Repository: ESMCI/cime

Issue:
mct interface defined twice
From tony craig:

There is an mct interface defined in share/csm_share/shr/mct_mod.F90 twice,

   use m_GlobalSegMap       ,only: mct_gsMap_OP           => OrderedPoints
   use m_GlobalSegMap       ,only: mct_gsMap_orderedPoints=> OrderedPoints

The mct_gsmap_orderedpoints is used throughout CESM.  The mct_gsmap_op
is used only in clm (which also uses mct_gsmap_orderedpoints by the way).

I suggest we modify the calls to mct_gsmap_op to mct_gsmap_orderedpoints
in clm and then delete that interface in mct_mod.F90.

I am using cesm15.beta06 right now, but assume it's still the case in the latest
version.  I see the string in the following places,

components/clm/src_clm40/main/GetGlobalValuesMod.F90:    call mct_gsmap_op(gsmap, iam, gsmap_ordered)
components/clm/src_clm40/main/ncdio_pio.F90.in:  use mct_mod , only : mct_gsMap, mct_gsMap_lsize, mct_gsMap_gsize, mct_gsMap_OP
components/clm/src_clm40/main/ncdio_pio.F90.in:    call mct_gsmap_OP(gsmap,iam,gsmOP)
components/clm/src/main/GetGlobalValuesMod.F90:    call mct_gsmap_op(gsmap, iam, gsmap_ordered)
components/clm/src/main/ncdio_pio.F90.in:  use mct_mod        , only : mct_gsMap, mct_gsMap_lsize, mct_gsMap_gsize, mct_gsMap_OP
components/clm/src/main/ncdio_pio.F90.in:    call mct_gsmap_OP(gsmap,iam,gsmOP)
components/clm/src/ED/main/EDRestVectorMod.F90:    use mct_mod, only : mct_gsMap, mct_gsmap_OP
components/clm/src/ED/main/EDRestVectorMod.F90:    call mct_gsmap_OP(gsmap, iam, gsmOP)
components/clm/src/unit_test_stubs/csm_share/mct_mod_stub.F90: public :: mct_gsMap_OP
components/clm/src/unit_test_stubs/csm_share/mct_mod_stub.F90: subroutine mct_gsMap_OP(GSMap, PEno, Points)
components/clm/src/unit_test_stubs/csm_share/mct_mod_stub.F90:    ! Stub routine that simply matches the signature of mct_gsMap_OP
components/clm/src/unit_test_stubs/csm_share/mct_mod_stub.F90:  end subroutine mct_gsMap_OP



Discussion:
I think that the clm model first needs to be updated to remove the  mct_gsmap_op and replace it with mct_gsMap_orderedPoints and then the extra definition can be removed from share/csm_share/shr/mct_mod.F90

The CLM bug report on this is...

http://bugz.cgd.ucar.edu/show_bug.cgi?id=2440
clm4_5_15_r233 fixes the issues for CLM, so cime should now be able to make this update.

Resolving patch:
diff --git a/scripts/lib/CIME/preview_namelists.py b/scripts/lib/CIME/preview_namelists.py
--- a/scripts/lib/CIME/preview_namelists.py
+++ b/scripts/lib/CIME/preview_namelists.py
@@ -75,12 +75,14 @@ def create_namelists(case):
 
         cmd = os.path.join(config_dir, "buildnml")
         do_run_cmd = False
+        # This code will try to import and run each buildnml as a subroutine
+        # if that fails it will run it as a program in a seperate shell
         try:
             with open(cmd, 'r') as f:
                 first_line = f.readline()
             if "python" in first_line:
-                logger.info("   Calling %s buildnml"%compname)
                 mod = imp.load_source("buildnml", cmd)
+                logger.info("   Calling %s buildnml"%compname)
                 mod.buildnml(case, caseroot, compname)
             else:
                 raise SyntaxError


Test patch: