1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#! /usr/bin/env python3
##
## Copyright (C) by Argonne National Laboratory
## See COPYRIGHT in top-level directory
##
import sys
########################################################################################
##### printing utilities
########################################################################################
def display(OUTFILE, *argv):
for arg in argv:
if (arg.find('}') != -1):
display.indent -= 1
for x in range(display.indent):
OUTFILE.write(" ")
for arg in argv:
OUTFILE.write(arg)
if (arg.find('{') != -1):
display.indent += 1
display.indent = 0
########################################################################################
##### add the copyright header to the top of the file
########################################################################################
def copyright_c(outfile):
OUTFILE = open(outfile, "w")
OUTFILE.write("/*\n")
OUTFILE.write(" * Copyright (C) by Argonne National Laboratory\n")
OUTFILE.write(" * See COPYRIGHT in top-level directory\n")
OUTFILE.write(" *\n")
OUTFILE.write(" * DO NOT EDIT: AUTOMATICALLY GENERATED FILE !!\n")
OUTFILE.write(" */\n")
OUTFILE.write("\n")
OUTFILE.close()
def copyright_makefile(outfile):
OUTFILE = open(outfile, "w")
OUTFILE.write("##\n")
OUTFILE.write("## Copyright (C) by Argonne National Laboratory\n")
OUTFILE.write("## See COPYRIGHT in top-level directory\n")
OUTFILE.write("##\n")
OUTFILE.write("## DO NOT EDIT: AUTOMATICALLY GENERATED FILE !!\n")
OUTFILE.write("##\n")
OUTFILE.write("\n")
OUTFILE.close()
########################################################################################
##### generate an array of datatype arrays
########################################################################################
def generate_darrays(derived_types, darraylist, maxlevels):
darraylist.append([])
for level in range(maxlevels, 0, -1):
index = [ ]
for x in range(level):
index.append(0)
while True:
darray = [ ]
for x in range(level):
darray.append(derived_types[index[x]])
darraylist.append(darray)
index[-1] = index[-1] + 1
for x in range(level - 1, 0, -1):
if (index[x] == len(derived_types)):
index[x] = 0
index[x-1] = index[x-1] + 1
if (index[0] == len(derived_types)):
break
|