Skip to content

Use cnst_ and pbuf_ alternative ic names when reading constituents not in the registry; try no cnst_ names for constituent-dimensioned input fields - #438

Merged
jimmielin merged 13 commits into
ESCOMP:developmentfrom
jimmielin:hplin/registry_cnst_ic
Jul 6, 2026
Merged

Conversation

@jimmielin

@jimmielin jimmielin commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator

Tag name (required for release branches):
Originator(s): @jimmielin

Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number):

  • Try to add cnst_ and pbuf_ (prescribed fields from CAM) when reading input files for constituents when they are not in the registry; this is to avoid unnecessary entries in the registry for constituents if the sole purpose is to specify ic_file_input_names for them;
  • When reading constituent-dimensioned input fields (e.g., cam_in_cflx_<name>) from snapshot, try to use the name without the cnst_ prefix that SIMA adds, e.g., cam_in_cflx_num_a4 instead of just cam_in_cflx_cnst_num_a4 right now.

Describe any changes made to build system: N/A

Describe any changes made to the namelist: N/A

List any changes to the defaults for the input datasets (e.g. boundary datasets): N/A

List all files eliminated and why: N/A

List all files added and what they do: N/A

List all existing files that have been modified, and describe the changes:
(Helpful git command: git diff --name-status development...<your_branch_name>)

M       src/data/write_init_files.py
M       test/unit/python/sample_files/write_init_files/physics_inputs_4D.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_bvd.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_cnst.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_constituent_dim.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt2.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_ddt_array.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_host_var.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_initial_value.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_mf.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_no_horiz.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_noreq.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_param.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_protect.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_scalar.F90
M       test/unit/python/sample_files/write_init_files/physics_inputs_simple.F90
  - try cnst_ and pbuf_ prefix for constituent read

M       src/physics/utils/physics_data.F90 
  - try removing cnst_ for constituent-dimensioned input fields

M       src/data/registry.xml
  - the above changes allow us to remove "trivial" constituent input name entries
    from the registry.xml file.

If there are new failures (compared to the test/existing-test-failures.txt file),
have them OK'd by the gatekeeper, note them here, and add them to the file.
If there are baseline differences, include the test and the reason for the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima: All PASS

derecho/gnu/aux_sima: FADIAB pre-existing failure.

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:

CAM-SIMA date used for the baseline comparison tests if different than latest:

@jimmielin jimmielin self-assigned this Oct 23, 2025
@jimmielin jimmielin added the enhancement New feature or request label Oct 23, 2025
@jimmielin jimmielin changed the title Use cnst_ and pbuf_ alternative ic names when reading constituents not in the registry Use cnst_ and pbuf_ alternative ic names when reading constituents not in the registry; try no cnst_ names for constituent-dimensioned input fields Nov 24, 2025
@jimmielin
jimmielin marked this pull request as ready for review November 24, 2025 16:54
@jimmielin

Copy link
Copy Markdown
Collaborator Author

fcdba17 is a cherry-pick from ongoing work in UW PBL

@jimmielin

Copy link
Copy Markdown
Collaborator Author

Once #439 is merged we could try using this PR and then removing the extra entries in registry.xml could be possible

    <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>

if it works we could remove the new entries from #439 in this PR as well when this is merged (and passes all the tests)

@jimmielin
jimmielin requested a review from peverwhee January 6, 2026 15:41
@jimmielin
jimmielin temporarily deployed to CI-tests-on-CIRRUS June 29, 2026 20:48 — with GitHub Actions Inactive

@peverwhee peverwhee left a comment

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.

one small comment request, but nothing that holds up my approval!

Comment thread src/data/registry.xml
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?

@jimmielin

Copy link
Copy Markdown
Collaborator Author

The following example has been tested to work with ifx and nvfortran on Derecho. The example was written by claude-opus-4-8:

program test_typed_char_constructor
   !----------------------------------------------------------------------
   ! Minimal test of an F2003 typed array constructor for character
   ! arrays whose elements have differing lengths. The [type-spec :: ...]
   ! syntax forces all elements to be padded/truncated to len=std_name_len.
   !
   ! Build on Derecho:
   !   module load intel-oneapi   ! provides ifx
   !   ifx -o test_tc test_typed_char_constructor.f90
   !   ./test_tc
   !
   ! (Optionally also try the classic compiler for comparison:)
   !   module load intel          ! provides ifort
   !   ifort -o test_tc_ifort test_typed_char_constructor.f90
   !----------------------------------------------------------------------
   implicit none

   integer, parameter :: std_name_len = 64
   character(len=std_name_len) :: std_name
   character(len=std_name_len), allocatable :: names(:)
   integer :: i

   std_name = 'temperature'

   ! The construct under review: mixed-length elements unified to
   ! len=std_name_len via the type-spec.
   names = [character(len=std_name_len) :: std_name, &
            'cnst_'//trim(std_name),                 &
            'pbuf_'//trim(std_name)]

   write(*,'(a,i0)') 'Number of elements: ', size(names)
   write(*,'(a,i0)') 'Element length:     ', len(names)
   do i = 1, size(names)
      write(*,'(a,i0,3a)') 'names(', i, ') = "', trim(names(i)), '"'
   end do

   ! Sanity checks
   if (len(names) /= std_name_len) then
      write(*,'(a)') 'FAIL: element length /= std_name_len'
      stop 1
   end if
   if (size(names) /= 3) then
      write(*,'(a)') 'FAIL: wrong number of elements'
      stop 1
   end if
   if (trim(names(2)) /= 'cnst_temperature' .or. &
       trim(names(3)) /= 'pbuf_temperature') then
      write(*,'(a)') 'FAIL: concatenation/padding incorrect'
      stop 1
   end if

   write(*,'(a)') 'PASS'

end program test_typed_char_constructor

@jimmielin
jimmielin requested a review from nusbaume June 30, 2026 16:02

@nusbaume nusbaume left a comment

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.

Thanks @jimmielin! I had one request to increase the length of the declared strings to include the length of the prefixes, but otherwise this PR looks good to me (assuming @peverwhee's comment request is also included). Thanks again!

Comment thread src/data/write_init_files.py Outdated
Comment thread src/data/write_init_files.py Outdated
Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
@jimmielin
jimmielin temporarily deployed to CI-tests-on-CIRRUS July 6, 2026 15:15 — with GitHub Actions Inactive
@jimmielin
jimmielin merged commit 0d6d482 into ESCOMP:development Jul 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants