Skip to content

Commit 5ebdd28

Browse files
committed
Fix crash in physics_check_data when registry variable has initial_value but not read from file, but is modified (intent out) from physics scheme
This is a proposed fix for a corner case where a variable is introduced into the CAM registry that has an initial_value but never read from file, as well as having an intent(out) or intent(inout) from a physics scheme. Such a case might happen because a variable might only be set in a scheme's "init" phase, yet used for "run" phases, and thus necessitates its introduction into the registry to persist state across timesteps. However, because this variable needs to be set in the scheme's "init" phase (and thus has intent(out)) it triggers the physics data check routine. The physics_check_data select case uses the find_input_name_idx to retrieve the name_idx, which is then used to get the actual input name, via phys_var_stdnames(name_idx); however, if a variable is intent(out) yet never read from file, find_input_name_idx in physics_data.F90 returns init_mark_idx = -2, which is out of bounds for phys_var_stdnames, and yet not covered by the guard case statements in the select case in physics_check_data; this commit adds the guard case for init_mark_idx with a comment to denote the corner case's triggering conditions.
1 parent 77fa975 commit 5ebdd28

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/data/write_init_files.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,12 @@ def write_phys_check_subroutine(outfile, host_dict, host_vars, host_imports,
14151415
outfile.comment("If variable is a constituent, then do nothing. We'll handle these later", 6)
14161416
outfile.blank_line()
14171417

1418+
# Skip already initialized variables:
1419+
outfile.write("case (init_mark_idx)", 5)
1420+
outfile.blank_line()
1421+
outfile.comment("If variable only has an initial_value but not read from file, then do nothing, even if it is modified by the physics scheme. There is nothing we can check against.", 6)
1422+
outfile.blank_line()
1423+
14181424
# Generate error message if required variable isn't found:
14191425
outfile.write("case (no_exist_idx)", 5)
14201426
outfile.blank_line()

0 commit comments

Comments
 (0)