From d3a66a3a7299096da0824513d9310e35a017cf8b Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Sun, 12 Sep 2021 23:21:34 -0600 Subject: [PATCH 01/18] Working to add runtime environment --- src/data/generate_registry_data.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 3f97eb8e..41cdbfdd 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 @@ -1310,7 +1311,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. @@ -1318,8 +1319,10 @@ def metadata_file_to_files(file_path, known_types, dycore, config, logger): known_ddts = known_types.known_ddt_names() mfiles = list() if os.path.exists(file_path): - meta_tables = parse_metadata_file(file_path, known_ddts, logger) - logger.info("Parsing metadata_file, '{}'".format(file_path)) + meta_tables = parse_metadata_file(file_path, known_ddts, run_env) + if run_env.logger: + run_env.logger.info("Parsing metadata_file, '{}'".format(file_path)) + # end if else: emsg = "Metadata file, '{}', does not exist" raise CCPPError(emsg.format(file_path)) @@ -1335,7 +1338,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() @@ -1377,7 +1380,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. @@ -1389,8 +1392,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 @@ -1412,6 +1415,9 @@ def write_registry_files(registry, dycore, config, outdir, src_mod, src_root, """ files = list() 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: @@ -1447,7 +1453,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, '{}'" From fc57eda34762e9173c9c24e348cc5aafce19ed66 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Mon, 13 Sep 2021 22:32:27 -0600 Subject: [PATCH 02/18] Implement framework interface changes --- cime_config/cam_autogen.py | 24 +++++++++++++++------ src/physics/utils/phys_comp.F90 | 36 ++++++++++++++++---------------- src/physics/utils/phys_comp.meta | 4 ++-- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/cime_config/cam_autogen.py b/cime_config/cam_autogen.py index b3f91494..b63a1aab 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") @@ -476,8 +479,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: ") @@ -486,13 +489,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", ', '.join(preproc_defs)) _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_defs, 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_defs, kind_phys) diff --git a/src/physics/utils/phys_comp.F90 b/src/physics/utils/phys_comp.F90 index f35908dc..b14c3faf 100644 --- a/src/physics/utils/phys_comp.F90 +++ b/src/physics/utils/phys_comp.F90 @@ -133,20 +133,20 @@ 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 @@ -200,14 +200,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() @@ -226,8 +226,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 @@ -237,16 +237,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 @@ -272,13 +272,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 = () From 4de55c221787722fbe0c05ed2e6748bb120b0959 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Wed, 15 Sep 2021 20:20:20 -0600 Subject: [PATCH 03/18] Correct standard names for tend variables --- src/data/registry.xml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/data/registry.xml b/src/data/registry.xml index ca5e7285..03491549 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -245,20 +245,23 @@ 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 - Change in y wind from a parameterization @@ -285,9 +288,9 @@ constituent_mixing_ratio - 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 Total tendency from physics suite From caa3f2f71845a9aa532175350ded7fce957f993b Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Wed, 15 Sep 2021 20:56:43 -0600 Subject: [PATCH 04/18] Add ic_file_input_names to registry and fix logic bug in cam_register_close_file --- src/data/registry.xml | 2 ++ src/utils/cam_abortutils.F90 | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/data/registry.xml b/src/data/registry.xml index 03491549..a19299ac 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -259,6 +259,7 @@ allocatable="pointer"> Change in x wind from a parameterization horizontal_dimension vertical_layer_dimension + dTdt tend_dudt Change in y wind from a parameterization horizontal_dimension vertical_layer_dimension + dTdt tend_dvdt NULL() type(open_file_pointer), pointer :: open_files_pool => NULL() + private :: active_file_ptr + CONTAINS subroutine check_allocate(errcode, subname, fieldname, file, line) @@ -95,6 +97,21 @@ subroutine cam_register_open_file(file, file_name) end if end subroutine cam_register_open_file + logical function active_file_ptr(of_ptr) + ! Return .true. iff is associated and its member + ! is also associated + ! Dummy argument + type(open_file_pointer), pointer, intent(in) :: of_ptr + + active_file_ptr = .false. + if (associated(of_ptr)) then + if (associated(of_ptr%file_desc)) then + active_file_ptr = .true. + end if + end if + + end function active_file_ptr + subroutine cam_register_close_file(file, log_shutdown_in) ! Dummy arguments type(file_desc_t), target, intent(in) :: file @@ -114,7 +131,7 @@ subroutine cam_register_close_file(file, log_shutdown_in) end if ! Look to see if we have this file of_ptr => open_files_head - do while (associated(of_ptr) .and. associated(of_ptr%file_desc)) + do while (active_file_ptr(of_ptr)) if (file%fh == of_ptr%file_desc%fh) then ! Remove this file from the list if (associated(of_prev)) then From d39490956e5b084884ea70e30c5cd922f047c4ed Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Mon, 11 Oct 2021 09:31:20 -0600 Subject: [PATCH 05/18] new updaters branch --- Externals_CAM.cfg | 2 +- src/data/generate_registry_data.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 6ea35c22..3ad8aa5e 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.027 required = True [cosp2] diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 41cdbfdd..69404062 100755 --- a/src/data/generate_registry_data.py +++ b/src/data/generate_registry_data.py @@ -395,7 +395,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, + VarBase.__init__(self, elem_node, local_name, my_dimensions, known_types, parent_type, units_default=parent_units, kind_default=parent_kind, @@ -516,7 +516,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, + VarBase.__init__(self, var_node, local_name, my_dimensions, known_types, ttype, protected=protected) @@ -552,7 +552,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) + VarBase.write_metadata(self, outfile) if (self.allocatable == "parameter") or self.protected: outfile.write(' protected = True\n') # end if From e6ff6fe36ec16e04134c641d3f90eb400ae1222c Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Mon, 11 Oct 2021 16:36:02 -0600 Subject: [PATCH 06/18] update atmo_phys tag --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 3ad8aa5e..6c95f451 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -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_012 required = True [silhs] From 72e25d06055c4116de279802db88e1498ffe957c Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Mon, 18 Oct 2021 19:10:34 -0600 Subject: [PATCH 07/18] updating registry variable names --- src/data/registry.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/registry.xml b/src/data/registry.xml index 9b9db1ac..50829a82 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -261,7 +261,7 @@ tw_cur state_tw_cur - @@ -269,7 +269,7 @@ horizontal_dimension vertical_layer_dimension dTdt tend_dtdt - @@ -277,7 +277,7 @@ horizontal_dimension vertical_layer_dimension dTdt tend_dudt - From e5b2fd2731b1747ec5342a131feec96db1406acc Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Tue, 19 Oct 2021 10:58:23 -0600 Subject: [PATCH 08/18] updating file variable names --- src/data/registry.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/registry.xml b/src/data/registry.xml index 50829a82..2604d17b 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -275,7 +275,7 @@ allocatable="pointer"> Change in x wind from a parameterization horizontal_dimension vertical_layer_dimension - dTdt tend_dudt + dudt tend_dudt Change in y wind from a parameterization horizontal_dimension vertical_layer_dimension - dTdt tend_dvdt + dvdt tend_dvdt Date: Wed, 20 Oct 2021 13:33:32 -0600 Subject: [PATCH 09/18] updating externals --- Externals_CAM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 6c95f451..b5f6ec09 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.027 +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_012 +tag = atmos_phys0_00_013 required = True [silhs] From c004dddbc102f992682c8da134211738a251eace Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Wed, 20 Oct 2021 13:35:48 -0600 Subject: [PATCH 10/18] fix externals --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index b5f6ec09..ab47e4fd 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.029 +tag = CPF_0.2.026 required = True [cosp2] From 74908483c3cb18a009de688099d1e06c208d8d61 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Wed, 20 Oct 2021 15:04:38 -0600 Subject: [PATCH 11/18] fix unit tests --- .../write_init_files/missing_var_host.meta | 4 +- .../write_init_files/simple_host.meta | 4 +- .../write_init_files/temp_adjust.meta | 12 +- .../write_init_files/temp_adjust_4D.meta | 12 +- .../write_init_files/temp_adjust_bvd.meta | 12 +- .../temp_adjust_no_horiz.meta | 12 +- .../write_init_files/temp_adjust_noreq.meta | 12 +- .../write_init_files/temp_adjust_param.meta | 12 +- .../write_init_files/temp_adjust_scalar.meta | 12 +- test/unit/write_init_unit_tests.py | 197 +++++++++++++++--- 10 files changed, 213 insertions(+), 76 deletions(-) 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_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/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: From 349c6e5f4a19fdab87adf74f9f6570a4a40b646b Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Wed, 20 Oct 2021 15:08:23 -0600 Subject: [PATCH 12/18] reverting abortutils --- src/utils/cam_abortutils.F90 | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/utils/cam_abortutils.F90 b/src/utils/cam_abortutils.F90 index a3fc89b9..7fb89cfc 100644 --- a/src/utils/cam_abortutils.F90 +++ b/src/utils/cam_abortutils.F90 @@ -27,8 +27,6 @@ module cam_abortutils type(open_file_pointer), pointer :: open_files_tail => NULL() type(open_file_pointer), pointer :: open_files_pool => NULL() - private :: active_file_ptr - CONTAINS subroutine check_allocate(errcode, subname, fieldname, file, line) @@ -97,21 +95,6 @@ subroutine cam_register_open_file(file, file_name) end if end subroutine cam_register_open_file - logical function active_file_ptr(of_ptr) - ! Return .true. iff is associated and its member - ! is also associated - ! Dummy argument - type(open_file_pointer), pointer, intent(in) :: of_ptr - - active_file_ptr = .false. - if (associated(of_ptr)) then - if (associated(of_ptr%file_desc)) then - active_file_ptr = .true. - end if - end if - - end function active_file_ptr - subroutine cam_register_close_file(file, log_shutdown_in) ! Dummy arguments type(file_desc_t), target, intent(in) :: file @@ -132,7 +115,16 @@ subroutine cam_register_close_file(file, log_shutdown_in) end if ! Look to see if we have this file of_ptr => open_files_head - do while (active_file_ptr(of_ptr)) + + !Set while-loop control variable + file_loop_var = .false. + if (associated(of_ptr)) then + if(associated(of_ptr%file_desc)) then + file_loop_var = .true. + end if + end if + + do while (file_loop_var) if (file%fh == of_ptr%file_desc%fh) then ! Remove this file from the list if (associated(of_prev)) then From 9907a1f5c1a3be367160b3747506510bbe13fa0d Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 21 Oct 2021 11:01:25 -0600 Subject: [PATCH 13/18] ccpp_framework externals update; python version specification --- Externals_CAM.cfg | 2 +- cime_config/buildlib | 2 +- cime_config/buildnml | 3 +++ src/data/generate_registry_data.py | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index ab47e4fd..b5f6ec09 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] diff --git a/cime_config/buildlib b/cime_config/buildlib index 5076036f..e368af54 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, 7) stop_buffering_output() _LOGGER = logging.getLogger(__name__) diff --git a/cime_config/buildnml b/cime_config/buildnml index b9417701..416b0f8a 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -19,6 +19,7 @@ sys.path.append(_LIBDIR) from standard_script_setup import * from CIME.XML.standard_module_setup import * from CIME.buildnml import create_namelist_infile, parse_input +from CIME.utils import check_minimum_python_version from CIME.case import Case from CIME.utils import expect from CIME.nmlgen import NamelistGenerator @@ -32,6 +33,8 @@ sys.path.append(_CIME_CONFIG_PATH) # Import CAM's configure structure: from cam_config import ConfigCAM +check_minimum_python_version(3, 7) + # Open CIME case log: _LOGGER = logging.getLogger(__name__) diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 4ddbdfe9..1ecf21f1 100755 --- a/src/data/generate_registry_data.py +++ b/src/data/generate_registry_data.py @@ -434,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) - VarBase.__init__(self, 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, @@ -556,7 +556,7 @@ def __init__(self, var_node, known_types, vdict, logger): # end if # end for # Initialize the base class - VarBase.__init__(self, var_node, local_name, + super().__init__(var_node, local_name, my_dimensions, known_types, ttype, protected=protected) @@ -592,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": - VarBase.write_metadata(self, outfile) + super().write_metadata(outfile) if (self.allocatable == "parameter") or self.protected: outfile.write(' protected = True\n') # end if From e588cf5a577bb275662fb2e21f6d3eed338e2ab4 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Thu, 21 Oct 2021 11:42:34 -0600 Subject: [PATCH 14/18] update file hashes --- .../write_init_files/simple_build_cache_template.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..812fab08 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 @@ -TAG1TAG2noneTAG3UNSETREAL64 +TAG1TAG2noneTAG3UNSETREAL64 From b4e1bc161b6e262512db415ff71b3c0ef103971b Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Mon, 25 Oct 2021 09:36:39 -0600 Subject: [PATCH 15/18] fix unit tests --- test/unit/test_registry.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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]) From 51fbadac0ce53f6c522d2c292a588c3707b5b975 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Fri, 29 Oct 2021 10:09:08 -0600 Subject: [PATCH 16/18] update atmos_phys tag, pretty print xml --- Externals_CAM.cfg | 2 +- src/data/generate_registry_data.py | 3 ++- src/data/registry.xml | 3 ++- .../simple_build_cache_template.xml | 20 ++++++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index b5f6ec09..a05318da 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -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_013 +tag = atmos_phys0_00_014 required = True [silhs] diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 1ecf21f1..7c75365a 100755 --- a/src/data/generate_registry_data.py +++ b/src/data/generate_registry_data.py @@ -1439,9 +1439,9 @@ def metadata_file_to_files(file_path, known_types, dycore, config, run_env): known_ddts = known_types.known_ddt_names() mfiles = [] if os.path.exists(file_path): - meta_tables = parse_metadata_file(file_path, known_ddts, run_env) if run_env.logger: run_env.logger.info("Parsing metadata_file, '{}'".format(file_path)) + meta_tables = parse_metadata_file(file_path, known_ddts, run_env) # end if else: emsg = "Metadata file, '{}', does not exist" @@ -1535,6 +1535,7 @@ def write_registry_files(registry, dycore, config, outdir, src_mod, src_root, """ files = [] known_types = TypeRegistry() + logger.debug('hi') # Create a fake CCPPFrameworkEnv object to contain the logger run_env = CCPPFrameworkEnv(logger, host_files='', scheme_files='', suites='') diff --git a/src/data/registry.xml b/src/data/registry.xml index 2604d17b..55be5613 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -337,7 +337,8 @@ + units="None" type="physics_tend" + phys_timestep_init_zero="true"> Total tendency from physics suite 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 812fab08..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 + + + From 7adab47333fd5f1e1e41a7858625c65cd1d3c578 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Fri, 29 Oct 2021 14:26:22 -0600 Subject: [PATCH 17/18] update cime external; change python version check to 3.6 --- Externals.cfg | 2 +- cime_config/buildlib | 2 +- cime_config/buildnml | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) 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/cime_config/buildlib b/cime_config/buildlib index e368af54..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(3, 7) +check_minimum_python_version(3, 6) stop_buffering_output() _LOGGER = logging.getLogger(__name__) diff --git a/cime_config/buildnml b/cime_config/buildnml index 416b0f8a..934b8e8e 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -33,8 +33,6 @@ sys.path.append(_CIME_CONFIG_PATH) # Import CAM's configure structure: from cam_config import ConfigCAM -check_minimum_python_version(3, 7) - # Open CIME case log: _LOGGER = logging.getLogger(__name__) From b8fe050b0db95eee653096eb5ebe778f5d99ddc2 Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Fri, 29 Oct 2021 15:20:54 -0600 Subject: [PATCH 18/18] address pr comments --- cime_config/buildnml | 1 - src/data/generate_registry_data.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 934b8e8e..b9417701 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -19,7 +19,6 @@ sys.path.append(_LIBDIR) from standard_script_setup import * from CIME.XML.standard_module_setup import * from CIME.buildnml import create_namelist_infile, parse_input -from CIME.utils import check_minimum_python_version from CIME.case import Case from CIME.utils import expect from CIME.nmlgen import NamelistGenerator diff --git a/src/data/generate_registry_data.py b/src/data/generate_registry_data.py index 7c75365a..b732b104 100755 --- a/src/data/generate_registry_data.py +++ b/src/data/generate_registry_data.py @@ -1441,8 +1441,8 @@ def metadata_file_to_files(file_path, known_types, dycore, config, run_env): if os.path.exists(file_path): if run_env.logger: run_env.logger.info("Parsing metadata_file, '{}'".format(file_path)) - meta_tables = parse_metadata_file(file_path, known_ddts, run_env) # 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)) @@ -1535,7 +1535,6 @@ def write_registry_files(registry, dycore, config, outdir, src_mod, src_root, """ files = [] known_types = TypeRegistry() - logger.debug('hi') # Create a fake CCPPFrameworkEnv object to contain the logger run_env = CCPPFrameworkEnv(logger, host_files='', scheme_files='', suites='')