diff --git a/cmake/ccpp_capgen.cmake b/cmake/ccpp_capgen.cmake index 24c891f2..27b8579f 100644 --- a/cmake/ccpp_capgen.cmake +++ b/cmake/ccpp_capgen.cmake @@ -47,8 +47,8 @@ function(ccpp_capgen) list(APPEND CCPP_CAPGEN_CMD_LIST "--output-root" "${arg_OUTPUT_ROOT}") endif() if(DEFINED arg_VERBOSITY) - string(REPEAT "--verbose" ${arg_VERBOSITY} VERBOSE_PARAMS_SEPERATED) - separate_arguments(VERBOSE_PARAMS UNIX_COMMAND "${VERBOSE_PARAMS_SEPERATED}") + string(REPEAT "--verbose " ${arg_VERBOSITY} VERBOSE_PARAMS_SEPARATED) + separate_arguments(VERBOSE_PARAMS UNIX_COMMAND "${VERBOSE_PARAMS_SEPARATED}") list(APPEND CCPP_CAPGEN_CMD_LIST ${VERBOSE_PARAMS}) endif() @@ -126,4 +126,3 @@ function(ccpp_datafile) string(REPLACE "," ";" CCPP_CAPS_LIST ${CCPP_CAPS}) # Convert "," separated list from python back to ";" separated list for CMake. set(CCPP_CAPS_LIST "${CCPP_CAPS_LIST}" PARENT_SCOPE) endfunction() - diff --git a/scripts/ccpp_capgen.py b/scripts/ccpp_capgen.py index a0b1e032..af6443b0 100755 --- a/scripts/ccpp_capgen.py +++ b/scripts/ccpp_capgen.py @@ -93,26 +93,29 @@ def delete_pathnames_from_file(capfile, logger): # end if ############################################################################### -def find_associated_fortran_file(filename): +def find_associated_fortran_file(filename, fortran_source_path): ############################################################################### - "Find the Fortran file associated with metadata file, " + """Find the Fortran file associated with metadata file, . + Fortran files should be in . + """ fort_filename = None lastdot = filename.rfind('.') - ##XXgoldyXX: Should we check to make sure ends in '.meta.'? if lastdot < 0: - base = filename + '.' + base = os.path.basename(filename + '.') else: - base = filename[0:lastdot+1] + base = os.path.basename(filename[0:lastdot+1]) # end if for extension in _FORTRAN_FILENAME_EXTENSIONS: - test_name = base + extension + test_name = os.path.join(fortran_source_path, base + extension) if os.path.exists(test_name): fort_filename = test_name break # end if # end for if fort_filename is None: - raise CCPPError("Cannot find Fortran file associated with {}".format(filename)) + emsg = f"Cannot find Fortran file associated with '{filename}'." + emsg += f"\nfortran_src_path = '{fortran_source_path}'" + raise CCPPError(emsg) # end if return fort_filename @@ -493,7 +496,8 @@ def parse_host_model_files(host_filenames, host_name, run_env, logger.info('Reading host model data from {}'.format(filename)) # parse metadata file mtables = parse_metadata_file(filename, known_ddts, run_env) - fort_file = find_associated_fortran_file(filename) + fortran_source_path = mtables[0].fortran_source_path + fort_file = find_associated_fortran_file(filename, fortran_source_path) ftables, _ = parse_fortran_file(fort_file, run_env) # Check Fortran against metadata (will raise an exception on error) mheaders = list() @@ -550,7 +554,8 @@ def parse_scheme_files(scheme_filenames, run_env, skip_ddt_check=False, # parse metadata file mtables = parse_metadata_file(filename, known_ddts, run_env, skip_ddt_check=skip_ddt_check) - fort_file = find_associated_fortran_file(filename) + fortran_source_path = mtables[0].fortran_source_path + fort_file = find_associated_fortran_file(filename, fortran_source_path) ftables, additional_routines = parse_fortran_file(fort_file, run_env) # Check Fortran against metadata (will raise an exception on error) mheaders = list() diff --git a/scripts/metadata_table.py b/scripts/metadata_table.py index 959866a9..3de515ef 100755 --- a/scripts/metadata_table.py +++ b/scripts/metadata_table.py @@ -64,6 +64,7 @@ relative_path = dependencies = module = # only needed if module name differs from filename + source_path = dynamic_constituent_routine = [ccpp-arg-table] @@ -357,19 +358,20 @@ class MetadataTable(): __table_start = re.compile(r"(?i)\s*\[\s*ccpp-table-properties\s*\]") def __init__(self, run_env, table_name_in=None, table_type_in=None, - dependencies=None, relative_path=None, + dependencies=None, relative_path=None, source_path=None, known_ddts=None, var_dict=None, module=None, parse_object=None, skip_ddt_check=False): """Initialize a MetadataTable, either with a name, , and type, , or with information from a file (). - if is None, and are - also stored. + if is None, , , and + are are also stored. If and / or module are passed (not allowed with