Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,12 @@
</variable>

<!-- Constituent Variables -->
<!-- These are only used to set possible IC file input names, as the constituents object handles allocation. -->
<!-- Note: the first IC file input name should correspond to the short name of the constituent used in CAM, in order to facilitate reading constituent-dimensioned input fields. -->
<!-- These are only used to set possible IC file input names,
as the constituents object handles allocation/registration. -->
<!-- Only constituents with standard names that differ from the ic_file_input_name
needs to be listed in the registry. -->
<!-- Note: the first IC file input name should correspond to the short name of the constituent used in CAM,
in order to facilitate reading constituent-dimensioned input fields. -->
<variable local_name="q"
standard_name="water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water"
units="kg kg-1" type="real" constituent="true">
Expand Down Expand Up @@ -641,36 +645,11 @@
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>Q cnst_Q</ic_file_input_names>
</variable>
<variable local_name="CO2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment to the top of the constituents section that says something about how only constituents with standard names that differ from the ic_file_input_name need to be listed in the registry?

standard_name="CO2"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>CO2 cnst_CO2</ic_file_input_names>
</variable>
<variable local_name="N2O"
standard_name="N2O"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>N2O cnst_N2O</ic_file_input_names>
</variable>
<variable local_name="CH4"
standard_name="CH4"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>CH4 cnst_CH4</ic_file_input_names>
</variable>
<variable local_name="CFC12"
standard_name="CFC12"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>CFC12 cnst_CFC12</ic_file_input_names>
</variable>
<variable local_name="CFC11"
standard_name="CFC11"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>CFC11STAR pbuf_CFC11STAR</ic_file_input_names>
</variable>
<variable local_name="O2"
standard_name="O2"
units="kg kg-1" type="real" constituent="true">
<ic_file_input_names>O2 pbuf_O2</ic_file_input_names>
</variable>
<variable local_name="O3"
standard_name="O3"
units="kg kg-1" type="real" constituent="true">
Expand Down
16 changes: 12 additions & 4 deletions src/data/write_init_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,12 @@ def write_phys_read_subroutine(outfile, host_dict, host_vars, host_imports,
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 just use constituent name as input file name:",4)
outfile.write("call read_field(file, std_name, [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("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 <std_name>, cnst_<std_name>, pbuf_<std_name> 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.write("end if", 3)
outfile.write("if(.not. var_found) then", 3)
outfile.write("constituent_has_default = .false.", 4)
Expand Down Expand Up @@ -1501,8 +1505,12 @@ def write_phys_check_subroutine(outfile, host_dict, host_vars, host_imports,
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 just use constituent name as input file name:",4)
outfile.write("call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, is_first, diff_found)", 4)
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 <std_name>, cnst_<std_name>, pbuf_<std_name> 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.write("if (diff_found) then", 4)
outfile.write("overall_diff_found = .true.", 5)
outfile.write("end if", 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -374,9 +375,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -371,9 +372,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -371,9 +372,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -379,9 +380,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -371,9 +372,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ subroutine physics_read_data(file, suite_names, timestep, read_initialized_varia
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 just use constituent name as input file name:
call read_field(file, std_name, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), mark_as_read=.false., &
error_on_not_found=.false., var_found=var_found)
! 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)
end if
if(.not. var_found) then
constituent_has_default = .false.
Expand Down Expand Up @@ -371,9 +372,10 @@ subroutine physics_check_data(file_name, suite_names, timestep, min_difference,
overall_diff_found = .true.
end if
else
! If not in standard names list, then just use constituent name as input file name:
call check_field(file, [std_name], 'lev', timestep, field_data_ptr(:,:,constituent_idx), std_name, min_difference, min_relative_value, &
is_first, diff_found)
! 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)
if (diff_found) then
overall_diff_found = .true.
end if
Expand Down
Loading
Loading