ESCOMP / CMEPS

NUOPC Community Mediator for Earth Prediction Systems
https://escomp.github.io/CMEPS/
22 stars 78 forks source link

Merge of megan namelist item from CAM and CTSM is failing even though there are only whitespace differences #509

Open ekluzek opened 2 days ago

ekluzek commented 2 days ago

I have a case that's failing in the merge of the CAM and CTSM namelist for drv_flds_in in preview_namaelists even though the difference is only in whitespace. This is in cmeps1_0_20 the latest version right now...

Here is the error I'm getting:

Create namelist for component sesp
   Calling /glade/derecho/scratch/erik/cam6_4_032/cime/CIME/non_py/src/components/stub_comps_nuopc/sesp/cime_config/buildnml
  2024-10-01 16:01:49 cpl 
Create namelist for component drv
   Calling /glade/derecho/scratch/erik/cam6_4_032/components/cmeps/cime_config/buildnml
Writing nuopc_runconfig for components ['CPL', 'ATM', 'LND', 'ICE', 'OCN', 'ROF']
Key: megan_specifier, 
 Value 1: 'CH2O = formaldehyde', 'CO = carbon_monoxide', 
 Value 2: 'CH2O = formaldehyde','CO = carbon_monoxide'
ERROR: incompatible settings in drv_flds_in from 
 /glade/derecho/scratch/erik/cam6_4_032/cime/scripts/SMS_D_Ln9.f19_f19_mg17.FWma2000climo.derecho_intel.cam-outfrq9s_waccm_ma_mam4.20241001_150352_n6ytq4/Buildconf/camconf/drv_flds_in 
 and 
 /glade/derecho/scratch/erik/cam6_4_032/cime/scripts/SMS_D_Ln9.f19_f19_mg17.FWma2000climo.derecho_intel.cam-outfrq9s_waccm_ma_mam4.20241001_150352_n6ytq4/Buildconf/clmconf/drv_flds_in

How to replicate this case:

ekluzek commented 2 days ago

@jedwards4b @billsacks this is a potential fix that does get it to work. But, I'm not sure it's the right thing to do. It simply removes the space character from the comparison.

diff --git a/cime_config/buildnml b/cime_config/buildnml
index 44116d98..91cb4f41 100755
--- a/cime_config/buildnml
+++ b/cime_config/buildnml
@@ -605,7 +605,7 @@ def compare_drv_flds_in(first, second, infile1, infile2):
     ###############################################################################
     sharedKeys = set(first.keys()).intersection(second.keys())
     for key in sharedKeys:
-        if first[key] != second[key]:
+        if first[key].replace(" ", "") != second[key].replace(" ", ""):
             print(
                 "Key: {}, \n Value 1: {}, \n Value 2: {}".format(
                     key, first[key], second[key]
billsacks commented 1 day ago

I'm not very familiar with the details of this, but the diff you give looks reasonable to me.

jedwards4b commented 1 day ago

@ekluzek I'm not sure I like this - whitespace should already be removed in buildnml lines 534 and 535:

     name = name.strip()                                                                                                                                
     var = var.strip()      

Why is it needed again?

jedwards4b commented 1 day ago

I see it's needed because in this case the extra space is in the middle of the string. I think that your fix is fine.

jedwards4b commented 1 day ago

Please submit a PR with the change.