def from_fortran_file(cls, fortran_file: str, tmpdir: str = "."): """Builds GrFN object from a Fortran program.""" root_dir = os.path.abspath(tmpdir) ( python_sources, translated_python_files, mod_mapper_dict, fortran_filename, module_log_file_path, processing_modules, ) = f2grfn.fortran_to_grfn( fortran_file, temp_dir=str(tmpdir), root_dir_path=root_dir, processing_modules=False, ) # For now, just taking the first translated file. # TODO - generalize this. python_file = translated_python_files[0] G = cls.from_python_src( python_sources[0][0], python_file, fortran_file, module_log_file_path, mod_mapper_dict, processing_modules, ) return G
def get_python_source(original_fortran_file): # Setting a root directory to absolute path of /tests directory. root_dir = os.path.abspath(".") result_tuple = f2grfn.fortran_to_grfn( original_fortran_file, temp_dir=TEMP_DIR, root_dir_path=root_dir, processing_modules=False, module_file_name= f"{TEMP_DIR}/{Path(original_fortran_file).stem}_modFileLog.json") return result_tuple
def from_fortran_file(cls, fortran_file: str, tmpdir: str = "."): """Builds GrFN object from a Fortran program.""" if tmpdir == "." and "/" in fortran_file: tmpdir = Path(fortran_file).parent ( pySrc, lambdas_path, json_filename, stem, fortran_filename, ) = f2grfn.fortran_to_grfn(fortran_file, True, True, str(tmpdir)) G = cls.from_python_src(pySrc, lambdas_path, json_filename, stem, fortran_file) return G
def get_python_source( original_fortran_file) -> Tuple[str, str, str, str, list, str]: return f2grfn.fortran_to_grfn(original_fortran_file, True, False, ".")
help="Module log file name.", default="modFileLog.json", ) args = parser.parse_args() ( python_sources, translated_python_files, mode_mapper_dict, original_fortran_file, module_log_file_path, processing_modules, ) = f2grfn.fortran_to_grfn( args.file, args.directory, args.root, args.moduleLog, save_intermediate_files=True, ) python_file_num = 0 for python_file in translated_python_files: lambdas_file_path = python_file.replace(".py", "_lambdas.py") grfn_dict = f2grfn.generate_grfn( python_sources[python_file_num][0], python_file, lambdas_file_path, mode_mapper_dict[0], original_fortran_file, module_log_file_path, processing_modules, )