diff --git a/.gitmodules b/.gitmodules index 35ceeb156..605b3f5a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "ccpp-framework"] path = ccpp_framework url = https://github.com/NCAR/ccpp-framework - fxtag = sima_2026-04-13 + fxtag = sima_2026-07-15 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework [submodule "history"] @@ -20,7 +20,7 @@ [submodule "ncar-physics"] path = src/physics/ncar_ccpp url = https://github.com/ESCOMP/atmospheric_physics - fxtag = atmos_phys0_25_000 + fxtag = 9865ef6a9384030233abe23e77acdc208abecdc3 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics [submodule "rrtmgp-data"] diff --git a/ccpp_framework b/ccpp_framework index 36b6052d1..766261cf0 160000 --- a/ccpp_framework +++ b/ccpp_framework @@ -1 +1 @@ -Subproject commit 36b6052d1943447db6f9717ccbcbf296cdcefef3 +Subproject commit 766261cf0433692037eec258ba87dcdbea552692 diff --git a/cime_config/create_readnl_files.py b/cime_config/create_readnl_files.py index ad409aae3..06f4a83fc 100644 --- a/cime_config/create_readnl_files.py +++ b/cime_config/create_readnl_files.py @@ -404,12 +404,17 @@ def missing(self): def write_metadata_entry(self, file): """Write a metadata entry for this NLVar object to .""" if self.array_len: - # Write unique array dimension variable(s) + # Write unique array dimension variable(s). These are declared + # as Fortran parameters (see write_dimension_decls), so mark them + # protected: schemes only use them as dimensions, and the host + # provides their values, so they must not be treated as fields to + # read from the initial-conditions file. for aname in self.__array_names: file.write(f"[ {aname} ]\n") file.write(f" standard_name = {aname}\n") file.write(" type = integer | units = 1\n") file.write(" dimensions = ()\n") + file.write(" protected = True\n") # end for # end if (no else) file.write(f"[ {self.var_name} ]\n") diff --git a/src/data/cam_var_init_marks.inc b/src/data/cam_var_init_marks.inc index b9b44c039..ba5d4b89a 100644 --- a/src/data/cam_var_init_marks.inc +++ b/src/data/cam_var_init_marks.inc @@ -5,6 +5,8 @@ ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -13,7 +15,7 @@ ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -33,6 +35,7 @@ ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -45,7 +48,7 @@ found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -73,6 +76,7 @@ ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -87,7 +91,7 @@ ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -108,6 +112,7 @@ ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -125,7 +130,7 @@ ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -136,7 +141,7 @@ if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/src/data/write_init_files.py b/src/data/write_init_files.py index 98e52617a..55728d4c1 100644 --- a/src/data/write_init_files.py +++ b/src/data/write_init_files.py @@ -132,7 +132,7 @@ def write_init_files(cap_database, ic_names, registry_constituents, vars_init_va # Gather all the host model variables that are required by # any of the compiled CCPP physics suites. - in_vars, out_vars, constituent_set, retmsg = gather_ccpp_req_vars(cap_database, registry_constituents) + in_vars, out_vars, constituent_set, retmsg = gather_ccpp_req_vars(cap_database) # Quit now if there are missing variables if retmsg: @@ -306,7 +306,7 @@ def _find_and_add_host_variable(stdname, host_dict, var_dict): return missing_vars ############################################################################## -def gather_ccpp_req_vars(cap_database, registry_constituents): +def gather_ccpp_req_vars(cap_database): """ Generate a list of host-model and constituent variables required by the CCPP physics suites potentially being used @@ -340,10 +340,11 @@ def gather_ccpp_req_vars(cap_database, registry_constituents): (stdname not in in_vars) and (stdname not in _EXCLUDED_STDNAMES)): if is_const: - #Add variable to constituent set: constituent_vars.add(stdname) - #Add variable to required variable list if it's not a registry constituent - if stdname not in registry_constituents: + # Do not add advected constituents to the host variable + # list so they are not included in phys_var_stdnames and + # can be read in the constituent path: + if not cvar.get_prop_value('advected'): in_vars[stdname] = cvar # end if else: @@ -974,6 +975,7 @@ def write_phys_read_subroutine(outfile, host_dict, host_vars, host_imports, "cam_constituents_array", "cam_model_const_properties"]], ["ccpp_kinds", ["kind_phys"]], + ["string_utils", ["to_lower", "to_upper"]], [phys_check_fname_str, ["phys_var_num", "phys_var_stdnames", "input_var_names", "std_name_len", "is_initialized"]], @@ -1180,26 +1182,29 @@ def write_phys_read_subroutine(outfile, host_dict, host_vars, host_imports, outfile.write("var_found = .false.", 3) outfile.comment("Check if constituent standard name in registered SIMA standard names list:", 3) outfile.write("call const_props(constituent_idx)%standard_name(std_name)", 3) - outfile.write("if(any(phys_var_stdnames == trim(std_name))) then", 3) + outfile.comment("Find array index to extract correct input names", 3) + outfile.comment("(case-insensitive: see find_input_name_idx):", 3) + outfile.write("const_input_idx = -1", 3) + outfile.write("do n=1, phys_var_num", 3) + outfile.write("if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then", 4) + outfile.write("const_input_idx = n", 5) + outfile.write("exit", 5) + outfile.write("end if", 4) + outfile.write("end do", 3) + outfile.write("if(const_input_idx > 0) then", 3) outfile.comment("Don't read the variable in if it's already initialized", 4) outfile.write("if (is_initialized(std_name)) then", 4) outfile.write("cycle", 5) outfile.write("end if", 4) - outfile.comment("Find array index to extract correct input names:", 4) - outfile.write("do n=1, phys_var_num", 4) - outfile.write("if(trim(phys_var_stdnames(n)) == trim(std_name)) then", 5) - outfile.write("const_input_idx = n", 6) - outfile.write("exit", 6) - outfile.write("end if", 5) - outfile.write("end do", 4) outfile.write("call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found)", 4) outfile.write("else", 3) outfile.comment("If not in standard names list, then attempt constituent name",4) - outfile.comment("and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names:",4) - # The , cnst_, pbuf_ prefix default fallbacks - # allows us to not enumerate all needed constituents from snapshots in the - # registry, yet allow reading their values from CAM snapshots. - outfile.write("call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found)", 4) + outfile.comment("and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names.",4) + outfile.comment("Standard names are case-insensitive (capgen lowercases them) but netCDF names are not,",4) + outfile.comment("so also try the all-upper and all-lower case spellings of the constituent name:",4) + # Try uppercase and lowercase variants for constituent names to match CAM + # e.g., O3, NO2, NUMLIQ (most species) ... num_a1, num_a2 (aerosols) + outfile.write("call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found)", 4) outfile.write("end if", 3) outfile.write("if(.not. var_found) then", 3) outfile.write("constituent_has_default = .false.", 4) @@ -1306,6 +1311,7 @@ def write_phys_check_subroutine(outfile, host_dict, host_vars, host_imports, "cam_model_const_properties"]], ["cam_constituents", ["const_get_index"]], ["ccpp_kinds", ["kind_phys"]], + ["string_utils", ["to_lower", "to_upper"]], ["cam_logfile", ["iulog"]], ["spmd_utils", ["masterproc"]], ["phys_vars_init_check", ["is_read_from_file"]], @@ -1492,25 +1498,28 @@ def write_phys_check_subroutine(outfile, host_dict, host_vars, host_imports, outfile.write("do constituent_idx = 1, size(const_props)", 2) outfile.comment("Check if constituent standard name in registered SIMA standard names list:", 3) outfile.write("call const_props(constituent_idx)%standard_name(std_name)", 3) - outfile.write("if(any(phys_var_stdnames == std_name)) then", 3) - outfile.comment("Find array index to extract correct input names:", 4) - outfile.write("do n=1, phys_var_num", 4) - outfile.write("if(trim(phys_var_stdnames(n)) == trim(std_name)) then", 5) - outfile.write("const_input_idx = n", 6) - outfile.write("exit", 6) - outfile.write("end if", 5) - outfile.write("end do", 4) + outfile.comment("Find array index to extract correct input names", 3) + outfile.comment("(case-insensitive: see find_input_name_idx):", 3) + outfile.write("const_input_idx = -1", 3) + outfile.write("do n=1, phys_var_num", 3) + outfile.write("if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then", 4) + outfile.write("const_input_idx = n", 5) + outfile.write("exit", 5) + outfile.write("end if", 4) + outfile.write("end do", 3) + outfile.write("if(const_input_idx > 0) then", 3) outfile.write("call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found)", 4) outfile.write("if (diff_found) then", 4) outfile.write("overall_diff_found = .true.", 5) outfile.write("end if", 4) outfile.write("else", 3) outfile.comment("If not in standard names list, then attempt constituent name",4) - outfile.comment("and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names:",4) - # The , cnst_, pbuf_ prefix default fallbacks - # allows us to not enumerate all needed constituents from snapshots in the - # registry, yet allow reading their values from CAM snapshots. - outfile.write("call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found)", 4) + outfile.comment("and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names.",4) + outfile.comment("Standard names are case-insensitive (capgen lowercases them) but netCDF names are not,",4) + outfile.comment("so also try the all-upper and all-lower case spellings of the constituent name:",4) + # Try uppercase and lowercase variants for constituent names to match CAM + # e.g., O3, NO2, NUMLIQ (most species) ... num_a1, num_a2 (aerosols) + outfile.write("call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found)", 4) outfile.write("if (diff_found) then", 4) outfile.write("overall_diff_found = .true.", 5) outfile.write("end if", 4) diff --git a/src/physics/ncar_ccpp b/src/physics/ncar_ccpp index 979c6bca0..9865ef6a9 160000 --- a/src/physics/ncar_ccpp +++ b/src/physics/ncar_ccpp @@ -1 +1 @@ -Subproject commit 979c6bca02a4e4c76d94205c27831a7be66fb035 +Subproject commit 9865ef6a9384030233abe23e77acdc208abecdc3 diff --git a/src/physics/utils/physics_data.F90 b/src/physics/utils/physics_data.F90 index 67eb78919..2ae08c518 100644 --- a/src/physics/utils/physics_data.F90 +++ b/src/physics/utils/physics_data.F90 @@ -59,6 +59,7 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in use phys_vars_init_check, only: is_initialized use phys_vars_init_check, only: is_read_from_file use cam_constituents, only: const_get_index + use string_utils, only: to_lower ! Dummy arguments ! Variable standard name being checked: @@ -93,8 +94,10 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in !Loop through physics variable standard names: do idx = 1, phys_var_num - !Check if provided name is in required names array: - if (trim(phys_var_stdnames(idx)) == trim(stdname)) then + !Check if provided name is in required names array (standard names + !are case-insensitive: capgen normalizes scheme-side names to + !lowercase while registry declarations keep their authored case): + if (to_lower(trim(phys_var_stdnames(idx))) == to_lower(trim(stdname))) then found_in_phys_vars = .true. !Check if this variable has already been initialized. !If so, then set the index to a quantity that will be skipped: @@ -140,7 +143,7 @@ integer function find_input_name_idx(stdname, use_init_variables, constituent_in ! If not found, loop through the excluded variable standard names if (find_input_name_idx == no_exist_idx) then do idx = 1, phys_const_num - if (trim(phys_const_stdnames(idx)) == trim(stdname)) then + if (to_lower(trim(phys_const_stdnames(idx))) == to_lower(trim(stdname))) then ! Set to initialized because we can't check here. ! The relevant modules (e.g., cam_constituents) will check. find_input_name_idx = init_mark_idx @@ -461,6 +464,7 @@ subroutine read_constituent_dimensioned_field_2d(const_props, file, std_name, ba use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use phys_vars_init_check, only: mark_as_read_from_file use phys_vars_init_check, only: phys_var_stdnames, input_var_names, phys_var_num + use string_utils, only: to_lower ! Dummy arguments type(ccpp_constituent_prop_ptr_t), intent(in) :: const_props(:) ! Constituent properties @@ -525,7 +529,8 @@ subroutine read_constituent_dimensioned_field_2d(const_props, file, std_name, ba ! is the short name const_input_idx = -1 phys_inputvar_loop: do n = 1, phys_var_num - if (trim(phys_var_stdnames(n)) == trim(constituent_std_name)) then + ! case-insensitive: see find_input_name_idx + if (to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(constituent_std_name))) then const_input_idx = n exit phys_inputvar_loop end if @@ -550,12 +555,14 @@ subroutine read_constituent_dimensioned_field_2d(const_props, file, std_name, ba ! Get constituent short name constituent_name = constituent_short_names(const_idx) - ! Create file variable name: _ - file_var_name = trim(base_var_names(base_idx)) // '_' // trim(constituent_name) - - ! Try to find variable in file + ! Try to find variable in file: _, + ! trying case variants of the constituent name (see + ! constituent_dim_file_var_names). var_found = .false. - call cam_pio_find_var(file, [file_var_name], found_name, vardesc, var_found) + call cam_pio_find_var(file, & + constituent_dim_file_var_names(base_var_names(base_idx), & + constituent_name), & + found_name, vardesc, var_found) if(var_found) then exit base_idx_loop @@ -582,20 +589,26 @@ subroutine read_constituent_dimensioned_field_2d(const_props, file, std_name, ba ! Get constituent short name constituent_name = constituent_short_names(const_idx) - ! Create file variable name: _ + ! Create file variable name (used for reporting): _ file_var_name = trim(base_var_names(base_idx)) // '_' // trim(constituent_name) - ! Try to find variable in file + ! Try to find variable in file, trying case variants of the + ! constituent name (see constituent_dim_file_var_names). var_found = .false. - call cam_pio_find_var(file, [file_var_name], found_name, vardesc, var_found) + call cam_pio_find_var(file, & + constituent_dim_file_var_names(base_var_names(base_idx), & + constituent_name), & + found_name, vardesc, var_found) ! Some constituents whose names are not specified in the registry ! will have cnst_ prepended to them (e.g., cnst_dst_a1); also try reading ! from file by removing this prefix: if (.not. var_found) then if (constituent_name(1:5) == 'cnst_') then - file_var_name = trim(base_var_names(base_idx)) // '_' // trim(constituent_name(6:)) - call cam_pio_find_var(file, [file_var_name], found_name, vardesc, var_found) + call cam_pio_find_var(file, & + constituent_dim_file_var_names(base_var_names(base_idx), & + constituent_name(6:)), & + found_name, vardesc, var_found) end if end if @@ -661,6 +674,27 @@ subroutine read_constituent_dimensioned_field_2d(const_props, file, std_name, ba end subroutine read_constituent_dimensioned_field_2d + function constituent_dim_file_var_names(base_name, cname) result(var_names) + ! Build candidate file variable names '_' for a + ! constituent-dimensioned field. netCDF variable names are + ! case-sensitive, but a constituent name that is not enumerated in the + ! registry derives from its standard name, which is case-insensitive and + ! arrives lowercased from capgen (e.g. 'co2' for a field authored 'CO2'). + ! Try the constituent name as registered plus its all-upper and all-lower + ! spellings; the base name keeps its case. + use string_utils, only: to_upper, to_lower + use shr_kind_mod, only: cl => shr_kind_cl + + character(len=*), intent(in) :: base_name + character(len=*), intent(in) :: cname + character(len=cl) :: var_names(3) + + var_names(1) = trim(base_name) // '_' // trim(cname) + var_names(2) = trim(base_name) // '_' // trim(to_upper(cname)) + var_names(3) = trim(base_name) // '_' // trim(to_lower(cname)) + + end function constituent_dim_file_var_names + subroutine check_field_2d(file, var_names, timestep, current_value, & stdname, min_difference, min_relative_value, is_first, diff_found) use ccpp_kinds, only: kind_phys diff --git a/src/physics/utils/tropopause_climo_read.meta b/src/physics/utils/tropopause_climo_read.meta index e42cc9b04..cc06dac06 100644 --- a/src/physics/utils/tropopause_climo_read.meta +++ b/src/physics/utils/tropopause_climo_read.meta @@ -10,6 +10,7 @@ units = 1 type = integer dimensions = () + protected = True [ tropp_p_loc ] standard_name = tropopause_air_pressure_from_tropopause_climatology_dataset units = Pa diff --git a/test/unit/python/sample_files/namelist_files/kumquat_namelist.meta b/test/unit/python/sample_files/namelist_files/kumquat_namelist.meta index fdfe1b1bf..5127cc1d8 100644 --- a/test/unit/python/sample_files/namelist_files/kumquat_namelist.meta +++ b/test/unit/python/sample_files/namelist_files/kumquat_namelist.meta @@ -32,6 +32,7 @@ standard_name = kq_farr1_dimension type = integer | units = 1 dimensions = () + protected = True [ kq_farr1 ] standard_name = kumquat_fake_array1 type = real | kind = kind_phys @@ -42,10 +43,12 @@ standard_name = kq_fake2_dimension type = integer | units = 1 dimensions = () + protected = True [ kq_fake2_dimension_2 ] standard_name = kq_fake2_dimension_2 type = integer | units = 1 dimensions = () + protected = True [ kq_fake2 ] standard_name = kumquat_fake2d_array type = integer @@ -56,6 +59,7 @@ standard_name = kq_fchar3_dimension type = integer | units = 1 dimensions = () + protected = True [ kq_fchar3 ] standard_name = kumquat_fake_char_array type = character | kind = len=256 diff --git a/test/unit/python/sample_files/write_init_files/host_var_host.meta b/test/unit/python/sample_files/write_init_files/host_var_host.meta index 66745d6e2..d16811a07 100644 --- a/test/unit/python/sample_files/write_init_files/host_var_host.meta +++ b/test/unit/python/sample_files/write_init_files/host_var_host.meta @@ -4,6 +4,12 @@ [ccpp-arg-table] name = simple_sub type = host +[ pcols ] + standard_name = horizontal_dimension + type = integer + units = count + dimensions = () + protected = True [ col_start ] standard_name = horizontal_loop_begin type = integer diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_4D.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_4D.F90 index 32cd499a6..673873f65 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_4D.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_4D.F90 @@ -92,6 +92,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -100,7 +102,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -120,6 +122,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -132,7 +135,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -160,6 +163,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -174,7 +178,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -195,6 +199,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -212,7 +217,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -223,7 +228,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_bvd.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_bvd.F90 index f98f583fd..62bfc26b4 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_bvd.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_bvd.F90 @@ -32,19 +32,20 @@ module phys_vars_init_check_bvd integer, public, parameter :: PARAM = 2 integer, public, parameter :: READ_FROM_FILE = 3 ! Total number of physics-related variables: - integer, public, parameter :: phys_var_num = 2 + integer, public, parameter :: phys_var_num = 3 integer, public, parameter :: phys_const_num = 16 !Max length of physics-related variable standard names: integer, public, parameter :: std_name_len = 25 ! Max length of input (IC) file variable names: - integer, public, parameter :: ic_name_len = 5 + integer, public, parameter :: ic_name_len = 7 ! Physics-related input variable standard names: character(len=25), public, protected :: phys_var_stdnames(phys_var_num) = (/ & 'potential_temperature ', & - 'air_pressure_at_sea_level' /) + 'air_pressure_at_sea_level', & + 'band_number ' /) character(len=36), public, protected :: phys_const_stdnames(phys_const_num) = (/ & "ccpp_constituent_minimum_values ", & @@ -64,19 +65,22 @@ module phys_vars_init_check_bvd "suite_name ", & "suite_part " /) !Array storing all registered IC file input names for each variable: - character(len=5), public, protected :: input_var_names(1, phys_var_num) = reshape((/ & - 'theta', & - 'slp ' /), (/1, phys_var_num/)) + character(len=7), public, protected :: input_var_names(1, phys_var_num) = reshape((/ & + 'theta ', & + 'slp ', & + 'band_no' /), (/1, phys_var_num/)) ! Array indicating whether or not variable is protected: logical, public, protected :: protected_vars(phys_var_num)= (/ & .false., & - .false. /) + .false., & + .true. /) ! Variable state (UNINITIALIZED, INTIIALIZED, PARAM or READ_FROM_FILE): integer, public, protected :: initialized_vars(phys_var_num)= (/ & UNINITIALIZED, & - UNINITIALIZED /) + UNINITIALIZED, & + PARAM /) contains @@ -88,6 +92,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +102,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +122,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +135,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +163,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +178,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +199,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +217,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +228,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_cnst.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_cnst.F90 index a676c97df..a1a6cd590 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_cnst.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_cnst.F90 @@ -92,6 +92,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -100,7 +102,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -120,6 +122,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -132,7 +135,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -160,6 +163,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -174,7 +178,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -195,6 +199,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -212,7 +217,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -223,7 +228,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90 index 1e596ad0f..a1235d79c 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_constituent_dim.F90 @@ -96,6 +96,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -104,7 +106,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -124,6 +126,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -136,7 +139,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -164,6 +167,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -178,7 +182,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -199,6 +203,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -216,7 +221,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -227,7 +232,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt.F90 index b990acdbc..c35ac21dd 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt2.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt2.F90 index e6c206c66..e6c0628b4 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt2.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt2.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt_array.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt_array.F90 index aab144098..d2b1a473a 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt_array.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_ddt_array.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_host_var.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_host_var.F90 index 05002f296..255d0562c 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_host_var.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_host_var.F90 @@ -84,6 +84,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -92,7 +94,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -112,6 +114,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -124,7 +127,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -152,6 +155,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -166,7 +170,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -187,6 +191,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -204,7 +209,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -215,7 +220,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_initial_value.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_initial_value.F90 index 0a7c6dd2a..50dcdaedf 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_initial_value.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_initial_value.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_mf.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_mf.F90 index 440af04f5..4add92b17 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_mf.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_mf.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_no_horiz.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_no_horiz.F90 index 3c46c5899..153860f01 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_no_horiz.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_no_horiz.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_noreq.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_noreq.F90 index b6f7c5bef..815f7c6f3 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_noreq.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_noreq.F90 @@ -80,6 +80,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -88,7 +90,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -108,6 +110,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -120,7 +123,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -148,6 +151,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -162,7 +166,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -183,6 +187,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -200,7 +205,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -211,7 +216,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_param.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_param.F90 index 5633bc144..aea1802d0 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_param.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_param.F90 @@ -92,6 +92,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -100,7 +102,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -120,6 +122,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -132,7 +135,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -160,6 +163,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -174,7 +178,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -195,6 +199,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -212,7 +217,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -223,7 +228,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_protect.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_protect.F90 index 2592cb916..fd867643b 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_protect.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_protect.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_scalar.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_scalar.F90 index dd29c2b5f..9c52f6078 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_scalar.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_scalar.F90 @@ -88,6 +88,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -96,7 +98,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -116,6 +118,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -128,7 +131,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -156,6 +159,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -170,7 +174,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -191,6 +195,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -208,7 +213,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -219,7 +224,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_simple.F90 b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_simple.F90 index 74cfb9860..f37f228ce 100644 --- a/test/unit/python/sample_files/write_init_files/phys_vars_init_check_simple.F90 +++ b/test/unit/python/sample_files/write_init_files/phys_vars_init_check_simple.F90 @@ -96,6 +96,8 @@ subroutine mark_as_initialized(varname) ! which means any initialization check should ! now return True. + use string_utils, only: to_lower + ! Dummy argument character(len=*), intent(in) :: varname !Variable name being marked @@ -104,7 +106,7 @@ subroutine mark_as_initialized(varname) ! Search for in the standard name array: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! Only set to INITIALIZED if state is UNINITIALIZED if (initialized_vars(stdnam_idx) < PARAM) then initialized_vars(stdnam_idx) = INITIALIZED @@ -124,6 +126,7 @@ subroutine mark_as_read_from_file(varname) ! initialized_vars array use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being marked @@ -136,7 +139,7 @@ subroutine mark_as_read_from_file(varname) found_var = .false. ! Set variable to READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then ! It is an error if the variable has already been set to PARAM if (initialized_vars(stdnam_idx) == PARAM) then call endrun("Variable '"//trim(varname)// & @@ -164,6 +167,7 @@ logical function is_initialized(varname) ! initialized according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy argument character(len=*), intent(in) :: varname ! Variable name being checked @@ -178,7 +182,7 @@ logical function is_initialized(varname) ! Check if variable is initialized (PARAM, INITIALIZED, or READ_FROM_FILE) do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_initialized = (initialized_vars(stdnam_idx) > UNINITIALIZED) found = .true. exit ! Exit loop once variable has been found and checked @@ -199,6 +203,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! file according to the 'initialized_vars' array. use cam_abortutils, only: endrun + use string_utils, only: to_lower ! Dummy arguments character(len=*), intent(in) :: varname ! Variable name being checked @@ -216,7 +221,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) ! Return .true. if the variable's status is READ_FROM_FILE: do stdnam_idx = 1, phys_var_num - if (trim(phys_var_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_var_stdnames(stdnam_idx))) == to_lower(trim(varname))) then is_read = (initialized_vars(stdnam_idx) == READ_FROM_FILE) ! Mark as found: found = .true. @@ -227,7 +232,7 @@ subroutine is_read_from_file(varname, is_read, stdnam_idx_out) if (.not. found) then ! Check to see if this is an internally-protected variable do stdnam_idx = 1, phys_const_num - if (trim(phys_const_stdnames(stdnam_idx)) == trim(varname)) then + if (to_lower(trim(phys_const_stdnames(stdnam_idx))) == to_lower(trim(varname))) then found = .true. exit ! Exit loop once variable has been found end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90 index 869575ca2..d92ff84b2 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_4D, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -184,25 +185,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -232,6 +239,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -361,14 +369,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -376,9 +386,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90 index dc8fda6d1..3137ab8a8 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90 @@ -36,10 +36,11 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_bvd, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog - use physics_types_bad_vertdim, only: slp, theta + use physics_types_bad_vertdim, only: band_no, slp, theta ! Dummy arguments type(file_desc_t), intent(inout) :: file @@ -151,6 +152,9 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia case ('air_pressure_at_sea_level') call endrun('Cannot read slp from file'//', slp has unsupported dimension, band_number (dimension 2).') + case ('band_number') + call endrun('Cannot read band_no from file'//', band_no has no horizontal dimension; band_no is a protected variable') + end select !read variables end select !special indices @@ -181,25 +185,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +239,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +369,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +386,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90 index 53d1169d6..c9d8c9c5a 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_cnst, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90 index 90c43f4ba..8e0c4375f 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_constituent_dim, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -189,25 +190,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -237,6 +244,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -366,14 +374,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -381,9 +391,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90 index 07c980311..b3d0ca072 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_ddt, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90 index 8201666f1..00aa313f8 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_ddt2, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90 index dfca01355..d22a8f186 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_ddt_array, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90 index 3517c215f..05cc31043 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_host_var, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -178,25 +179,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -226,6 +233,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -350,14 +358,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -365,9 +375,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90 index 0670e5657..8b7cf12f8 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_initial_value, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90 index e09849edc..0b0af8bd1 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_mf, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -182,25 +183,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -230,6 +237,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -359,14 +367,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -374,9 +384,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90 index 119e086ef..b993b3dba 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_no_horiz, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90 index 158f9be55..382c31292 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_noreq, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -174,25 +175,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -222,6 +229,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -346,14 +354,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -361,9 +371,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_param.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_param.F90 index 57aeac7d6..f9a7a1ab7 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_param.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_param.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_param, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -184,25 +185,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -232,6 +239,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -361,14 +369,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -376,9 +386,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90 index 363c3ce46..37c850108 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_protect, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90 index ccb1a2c1e..1b338728d 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_scalar, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -358,14 +366,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -373,9 +383,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if diff --git a/test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90 b/test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90 index bf46c963b..2f31c5483 100644 --- a/test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90 +++ b/test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90 @@ -36,6 +36,7 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia use physics_data, only: read_constituent_dimensioned_field use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use phys_vars_init_check_simple, only: phys_var_num, phys_var_stdnames, input_var_names, std_name_len, is_initialized use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t use cam_logfile, only: iulog @@ -181,25 +182,31 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia var_found = .false. ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == trim(std_name))) then + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then ! Don't read the variable in if it's already initialized if (is_initialized(std_name)) then cycle end if - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do call read_field(file, std_name, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), & mark_as_read=.false., error_on_not_found=.false., var_found=var_found) else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', & - timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., error_on_not_found=.false., var_found=var_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call read_field(file, std_name, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), & + to_upper(std_name), 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), & + 'cnst_'//trim(to_lower(std_name)), 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), & + mark_as_read=.false., error_on_not_found=.false., var_found=var_found) end if if(.not. var_found) then constituent_has_default = .false. @@ -229,6 +236,7 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, use cam_ccpp_cap, only: ccpp_physics_suite_variables, cam_constituents_array, cam_model_const_properties use cam_constituents, only: const_get_index use ccpp_kinds, only: kind_phys + use string_utils, only: to_lower, to_upper use cam_logfile, only: iulog use spmd_utils, only: masterproc use phys_vars_init_check, only: is_read_from_file @@ -365,14 +373,16 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, do constituent_idx = 1, size(const_props) ! Check if constituent standard name in registered SIMA standard names list: call const_props(constituent_idx)%standard_name(std_name) - if(any(phys_var_stdnames == std_name)) then - ! Find array index to extract correct input names: - do n=1, phys_var_num - if(trim(phys_var_stdnames(n)) == trim(std_name)) then - const_input_idx = n - exit - end if - end do + ! Find array index to extract correct input names + ! (case-insensitive: see find_input_name_idx): + const_input_idx = -1 + do n=1, phys_var_num + if(to_lower(trim(phys_var_stdnames(n))) == to_lower(trim(std_name))) then + const_input_idx = n + exit + end if + end do + if(const_input_idx > 0) then call check_field(file, input_var_names(:,const_input_idx), 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, & min_difference, min_relative_value, is_first, diff_found) if (diff_found) then @@ -380,9 +390,13 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference, end if else ! If not in standard names list, then attempt constituent name - ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names: - call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name)], 'lev', timestep, & - field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found) + ! and cnst_, pbuf_ prefixes used by CAM snapshots (advected, non-advected) as input names. + ! Standard names are case-insensitive (capgen lowercases them) but netCDF names are not, + ! so also try the all-upper and all-lower case spellings of the constituent name: + call check_field(file, [character(len=std_name_len+5) :: std_name, 'cnst_'//trim(std_name), 'pbuf_'//trim(std_name), to_upper(std_name), & + 'cnst_'//trim(to_upper(std_name)), 'pbuf_'//trim(to_upper(std_name)), to_lower(std_name), 'cnst_'//trim(to_lower(std_name)), & + 'pbuf_'//trim(to_lower(std_name))], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, & + min_relative_value, is_first, diff_found) if (diff_found) then overall_diff_found = .true. end if