diff --git a/Externals.cfg b/Externals.cfg index 4d5c1d07..2f9f16c8 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -16,7 +16,7 @@ local_path = components/cice required = False [cime] -tag = cime5.8.38 +tag = cime5.8.47 protocol = git repo_url = https://github.com/ESMCI/cime local_path = cime diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 6ea35c22..a05318da 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -2,7 +2,7 @@ local_path = ccpp_framework protocol = git repo_url = https://github.com/gold2718/ccpp-framework -tag = CPF_0.2.026 +tag = CPF_0.2.029 required = True [cosp2] @@ -23,7 +23,7 @@ required = False local_path = src/physics/ncar_ccpp protocol = git repo_url = https://github.com/NCAR/atmospheric_physics -tag = atmos_phys0_00_011 +tag = atmos_phys0_00_014 required = True [silhs] diff --git a/cime_config/buildlib b/cime_config/buildlib index 5076036f..34c8c053 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -28,7 +28,7 @@ from CIME.buildlib import parse_input from CIME.build import get_standard_makefile_args #pylint: enable=wrong-import-position -check_minimum_python_version(2, 7) +check_minimum_python_version(3, 6) stop_buffering_output() _LOGGER = logging.getLogger(__name__) diff --git a/cime_config/cam_autogen.py b/cime_config/cam_autogen.py index 01a5ee69..a45560e5 100644 --- a/cime_config/cam_autogen.py +++ b/cime_config/cam_autogen.py @@ -9,6 +9,7 @@ # Import needed python libraries/modules ######################################## +# Python library imports import sys import os import logging @@ -397,6 +398,7 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n # Import needed CCPP-framework scripts: try: from ccpp_capgen import capgen + from framework_env import CCPPFrameworkEnv #pylint: disable=redefined-outer-name # pylint change because of doctest import below from metadata_table import find_scheme_names @@ -453,6 +455,7 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n # Figure out if we need to generate new physics code genccpp_dir = os.path.join(bldroot, "ccpp") kind_phys = 'REAL64' + kind_types = ["kind_phys={}".format(kind_phys)] # Set location of CCPP "capfiles.txt" file: cap_output_file = os.path.join(genccpp_dir, "ccpp_datatable.xml") @@ -482,8 +485,8 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n do_gen_ccpp = True # End if if do_gen_ccpp: - gen_hostcap = True gen_docfiles = False + use_error_obj = False # print extra info to bldlog if DEBUG is TRUE _LOGGER.debug("Calling capgen: ") @@ -492,13 +495,22 @@ def generate_physics_suites(ccpp_scripts_path, build_cache, preproc_defs, host_n _LOGGER.debug(" suite definition files: %s", ', '.join(sdfs)) _LOGGER.debug(" preproc defs: %s", preproc_cache_str) _LOGGER.debug(" output directory: '%s'", genccpp_dir) - _LOGGER.debug(" kind_phys: '%s'", kind_phys) + for kind_type in kind_types: + name, type = [x.strip() for x in kind_type.split('=')] + _LOGGER.debug(" %s: '%s'", name, type) + # end for # generate CCPP caps - force_overwrite = False - capgen(host_files, scheme_files, sdfs, cap_output_file, - preproc_cache_str, gen_hostcap, gen_docfiles, genccpp_dir, - host_name, kind_phys, force_overwrite, _LOGGER) + run_env = CCPPFrameworkEnv(_LOGGER, host_files=host_files, + scheme_files=scheme_files, suites=sdfs, + preproc_directives=preproc_defs, + generate_docfiles=gen_docfiles, + host_name=host_name, kind_types=kind_types, + use_error_obj=use_error_obj, + force_overwrite=False, + output_root=genccpp_dir, + ccpp_datafile=cap_output_file) + capgen(run_env) # save build details in the build cache build_cache.update_ccpp(sdfs, scheme_files, preproc_cache_str, kind_phys) diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 0f662f52..b732b104 100755 --- a/src/data/generate_registry_data.py +++ b/src/data/generate_registry_data.py @@ -28,6 +28,7 @@ # CCPP framework imports # pylint: disable=wrong-import-position +from framework_env import CCPPFrameworkEnv from parse_tools import validate_xml_file, read_xml_file from parse_tools import find_schema_file, find_schema_version from parse_tools import init_log, CCPPError, ParseInternalError @@ -433,7 +434,7 @@ def __init__(self, elem_node, parent_name, dimensions, known_types, ', '.join(dimensions))) # end if local_name = '{}({})'.format(parent_name, self.index_string) - super(ArrayElement, self).__init__(elem_node, local_name, my_dimensions, + super().__init__(elem_node, local_name, my_dimensions, known_types, parent_type, units_default=parent_units, kind_default=parent_kind, @@ -555,7 +556,7 @@ def __init__(self, var_node, known_types, vdict, logger): # end if # end for # Initialize the base class - super(Variable, self).__init__(var_node, local_name, + super().__init__(var_node, local_name, my_dimensions, known_types, ttype, protected=protected) @@ -591,7 +592,7 @@ def __init__(self, var_node, known_types, vdict, logger): def write_metadata(self, outfile): """Write out this variable as CCPP metadata""" if self.access != "private": - super(Variable, self).write_metadata(outfile) + super().write_metadata(outfile) if (self.allocatable == "parameter") or self.protected: outfile.write(' protected = True\n') # end if @@ -1430,7 +1431,7 @@ def parse_command_line(args, description): return pargs ############################################################################### -def metadata_file_to_files(file_path, known_types, dycore, config, logger): +def metadata_file_to_files(file_path, known_types, dycore, config, run_env): ############################################################################### """Read the metadata file at and convert it to a registry File object. @@ -1438,8 +1439,10 @@ def metadata_file_to_files(file_path, known_types, dycore, config, logger): known_ddts = known_types.known_ddt_names() mfiles = [] if os.path.exists(file_path): - meta_tables = parse_metadata_file(file_path, known_ddts, logger) - logger.info("Parsing metadata_file, '{}'".format(file_path)) + if run_env.logger: + run_env.logger.info("Parsing metadata_file, '{}'".format(file_path)) + # end if + meta_tables = parse_metadata_file(file_path, known_ddts, run_env) else: emsg = "Metadata file, '{}', does not exist" raise CCPPError(emsg.format(file_path)) @@ -1455,7 +1458,7 @@ def metadata_file_to_files(file_path, known_types, dycore, config, logger): section = ''.format(hname, htype) sect_xml = ET.fromstring(section) mfile = File(sect_xml, known_types, dycore, config, - logger, gen_code=False, file_path=file_path) + run_env.logger, gen_code=False, file_path=file_path) # Add variables # Note, we only support one section per table for host variables sections = mtable.sections() @@ -1497,7 +1500,7 @@ def metadata_file_to_files(file_path, known_types, dycore, config, logger): # end if vnode_str += '\n' var_node = ET.fromstring(vnode_str) - mfile.add_variable(var_node, logger) + mfile.add_variable(var_node, run_env.logger) # end for if htype == 'ddt': # We defined the variables, now create the DDT for them. @@ -1509,8 +1512,8 @@ def metadata_file_to_files(file_path, known_types, dycore, config, logger): vnode_str += '\n' var_node = ET.fromstring(vnode_str) new_ddt = DDT(var_node, known_types, mfile.var_dict, - dycore, config, logger) - mfile.add_ddt(new_ddt, logger=logger) + dycore, config, run_env.logger) + mfile.add_ddt(new_ddt, logger=run_env.logger) # end if mfiles.append(mfile) # end for @@ -1532,6 +1535,9 @@ def write_registry_files(registry, dycore, config, outdir, src_mod, src_root, """ files = [] known_types = TypeRegistry() + # Create a fake CCPPFrameworkEnv object to contain the logger + run_env = CCPPFrameworkEnv(logger, host_files='', + scheme_files='', suites='') for section in registry: sec_name = section.get('name') if sec_name: @@ -1567,7 +1573,7 @@ def write_registry_files(registry, dycore, config, outdir, src_mod, src_root, # end if # end if meta_files = metadata_file_to_files(file_path, known_types, - dycore, config, logger) + dycore, config, run_env) files.extend(meta_files) else: emsg = "Unknown registry object type, '{}'" diff --git a/src/data/registry.xml b/src/data/registry.xml index 970bb445..55be5613 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -261,24 +261,29 @@ tw_cur state_tw_cur - Change in temperature from a parameterization horizontal_dimension vertical_layer_dimension dTdt tend_dtdt - Change in x wind from a parameterization horizontal_dimension vertical_layer_dimension + dudt tend_dudt - Change in y wind from a parameterization horizontal_dimension vertical_layer_dimension + dvdt tend_dvdt frontogenesis_angle - total_tendency_of_air_temperature - total_tendency_of_x_wind - total_tendency_of_y_wind + tendency_of_air_temperature_due_to_model_physics + tendency_of_x_wind_due_to_model_physics + tendency_of_y_wind_due_to_model_physics Physics state variables updated by dynamical core + standard_name="tendency_due_to_model_physics" + units="None" type="physics_tend" + phys_timestep_init_zero="true"> Total tendency from physics suite diff --git a/src/physics/utils/phys_comp.F90 b/src/physics/utils/phys_comp.F90 index ec6ef65b..832467e0 100644 --- a/src/physics/utils/phys_comp.F90 +++ b/src/physics/utils/phys_comp.F90 @@ -133,21 +133,21 @@ subroutine phys_init(cam_runtime_opts, phys_state, phys_tend, cam_out) ! Local variables real(kind_phys) :: dtime_phys = 0.0_kind_phys ! Not set yet character(len=512) :: errmsg - integer :: errflg + integer :: errcode - errflg = 0 + errcode = 0 call physconst_init(columns_on_task, pver, pverp) call allocate_physics_types_fields(columns_on_task, pver, pverp, & pcnst, set_init_val_in=.true., reallocate_in=.false.) call cam_ccpp_physics_initialize(phys_suite_name, dtime_phys, & - errmsg, errflg) - if (errflg /= 0) then + errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_physics_initialize: '//trim(errmsg)) end if call ccpp_physics_suite_part_list(phys_suite_name, suite_parts, & - errmsg, errflg) - if (errflg /= 0) then + errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_suite_part_list: '//trim(errmsg)) end if @@ -202,14 +202,14 @@ subroutine phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, & ! Local variables type(file_desc_t), pointer :: ncdata character(len=512) :: errmsg - integer :: errflg + integer :: errcode integer :: part_ind integer :: col_start integer :: col_end integer :: data_frame logical :: use_init_variables - errflg = 0 + errcode = 0 ! Physics needs to read in all data not read in by the dycore ncdata => initial_file_get_id() @@ -231,8 +231,8 @@ subroutine phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, & ! Initialize the physics time step call cam_ccpp_physics_timestep_initial(phys_suite_name, dtime_phys, & - errmsg, errflg) - if (errflg /= 0) then + errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_physics_timestep_initial: '//trim(errmsg)) end if @@ -243,16 +243,16 @@ subroutine phys_run2(dtime_phys, cam_runtime_opts, phys_state, phys_tend, & ! Run CCPP suite do part_ind = 1, size(suite_parts, 1) call cam_ccpp_physics_run(phys_suite_name, suite_parts(part_ind), & - col_start, col_end, dtime_phys, errmsg, errflg) - if (errflg /= 0) then + col_start, col_end, dtime_phys, errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_physics_run: '//trim(errmsg)) end if end do ! Finalize the time step call cam_ccpp_physics_timestep_final(phys_suite_name, dtime_phys, & - errmsg, errflg) - if (errflg /= 0) then + errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_physics_timestep_final: '//trim(errmsg)) end if @@ -278,13 +278,13 @@ subroutine phys_final(cam_runtime_opts, phys_state, phys_tend) ! Local variables real(kind_phys) :: dtime_phys = 0.0_kind_phys ! Not used character(len=512) :: errmsg - integer :: errflg + integer :: errcode - errflg = 0 + errcode = 0 call cam_ccpp_physics_finalize(phys_suite_name, dtime_phys, & - errmsg, errflg) - if (errflg /= 0) then + errmsg, errcode) + if (errcode /= 0) then call endrun('cam_ccpp_physics_finalize: '//trim(errmsg)) end if deallocate(suite_names) diff --git a/src/physics/utils/phys_comp.meta b/src/physics/utils/phys_comp.meta index 444dc51f..84d0673d 100644 --- a/src/physics/utils/phys_comp.meta +++ b/src/physics/utils/phys_comp.meta @@ -29,8 +29,8 @@ dimensions = () type = character kind = len=512 -[ errflg ] - standard_name = ccpp_error_flag +[ errcode ] + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP units = flag dimensions = () diff --git a/test/unit/sample_files/write_init_files/missing_var_host.meta b/test/unit/sample_files/write_init_files/missing_var_host.meta index d8b2f8b0..6ab3f971 100644 --- a/test/unit/sample_files/write_init_files/missing_var_host.meta +++ b/test/unit/sample_files/write_init_files/missing_var_host.meta @@ -37,9 +37,9 @@ type = character kind = len=512 [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer [ theta ] diff --git a/test/unit/sample_files/write_init_files/simple_build_cache_template.xml b/test/unit/sample_files/write_init_files/simple_build_cache_template.xml index 04cba90d..3000a844 100644 --- a/test/unit/sample_files/write_init_files/simple_build_cache_template.xml +++ b/test/unit/sample_files/write_init_files/simple_build_cache_template.xml @@ -1 +1,19 @@ -TAG1TAG2noneTAG3UNSETREAL64 + + TAG1 + + + TAG2 + + + none + + + + + + TAG3 + UNSET + REAL64 + + + diff --git a/test/unit/sample_files/write_init_files/simple_host.meta b/test/unit/sample_files/write_init_files/simple_host.meta index a051798d..0a50a1e9 100644 --- a/test/unit/sample_files/write_init_files/simple_host.meta +++ b/test/unit/sample_files/write_init_files/simple_host.meta @@ -37,8 +37,8 @@ type = character kind = len=512 [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer diff --git a/test/unit/sample_files/write_init_files/temp_adjust.meta b/test/unit/sample_files/write_init_files/temp_adjust.meta index b2ab93ee..09344292 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust.meta @@ -47,9 +47,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -65,9 +65,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -83,9 +83,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_4D.meta b/test/unit/sample_files/write_init_files/temp_adjust_4D.meta index 9a265294..103a0298 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_4D.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_4D.meta @@ -47,9 +47,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -65,9 +65,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -83,9 +83,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_bvd.meta b/test/unit/sample_files/write_init_files/temp_adjust_bvd.meta index 76c028f5..abc2b9ed 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_bvd.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_bvd.meta @@ -47,9 +47,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -65,9 +65,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -83,9 +83,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_no_horiz.meta b/test/unit/sample_files/write_init_files/temp_adjust_no_horiz.meta index f531f9f9..5a7ec3a9 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_no_horiz.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_no_horiz.meta @@ -47,9 +47,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -65,9 +65,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -83,9 +83,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_noreq.meta b/test/unit/sample_files/write_init_files/temp_adjust_noreq.meta index 62e1cbfd..2bca7fb3 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_noreq.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_noreq.meta @@ -33,9 +33,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -51,9 +51,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -69,9 +69,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_param.meta b/test/unit/sample_files/write_init_files/temp_adjust_param.meta index efb04561..03c1bc0f 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_param.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_param.meta @@ -54,9 +54,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -72,9 +72,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -90,9 +90,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/sample_files/write_init_files/temp_adjust_scalar.meta b/test/unit/sample_files/write_init_files/temp_adjust_scalar.meta index 4d4b818a..bfd1d968 100644 --- a/test/unit/sample_files/write_init_files/temp_adjust_scalar.meta +++ b/test/unit/sample_files/write_init_files/temp_adjust_scalar.meta @@ -47,9 +47,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -65,9 +65,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out @@ -83,9 +83,9 @@ kind = len=512 intent = out [ errflg ] - standard_name = ccpp_error_flag + standard_name = ccpp_error_code long_name = Error flag for error handling in CCPP - units = flag + units = 1 dimensions = () type = integer intent = out diff --git a/test/unit/test_registry.py b/test/unit/test_registry.py index 74c72faf..879e6030 100644 --- a/test/unit/test_registry.py +++ b/test/unit/test_registry.py @@ -47,6 +47,7 @@ # pylint: disable=wrong-import-position from generate_registry_data import gen_registry from generate_registry_data import metadata_file_to_files, TypeRegistry +from framework_env import CCPPFrameworkEnv # pylint: enable=wrong-import-position ############################################################################### @@ -1152,11 +1153,14 @@ def test_bad_metadata_file_dup_section(self): # Setup test infilename = os.path.join(_SAMPLE_FILES_DIR, "phys_types_dup_section.meta") + # Create fake CCPPFrameworkEnv object to contain the logger + run_env = CCPPFrameworkEnv(logging.getLogger("badmf"), host_files='', + scheme_files='', suites='') # Run test with self.assertRaises(ValueError) as verr: metadata_file_to_files(infilename, TypeRegistry(), 'eul', {}, - logging.getLogger("badmf")) + run_env) # Check exception message emsg = "module, 'physics_types_simple', table already contains " emsg += "'physics_types_simple', at {}:36".format(infilename) @@ -1169,10 +1173,14 @@ def test_bad_metadata_file_no_table(self): table_name = "phys_types_no_table.meta" infilename = os.path.join(_SAMPLE_FILES_DIR, table_name) + # Create fake CCPPFrameworkEnv object to contain the logger + run_env = CCPPFrameworkEnv(logging.getLogger("badmf"), host_files='', + scheme_files='', suites='') + # Run test with self.assertRaises(ValueError) as verr: metadata_file_to_files(infilename, TypeRegistry(), 'eul', {}, - logging.getLogger("badmf")) + run_env) # Check exception message emsg = "Missing metadata section ([ccpp-arg-table]) for physics_types_simple" self.assertEqual(emsg, str(verr.exception).split('\n')[0]) diff --git a/test/unit/write_init_unit_tests.py b/test/unit/write_init_unit_tests.py index e0a32729..3f0c02c5 100644 --- a/test/unit/write_init_unit_tests.py +++ b/test/unit/write_init_unit_tests.py @@ -62,6 +62,7 @@ # pylint: disable=wrong-import-position from ccpp_capgen import capgen +from framework_env import CCPPFrameworkEnv from generate_registry_data import gen_registry import write_init_files as write_init # pylint: enable=wrong-import-position @@ -142,8 +143,17 @@ def test_simple_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -210,8 +220,17 @@ def test_no_reqvar_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -278,8 +297,17 @@ def test_protected_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -345,8 +373,17 @@ def test_missing_var_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: # Note: "assertLogs" method doesn't exist in python 2: @@ -427,8 +464,17 @@ def test_dual_standard_name_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Run test with self.assertRaises(ValueError) as verr: @@ -492,8 +538,18 @@ def test_no_horiz_var_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + + capgen(run_env) # Run test with self.assertRaises(ValueError) as verr: @@ -555,8 +611,17 @@ def test_scalar_var_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ["kind_phys={REAL64}"] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Run test with self.assertRaises(ValueError) as verr: @@ -617,8 +682,17 @@ def test_4d_var_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types = ["kind_phys=REAL64"] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Run test with self.assertRaises(ValueError) as verr: @@ -680,8 +754,17 @@ def test_missing_ic_names_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=["kind_phys=REAL64"] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: # Note: "assertLogs" method doesn't exist in python 2: @@ -760,8 +843,17 @@ def test_ddt_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -828,8 +920,17 @@ def test_ddt2_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -896,8 +997,17 @@ def test_ddt_array_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -964,8 +1074,17 @@ def test_meta_file_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -1032,8 +1151,17 @@ def test_parameter_reg_write_init(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Generate physics initialization files: retmsg = write_init.write_init_files(files, _TMP_DIR, 3, @@ -1103,8 +1231,17 @@ def test_bad_vertical_dimension(self): error_on_no_validate=True) # Generate CCPP capgen files: - capgen(host_files, scheme_files, sdf, cap_datafile,'', - False, False, _TMP_DIR, 'cam', 'REAL64', True, logger) + kind_types=['kind_phys=REAL64'] + run_env = CCPPFrameworkEnv(logger, host_files=host_files, + scheme_files=scheme_files, suites=sdf, + preproc_directives='', + generate_docfiles=False, + host_name='cam', kind_types=kind_types, + use_error_obj=False, + force_overwrite=True, + output_root=_TMP_DIR, + ccpp_datafile=cap_datafile) + capgen(run_env) # Run test with self.assertRaises(ValueError) as verr: