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
|
##
## Copyright (C) by Argonne National Laboratory
## See COPYRIGHT in top-level directory
##
from local_python import MPI_API_Global as G
from local_python.mpi_api import *
from local_python.binding_common import *
from local_python.binding_f90 import *
from local_python import RE
import os
def main():
G.parse_cmdline()
binding_dir = G.get_srcdir_path("src/binding")
f90_dir = "src/binding/fortran/use_mpi"
G.check_write_path("%s/" % f90_dir)
func_list = load_C_func_list(binding_dir, True) # suppress noise
if "no-mpiio" in G.opts:
func_list = [f for f in func_list if not f['name'].startswith('MPI_File_')]
else:
func_list.extend(get_mpiio_func_list())
func_list.extend(get_f77_dummy_func_list())
def has_cptr(func):
if G.opts['iso-c-binding'] == "yes":
for p in func['parameters']:
if p['kind'] == 'C_BUFFER':
return True
return False
# mpi_base.f90
G.out = []
dump_F_module_open("mpi_base")
is_pmpi = False
for func in func_list:
check_func_directives(func)
if '_skip_fortran' in func:
continue
G.out.append("INTERFACE %s" % func['name'])
G.out.append("INDENT")
dump_f90_func(func, is_pmpi)
if has_cptr(func):
# specific interface using "TYPE(C_PTR)"
dump_f90_func(func, is_pmpi, True)
G.out.append("DEDENT")
G.out.append("END INTERFACE")
G.out.append("")
dump_F_module_close("mpi_base")
f = "%s/mpi_base.f90" % f90_dir
dump_f90_file(f, G.out)
# pmpi_base.f90
G.out = []
dump_F_module_open("pmpi_base")
is_pmpi = True
for func in func_list:
check_func_directives(func)
if '_skip_fortran' in func:
continue
G.out.append("INTERFACE P%s" % func['name'])
G.out.append("INDENT")
dump_f90_func(func, is_pmpi)
if re.match(r'mpi_alloc_mem', func['name'], re.IGNORECASE) and G.opts['iso-c-binding'] == "yes":
# specific interface using "TYPE(C_PTR)"
dump_f90_func(func, is_pmpi, True)
G.out.append("DEDENT")
G.out.append("END INTERFACE")
G.out.append("")
dump_F_module_close("pmpi_base")
f = "%s/pmpi_base.f90" % f90_dir
dump_f90_file(f, G.out)
# mpi_constants.f90
G.out = []
dump_F_module_open("mpi_constants")
dump_f90_constants()
dump_F_module_close("mpi_constants")
f = "%s/mpi_constants.f90" % f90_dir
dump_f90_file(f, G.out)
# mpi_sizeofs.f90
G.out = []
dump_F_module_open("mpi_sizeofs")
dump_f90_sizeofs()
dump_F_module_close("mpi_sizeofs")
f = "%s/mpi_sizeofs.f90" % f90_dir
dump_f90_file(f, G.out)
# ---------------------------------------------------------
if __name__ == "__main__":
main()
|