From 686e35d62dc9aeb72d21a15f0be62ff952ada65e Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 14 May 2026 12:30:18 -0400 Subject: [PATCH 1/2] To cherry-pick: fix constituent ic names length not being accounted for in array len calculation for write_init_files Assisted-by: claude-opus:4.6[1m] --- src/data/write_init_files.py | 7 +++++++ .../write_init_files/phys_vars_init_check_cnst.F90 | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/data/write_init_files.py b/src/data/write_init_files.py index 1c3fd9d6b..397751493 100644 --- a/src/data/write_init_files.py +++ b/src/data/write_init_files.py @@ -431,6 +431,13 @@ def write_ic_params(outfile, host_vars, ic_names, registry_constituents): ic_names[stdname] = [locname] # end if # end if + # Also check registry constituents for longer IC names + for const in registry_constituents: + if const in ic_names: + max_loclen = max(max_loclen, + max(len(x) for x in ic_names[const])) + # end if + # end for outfile.write(f"integer, public, parameter :: ic_name_len = {max_loclen}", 1) 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 f8cc25741..a676c97df 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 @@ -39,7 +39,7 @@ module phys_vars_init_check_cnst integer, public, parameter :: std_name_len = 25 ! Max length of input (IC) file variable names: - integer, public, parameter :: ic_name_len = 12 + integer, public, parameter :: ic_name_len = 13 ! Physics-related input variable standard names: character(len=25), public, protected :: phys_var_stdnames(phys_var_num) = (/ & @@ -65,10 +65,10 @@ module phys_vars_init_check_cnst "suite_name ", & "suite_part " /) !Array storing all registered IC file input names for each variable: - character(len=12), public, protected :: input_var_names(2, phys_var_num) = reshape((/ & - 'theta ', 'pot_temp ', & - 'slp ', 'sea_lev_pres', & - 'COOL_CAT ', 'cnst_COOL_CAT' /), (/2, phys_var_num/)) + character(len=13), public, protected :: input_var_names(2, phys_var_num) = reshape((/ & + 'theta ', 'pot_temp ', & + 'slp ', 'sea_lev_pres ', & + 'COOL_CAT ', 'cnst_COOL_CAT' /), (/2, phys_var_num/)) ! Array indicating whether or not variable is protected: logical, public, protected :: protected_vars(phys_var_num)= (/ & From ae9a26bf1c9daa4b48eb4df9066e1a7c681e2aee Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 18 May 2026 23:31:12 -0400 Subject: [PATCH 2/2] Update src/data/write_init_files.py Co-authored-by: Jesse Nusbaumer --- src/data/write_init_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/write_init_files.py b/src/data/write_init_files.py index 397751493..ea108babb 100644 --- a/src/data/write_init_files.py +++ b/src/data/write_init_files.py @@ -430,7 +430,7 @@ def write_ic_params(outfile, host_vars, ic_names, registry_constituents): # Add this variable to the ic_names dictionary ic_names[stdname] = [locname] # end if - # end if + # end for # Also check registry constituents for longer IC names for const in registry_constituents: if const in ic_names: