From faf5d1cee5daf610aa314594b4766ad213a77f9d Mon Sep 17 00:00:00 2001 From: Denise Worthen Date: Mon, 27 Jul 2020 15:12:22 -0400 Subject: [PATCH 1/2] cice6 compile (#71) (#34) * update cice6 component mk * update path for forapps/ufs * update paths to MOM6 and CICE interfaces (#33) Co-authored-by: Rahul Mahajan Co-authored-by: Rahul Mahajan --- src/incmake/component_CICE6.mk | 7 ++++--- src/incmake/component_MOM6.mk | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/incmake/component_CICE6.mk b/src/incmake/component_CICE6.mk index 7bf26c86..7e1b1d36 100644 --- a/src/incmake/component_CICE6.mk +++ b/src/incmake/component_CICE6.mk @@ -3,9 +3,9 @@ cice6_mk=$(CICE_BINDIR)/cice6.mk all_component_mk_files+=$(cice6_mk) # Location of source code and installation -CICE_SRCDIR?=$(ROOTDIR)/CICE6 -CICE_UFSDIR?=$(ROOTDIR)/CICE6/forapps/ufs -CICE_BINDIR?=$(ROOTDIR)/CICE6_INSTALL +CICE_SRCDIR?=$(ROOTDIR)/CICE-interface/CICE +CICE_UFSDIR?=$(ROOTDIR)/CICE-interface/CICE/configuration/scripts/forapps/ufs +CICE_BINDIR?=$(ROOTDIR)/CICE-interface/CICE_INSTALL # NEMS_GRID was found in CICE and defaults to a low-res GSM grid # This is obsolete and perhaps should be removed. @@ -49,6 +49,7 @@ build_CICE6: $(cice6_mk) # Rules for cleaning the SRCDIR and BINDIR: clean_CICE6_SRC: configure + cp -n $(MODULE_DIR)/$(CHOSEN_MODULE) $(CONFDIR)/modules.nems ; \ $(MODULE_LOGIC) ; \ set -eu ; \ export $(CICE_ALL_OPTS) $(CICE_MAKEOPT) ; \ diff --git a/src/incmake/component_MOM6.mk b/src/incmake/component_MOM6.mk index 0b03dee4..cf733335 100644 --- a/src/incmake/component_MOM6.mk +++ b/src/incmake/component_MOM6.mk @@ -3,8 +3,8 @@ mom6_mk = $(MOM6_BINDIR)/mom6.mk all_component_mk_files+=$(mom6_mk) # Location of source code and installation -MOM6_SRCDIR?=$(ROOTDIR)/MOM6 -MOM6_BINDIR?=$(ROOTDIR)/MOM6/MOM6_INSTALL +MOM6_SRCDIR?=$(ROOTDIR)/MOM6-interface +MOM6_BINDIR?=$(ROOTDIR)/MOM6-interface/MOM6_INSTALL # Make sure the expected directories exist and are non-empty: $(call require_dir,$(MOM6_SRCDIR),MOM6 source directory) From bfcc5e4c95a28b0692c320d81d31c62b1a0aa9c6 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Thu, 14 Oct 2021 16:03:19 -0400 Subject: [PATCH 2/2] create clean cleanup branch --- src/module_EARTH_GRID_COMP.F90 | 165 +++++++++++---------------------- 1 file changed, 53 insertions(+), 112 deletions(-) diff --git a/src/module_EARTH_GRID_COMP.F90 b/src/module_EARTH_GRID_COMP.F90 index ffc38d12..21148861 100644 --- a/src/module_EARTH_GRID_COMP.F90 +++ b/src/module_EARTH_GRID_COMP.F90 @@ -220,9 +220,7 @@ END SUBROUTINE EARTH_REGISTER ! subroutine SetModelServices(driver, rc) -#ifdef CMEPS - use med_internalstate_mod , only : med_id -#endif + type(ESMF_GridComp) :: driver integer, intent(out) :: rc @@ -241,11 +239,7 @@ subroutine SetModelServices(driver, rc) type(NUOPC_FreeFormat) :: attrFF, fdFF logical :: found_comp logical :: isPresent -#ifdef CMEPS - logical :: read_restart - character(ESMF_MAXSTR) :: cvalue - character(len=5) :: inst_suffix -#endif + rc = ESMF_SUCCESS ! query the Component for info @@ -297,15 +291,16 @@ subroutine SetModelServices(driver, rc) call ESMF_ConfigGetAttribute(config, valueList=compLabels, & label="EARTH_component_list:", count=componentCount, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return -#ifdef CMEPS - inst_suffix = "" - ! obtain driver attributes (for CMEPS) - call ReadAttributes(driver, config, "DRIVER_attributes::", formatprint=printattr, rc=rc) + call ReadAttributes(driver, config, "DRIVER_attributes::", relaxedflag=.true., & + formatprint=printattr, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ReadAttributes(driver, config, "ALLCOMP_attributes::", formatprint=printattr, rc=rc) + call ReadAttributes(driver, config, "ALLCOMP_attributes::", relaxedflag=.true., & + formatprint=printattr, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! get starttype and set read_restart attribute in driver config list + call InitRestart(driver, config, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return -#endif ! determine information for each component and add to the driver do i=1, componentCount @@ -431,7 +426,6 @@ subroutine SetModelServices(driver, rc) #endif #ifdef FRONT_CMEPS if (trim(model) == "cmeps") then - med_id = i+1 call NUOPC_DriverAddComp(driver, trim(prefix), MED_SS, & petList=petList, comp=comp, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -445,39 +439,11 @@ subroutine SetModelServices(driver, rc) return endif - ! read and ingest free format component attributes - attrFF = NUOPC_FreeFormatCreate(config, & - label=trim(prefix)//"_attributes::", relaxedflag=.true., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeIngest(comp, attrFF, addFlag=.true., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_FreeFormatDestroy(attrFF, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_ConfigFindNextLabel(config, & - label=trim(prefix)//"_modelio::", isPresent=isPresent, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (isPresent) then - attrFF = NUOPC_FreeFormatCreate(config, & - label=trim(prefix)//"_modelio::", relaxedflag=.true., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeIngest(comp, attrFF, addFlag=.true., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_FreeFormatDestroy(attrFF, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - endif + call AddAttributes(comp, driver, config, trim(prefix), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return ! clean-up deallocate(petList) - -#ifdef CMEPS - ! Perform restarts if appropriate - call InitRestart(driver, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call AddAttributes(comp, driver, config, i+1, trim(prefix), inst_suffix, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return -#endif enddo ! clean-up @@ -586,7 +552,6 @@ recursive subroutine ModifyCplLists(driver, importState, exportState, clock, & !----------------------------------------------------------------------------- -#ifdef CMEPS subroutine ReadAttributes(gcomp, config, label, relaxedflag, formatprint, rc) use ESMF , only : ESMF_GridComp, ESMF_Config, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS @@ -631,7 +596,7 @@ subroutine ReadAttributes(gcomp, config, label, relaxedflag, formatprint, rc) end subroutine ReadAttributes - subroutine InitRestart(driver, rc) + subroutine InitRestart(driver, config, rc) !----------------------------------------------------- ! Determine if will restart and read pointer file if appropriate @@ -643,12 +608,13 @@ subroutine InitRestart(driver, rc) ! input/output variables type(ESMF_GridComp) , intent(inout) :: driver + type(ESMF_Config) , intent(inout) :: config integer , intent(out) :: rc ! local variables logical :: read_restart ! read the restart file, based on start_type character(len=ESMF_MAXSTR) :: cvalue ! temporary - character(len=ESMF_MAXSTR) :: rest_case_name ! Short case identification + character(len=ESMF_MAXSTR) :: attribute ! character(len=*) , parameter :: subname = "(module_EARTH_GRID_COMP.F90:InitRestart)" !------------------------------------------- @@ -659,24 +625,22 @@ subroutine InitRestart(driver, rc) ! Carry out restart if appropriate !----------------------------------------------------- - read_restart = IsRestart(driver, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Add rest_case_name and read_restart to driver attributes - call NUOPC_CompAttributeAdd(driver, attrList=(/'rest_case_name','read_restart '/), rc=rc) + read_restart = IsRestart(driver, config, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - rest_case_name = ' ' - call NUOPC_CompAttributeSet(driver, name='rest_case_name', value=rest_case_name, rc=rc) + attribute = 'read_restart' + ! Add read_restart to driver attributes + call NUOPC_CompAttributeAdd(driver, attrList=(/trim(attribute)/), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return write(cvalue,*) read_restart call NUOPC_CompAttributeSet(driver, name='read_restart', value=trim(cvalue), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite('Set attribute read_restart in driver ', ESMF_LOGMSG_INFO) end subroutine InitRestart - function IsRestart(gcomp, rc) + function IsRestart(gcomp, config, rc) use ESMF , only : ESMF_GridComp, ESMF_SUCCESS use ESMF , only : ESMF_LogSetError, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_RC_NOT_VALID @@ -685,9 +649,11 @@ function IsRestart(gcomp, rc) ! input/output variables logical :: IsRestart type(ESMF_GridComp) , intent(inout) :: gcomp + type(ESMF_Config) , intent(inout) :: config integer , intent(out) :: rc ! locals + logical :: isPresent, isSet character(len=ESMF_MAXSTR) :: start_type ! Type of startup character(len=ESMF_MAXSTR) :: msgstr character(len=*) , parameter :: start_type_start = "startup" @@ -699,26 +665,32 @@ function IsRestart(gcomp, rc) rc = ESMF_SUCCESS ! First Determine if restart is read - call NUOPC_CompAttributeGet(gcomp, name='start_type', value=start_type, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name='start_type', value=start_type, & + isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if ((trim(start_type) /= start_type_start) .and. & - (trim(start_type) /= start_type_cont ) .and. & - (trim(start_type) /= start_type_brnch)) then - write (msgstr, *) subname//': start_type invalid = '//trim(start_type) - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc) - return - end if + if( isPresent .and. isSet) then + if ((trim(start_type) /= start_type_start) .and. & + (trim(start_type) /= start_type_cont ) .and. & + (trim(start_type) /= start_type_brnch)) then + write (msgstr, *) subname//': start_type invalid = '//trim(start_type) + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc) + return + end if - !TODO: this is hard-wired to CIME start/continue types in terms of gcomp - IsRestart = .false. - if (trim(start_type) == trim(start_type_cont) .or. trim(start_type) == trim(start_type_brnch)) then - IsRestart = .true. - end if + !TODO: this is hard-wired to CIME start/continue types in terms of gcomp + IsRestart = .false. + if (trim(start_type) == trim(start_type_cont) .or. trim(start_type) == trim(start_type_brnch)) then + IsRestart = .true. + end if + else + IsRestart = .false. + call ESMF_LogWrite('No start_type attribute found, setting read_restart false ', ESMF_LOGMSG_INFO) + endif end function IsRestart - subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, rc) + subroutine AddAttributes(gcomp, driver, config, compname, rc) ! Add specific set of attributes to components from driver attributes @@ -730,9 +702,7 @@ subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, r type(ESMF_GridComp) , intent(inout) :: gcomp type(ESMF_GridComp) , intent(in) :: driver type(ESMF_Config) , intent(inout) :: config - integer , intent(in) :: compid character(len=*) , intent(in) :: compname - character(len=*) , intent(in) :: inst_suffix integer , intent(inout) :: rc ! local variables @@ -752,20 +722,8 @@ subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, r call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) !------ - ! Add compid to gcomp attributes + ! Add restart flag to gcomp attributes !------ - !write(cvalue,*) compid - !call NUOPC_CompAttributeAdd(gcomp, attrList=(/'MCTID'/), rc=rc) - !if (chkerr(rc,__LINE__,u_FILE_u)) return - !call NUOPC_CompAttributeSet(gcomp, name='MCTID', value=trim(cvalue), rc=rc) - !if (chkerr(rc,__LINE__,u_FILE_u)) return - - !------ - ! Add all the other attributes in AttrList (which have already been added to driver attributes) - !------ - !allocate(attrList(5)) - !attrList = (/"read_restart", "orb_eccen ", "orb_obliqr ", "orb_lambm0 ", "orb_mvelpp "/) - ! TODO: orb_obliqr and orb_lambm0 not exist allocate(attrList(1)) attrList = (/"read_restart"/) @@ -774,61 +732,44 @@ subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, r do n = 1,size(attrList) if (trim(attrList(n)) == "read_restart") then - call NUOPC_CompAttributeGet(driver, name="mediator_read_restart", value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(driver, name="read_restart", value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) lvalue if (.not. lvalue) then call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - print*, trim(attrList(n)) + print *, trim(attrList(n)) call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if + call ESMF_LogWrite('Added attribute '//trim(attrList(n))//' to '//trim(compname), ESMF_LOGMSG_INFO) enddo deallocate(attrList) !------ ! Add component specific attributes !------ - call ReadAttributes(gcomp, config, trim(compname)//"_attributes::", formatprint=printattr, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ReadAttributes(gcomp, config, "ALLCOMP_attributes::", formatprint=printattr, rc=rc) + call ReadAttributes(gcomp, config, trim(compname)//"_attributes::", relaxedflag=.true., & + formatprint=printattr, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !------ - ! Add multi-instance specific attributes - !------ - call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_index'/), rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ReadAttributes(gcomp, config, trim(compname)//"_modelio::", relaxedflag=.true., & + formatprint=printattr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return - ! add inst_index attribute (inst_index is not required for cime internal components) - ! for now hard-wire inst_index to 1 - inst_index = 1 - write(cvalue,*) inst_index - call NUOPC_CompAttributeSet(gcomp, name='inst_index', value=trim(cvalue), rc=rc) + call ReadAttributes(gcomp, config, "ALLCOMP_attributes::", relaxedflag=.true., & + formatprint=printattr, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! add inst_suffix attribute - if (len_trim(inst_suffix) > 0) then - call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_suffix'/), rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call NUOPC_CompAttributeSet(gcomp, name='inst_suffix', value=inst_suffix, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - end if - end subroutine AddAttributes -#endif ! !----------------------------------------------------------------------- !