File: yutils.py

package info (click to toggle)
mpich 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,184 kB
  • sloc: ansic: 1,040,629; cpp: 82,270; javascript: 40,763; perl: 27,933; python: 16,041; sh: 14,676; xml: 14,418; f90: 12,916; makefile: 9,270; fortran: 8,046; java: 4,635; asm: 324; ruby: 103; awk: 27; lisp: 19; php: 8; sed: 4
file content (73 lines) | stat: -rw-r--r-- 2,570 bytes parent folder | download | duplicates (5)
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