This file is indexed.

/usr/bin/adiosxml2h is in libadios-bin 1.13.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/python

import sys
import os

# Make sure that the gpp modules are available...
# ...for the installed gpp
sys.path.insert (0, os.path.dirname(sys.argv[0]) + '/../lib/python')

# ...for the gpp in the utils dir of the adios source
#sys.path.insert (0, os.path.dirname(sys.argv[0]))

import ad_config
import type_mapper


# checkXML attempts to call adios_lint to verify that adios will accept the xml file as valid
def checkXML (config_file, path):
    if path == '':
        adios_lint = 'adios_lint '
    elif os.path.exists (path+'/adios_lint'):
        adios_lint = path + '/adios_lint '
    elif os.path.exists (path+'/../adios_lint/adios_lint'):
        adios_lint = path+'/../adios_lint/adios_lint '
    else:
        adios_lint = 'adios_lint '

    rv = os.system (adios_lint + config_file)
    if rv == 0:
        return 'success'
    elif rv == 32512:  # System unable to find adios_lint command
        print("Unable to find adios_lint. Proceeding with code generation.")
        return 'success'
    else:
        print("gpp.py failed.")
        return 'failure'


def get_c_groupsize_code (group):
    groupsize_code_string = ''
    groupsize_code_string += 'adios_groupsize = '
    for v in group.get_vars():
        if v.is_scalar():
            if v.get_type() != 'string':
                groupsize_code_string += ('%d' % type_mapper.get_size (v.get_type() ) + ' \\\n                + ')
            else:
                groupsize_code_string += ('strlen(' + v.get_gwrite() + ')' + ' \\\n                + ')
        else:
            groupsize_code_string += ('%d * ' % type_mapper.get_size (v.get_type() ) )

            for d in v.get_dimensions():
                # need to check whether this is the timestep
                groupsize_code_string += '(' + d + ') * '

            groupsize_code_string = groupsize_code_string.rstrip ('* ')

            groupsize_code_string += (' \\\n                + ')

    # remove the final +\, and add the ;
    groupsize_code_string = groupsize_code_string.rstrip('+\\\n ') + ';'

    groupsize_code_string += '\nadios_group_size (adios_handle, adios_groupsize, &adios_totalsize);'

    return groupsize_code_string;


def get_fortran_groupsize_code (group):
    #print('Get Fortran Groupsize code for group "'+group.get_name()+'"')
    groupsize_code_string = 'adios_groupsize = 0\n'
    groupsize_code_string += 'adios_groupsize = adios_groupsize + '
    for v in group.get_vars():
        #print('  count variable "'+v.get_fullpath()+'"')
        if (v.is_scalar() ):
            if v.get_type() != 'string':
                groupsize_code_string += ('%d_8' % type_mapper.get_size (v.get_type() ) + ' &\n                + ')
            else:
                groupsize_code_string += ('len_trim(' + v.get_gwrite() + ')' + ' &\n                + ')
        else:
            groupsize_code_string += ('%d_8 * ' % type_mapper.get_size (v.get_type() ) )

            for d in v.get_dimensions():
                #print('  count dim "'+d+'"')
                # need to check whether this is the timestep
                groupsize_code_string += '(' + d + ') * '

            groupsize_code_string = groupsize_code_string.rstrip ('* ')

            groupsize_code_string += (' &\n                + ')

    # remove the final &+
    groupsize_code_string = groupsize_code_string.rstrip('+\n &') 

    groupsize_code_string += '\ncall adios_group_size (adios_handle, adios_groupsize, adios_totalsize, adios_err)'

    #print('Done Fortran Groupsize')
    return groupsize_code_string;


def get_fortran_write_statements (group):

    statements = ""

    for item in group.get_ordered_contents():

        if item.__class__.__name__ == 'gwrite':
            statements += '\n' + item.get_src() 
            continue

        if item.__class__.__name__ == 'attr':
            # Ignore the attributes for now
            continue

        # Otherwise, the item must be a variable
        var = item

        statements += '\ncall adios_write (adios_handle, "' + var.get_fullpath() + '", ' + var.get_gwrite() + ', adios_err)'

    statements += '\n'
    return statements



def get_c_write_statements (group):

    statements = ""

    for item in group.get_ordered_contents():

        if item.__class__.__name__ == 'gwrite':
            statements += '\n' + item.get_src() 
            continue

        if item.__class__.__name__ == 'attr':
            # Ignore the attributes for now
            continue

        # Otherwise, the item must be a variable
        var = item

        # The tricky bit here is deciding whether we need the & before the variable name.
        # We omit it in two cases: 1) the variable type is string, or 2) the variable is not a scalar
        if (var.get_c_type() == 'string' or var.get_dimensions() != None):
            var_prefix = ''
        else:
            var_prefix = '&'

        statements += '\nadios_write (adios_handle, "' + var.get_fullpath() + '", ' + var_prefix + var.get_gwrite() + ');'

    statements += '\n'
    return statements


def get_fortran_read_statements (group):

    statements = ""
    # Make a selection to capture writes done by the corresponding process in the writing application
    statements += 'call adios_selection_writeblock (s, rank)\n'

    for var in group.get_vars():
        if var.get_dimensions() == None:
            continue

        statements += 'call adios_schedule_read (fp, s, "' + var.get_name() + '", 0, 1, ' + var.get_gwrite() + ', adios_err)\n'

    statements += '\ncall adios_perform_reads (fp, adios_err)\n'
    statements += 'call adios_selection_delete (s)\n'
    return statements


def get_c_read_statements (group):

    statements = ""
    # Make a selection to capture writes done by the corresponding process in the writing application
    statements += 's = adios_selection_writeblock (rank);\n'
    #statements += 'uint64_t counts[64];\n'

    for var in group.get_vars():
        if var.get_dimensions() == None:
            continue

        # The tricky bit here is deciding whether we need the & before the variable name.
        # We omit it in two cases: 1) the variable type is string, or 2) the variable is not a scalar
        if (var.get_c_type() == 'string' or var.get_dimensions() != None):
            var_prefix = ''
        else:
            var_prefix = '&'

        statements += 'adios_schedule_read (fp, s, "' + var.get_name() + '", 0, 1, ' + var_prefix + var.get_gwrite() + ');\n'

    statements += 'adios_perform_reads (fp, 1);\n'
    statements += 'adios_selection_delete (s);\n'
    return statements



def generate_fortran (config):

    # Output a gwrite_*.fh file for each group in the config
    for group in config.get_groups():
        # Open file - the filename is gwrite_<group>.fh
        gwfile = open ('gwrite_' + group.get_name() + '.fh', 'w')

        # Set groupsize
        gwfile.write (get_fortran_groupsize_code (group) )

        # Write vars
        gwfile.write (get_fortran_write_statements (group) )

        # Close file
        gwfile.close()

    # Output a gread_*.fh file for each group in the config
    for group in config.get_groups():
        # Open file - the filename is gread_<group>.fh
        grfile = open ('gread_' + group.get_name() + '.fh', 'w')

        # Read vars
        grfile.write (get_fortran_read_statements (group) )

        # Close file
        grfile.close()


def generate_c (config):
    #print("c")

    # Output a gwrite_*.ch file for each group in the config
    for group in config.get_groups():
        # Open file - the filename is gwrite_<group>.ch
        gwfile = open ('gwrite_' + group.get_name() + '.ch', 'w')

        # Set groupsize
        gwfile.write (get_c_groupsize_code (group) )

        # Write vars
        gwfile.write (get_c_write_statements (group) )

        # Close ch file
        gwfile.close()

    # Output a gread_*.ch file for each group in the config
    for group in config.get_groups():
        # Open file - the filename is gread_<group>.ch
        grfile = open ('gread_' + group.get_name() + '.ch', 'w')

        # Read vars
        grfile.write (get_c_read_statements (group) )

        # Close ch file
        grfile.close()


def main (argv=None):
  
    # Must be called with one argument, the name of the xml file
    if len (sys.argv) != 2:
        print('Usage: gpp.py <config file>\n')
        return 1


    # If possible, run adios_lint to catch malformed config files
    check_val = checkXML (sys.argv[1], os.path.dirname(sys.argv[0]))
    if check_val != 'success':
        return 1


    # The ad_config object provides all relevant info from the XML file
    config = ad_config.adiosConfig (sys.argv[1])


    # Now just call the generator for the specified language
    lang = config.get_host_language().lower()
    if lang == 'fortran':
        generate_fortran (config)
    elif lang == 'c' or lang == 'cpp':
        generate_c (config)
    else:
        print("Fatal: Language unknown or unspecified")
        raise SystemExit



if __name__ == "__main__":
    main()