diff --git a/MAPL_Base/MAPL_Generic.F90 b/MAPL_Base/MAPL_Generic.F90 index 6d20bbdb53ea..78b093ea8fb0 100644 --- a/MAPL_Base/MAPL_Generic.F90 +++ b/MAPL_Base/MAPL_Generic.F90 @@ -105,6 +105,7 @@ module MAPL_GenericMod use ESMF use ESMFL_Mod + use ESMF_CFIOMod, only: ESMF_CFIOStrTemplate use MAPL_BaseMod use MAPL_IOMod use MAPL_ProfMod @@ -865,9 +866,12 @@ recursive subroutine MAPL_GenericInitialize ( GC, IMPORT, EXPORT, CLOCK, RC ) logical :: ChldGridValid integer :: reference_date integer :: reference_time - integer :: yyyymmdd + integer :: yyyymmdd, hhmmss integer :: year, month, day, hh, mm, ss character(len=ESMF_MAXSTR) :: gridTypeAttribute + character(len=ESMF_MAXSTR) :: tmp_label, FILEtpl + character(len=ESMF_MAXSTR) :: id_string + integer :: ens_id_width real(ESMF_KIND_R8) :: fixedLons, fixedLats type(ESMF_GridComp) :: GCCS ! this is needed as a workaround ! for recursive ESMF method within method @@ -1182,10 +1186,11 @@ recursive subroutine MAPL_GenericInitialize ( GC, IMPORT, EXPORT, CLOCK, RC ) VERIFY_(STATUS) ! get current time from clock and create a reference time with optonal override - call ESMF_TimeGet( currTime, YY = YEAR, MM = MONTH, DD = DAY, rc = STATUS ) + call ESMF_TimeGet( currTime, YY = YEAR, MM = MONTH, DD = DAY, H=HH, M=MM, S=SS, rc = STATUS ) VERIFY_(STATUS) yyyymmdd = year*10000 + month*100 + day + hhmmss = HH*10000 + MM*100 + SS ! Get Alarm reference date and time from resouce, it defaults to midnight of the current day call MAPL_GetResource (STATE, reference_date, label='REFERENCE_DATE:', & @@ -1332,6 +1337,10 @@ recursive subroutine MAPL_GenericInitialize ( GC, IMPORT, EXPORT, CLOCK, RC ) deallocate(R_FILETYPE, R_ALARM) endif + call MAPL_GetResource( STATE, ens_id_width, & + LABEL="ENS_ID_WIDTH:", default=0, & + RC=STATUS) + if (associated(STATE%RECORD)) then call MAPL_GetResource( STATE, FILENAME, & LABEL="IMPORT_CHECKPOINT_FILE:", & @@ -1342,11 +1351,24 @@ recursive subroutine MAPL_GenericInitialize ( GC, IMPORT, EXPORT, CLOCK, RC ) else STATE%RECORD%IMP_LEN = 0 end if - - call MAPL_GetResource( STATE, FILENAME, & - LABEL="INTERNAL_CHECKPOINT_FILE:", & - RC=STATUS) + + id_string="" + tmp_label = "INTERNAL_CHECKPOINT_FILE:" + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & + RC=STATUS) + if((STATUS /= ESMF_SUCCESS) .and. ens_id_width > 0) then + i = len(trim(COMP_NAME)) + id_string = COMP_NAME(i-ens_id_width+1:i) + tmp_label =COMP_NAME(1:i-ens_id_width)//"_"//trim(tmp_label) + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & + RC=STATUS) + endif + if(STATUS==ESMF_SUCCESS) then + ! if the filename is tempate + call ESMF_CFIOStrTemplate(FILENAME, trim(adjustl(FILEtpl)),'GRADS', xid = trim(id_string), nymd=yyyymmdd,nhms=hhmmss,stat=status) STATE%RECORD%INT_FNAME = FILENAME STATE%RECORD%INT_LEN = LEN_TRIM(FILENAME) else @@ -1491,10 +1513,23 @@ recursive subroutine MAPL_GenericInitialize ( GC, IMPORT, EXPORT, CLOCK, RC ) end if VERIFY_(STATUS) - call MAPL_GetResource( STATE , FILENAME, & - LABEL="INTERNAL_RESTART_FILE:", & + id_string = "" + tmp_label = "INTERNAL_RESTART_FILE:" + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & RC=STATUS) + if((STATUS /=ESMF_SUCCESS) .and. ens_id_width >0) then + i = len(trim(COMP_NAME)) + id_string = COMP_NAME(i-ens_id_width+1:i) + tmp_label =COMP_NAME(1:i-ens_id_width)//"_"//trim(tmp_label) + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & + RC=STATUS) + endif + if(STATUS==ESMF_SUCCESS) then + ! if the filename is tempate + call ESMF_CFIOStrTemplate(FILENAME, trim(adjustl(FILEtpl)),'GRADS', xid = trim(id_string), nymd=yyyymmdd,nhms=hhmmss,stat=status) call MAPL_GetResource( STATE , hdr, & default=0, & LABEL="INTERNAL_HEADER:", & @@ -1730,7 +1765,7 @@ recursive subroutine MAPL_GenericFinalize ( GC, IMPORT, EXPORT, CLOCK, RC ) character(len=ESMF_MAXSTR) :: CHILD_NAME character(len=ESMF_MAXSTR) :: RECFIN type (MAPL_MetaComp), pointer :: STATE - integer :: I + integer :: I,j logical :: final_checkpoint integer :: NC integer :: PHASE @@ -1738,7 +1773,12 @@ recursive subroutine MAPL_GenericFinalize ( GC, IMPORT, EXPORT, CLOCK, RC ) integer :: MAXPHASES type (MAPL_MetaPtr), allocatable :: CHLDMAPL(:) integer :: hdr - + integer :: yyyymmdd, hhmmss + integer :: year, month, day, hh, mm, ss + character(len=ESMF_MAXSTR) :: tmp_label, FILEtpl + character(len=ESMF_MAXSTR) :: id_string + integer :: ens_id_width + type(ESMF_Time) :: CurrTime !============================================================================= ! Begin... @@ -1806,8 +1846,35 @@ recursive subroutine MAPL_GenericFinalize ( GC, IMPORT, EXPORT, CLOCK, RC ) ! Checkpoint the internal state if required. !------------------------------------------ - call MAPL_GetResource( STATE, FILENAME, LABEL="INTERNAL_CHECKPOINT_FILE:", RC=STATUS ) + call ESMF_ClockGet (clock, currTime=currTime, rc=status) + VERIFY_(STATUS) + call ESMF_TimeGet( currTime, YY = YEAR, MM = MONTH, DD = DAY, H=HH, M=MM, S=SS, rc = STATUS ) + VERIFY_(STATUS) + + yyyymmdd = year*10000 + month*100 + day + hhmmss = HH*10000 + MM*100 + SS + + call MAPL_GetResource( STATE, ens_id_width, & + LABEL="ENS_ID_WIDTH:", default=0, & + RC=STATUS) + + id_string="" + tmp_label = "INTERNAL_CHECKPOINT_FILE:" + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & + RC=STATUS) + if((STATUS /= ESMF_SUCCESS) .and. ens_id_width>0) then + i = len(trim(COMP_NAME)) + id_string = COMP_NAME(i-ens_id_width+1:i) + tmp_label =COMP_NAME(1:i-ens_id_width)//"_"//trim(tmp_label) + call MAPL_GetResource( STATE , FILEtpl, & + LABEL=trim(tmp_label), & + RC=STATUS) + endif + if(STATUS==ESMF_SUCCESS) then + ! if the filename is tempate + call ESMF_CFIOStrTemplate(FILENAME, trim(adjustl(FILEtpl)),'GRADS', xid = trim(id_string), nymd=yyyymmdd,nhms=hhmmss,stat=status) call MAPL_GetResource( STATE, FILETYPE, LABEL="INTERNAL_CHECKPOINT_TYPE:", RC=STATUS ) if ( STATUS/=ESMF_SUCCESS .or. FILETYPE == "default" ) then call MAPL_GetResource( STATE, FILETYPE, LABEL="DEFAULT_CHECKPOINT_TYPE:", default='pnc4', RC=STATUS ) diff --git a/MAPL_Base/MAPL_HistoryGridComp.F90 b/MAPL_Base/MAPL_HistoryGridComp.F90 index b7570380d217..c87248bd127f 100644 --- a/MAPL_Base/MAPL_HistoryGridComp.F90 +++ b/MAPL_Base/MAPL_HistoryGridComp.F90 @@ -2810,6 +2810,7 @@ subroutine Run ( gc, import, export, clock, rc ) end if if( MAPL_AM_I_ROOT() ) then + if (index(list(n)%format,'flat') == 0 ) & write(6,'(1X,"Writing: ",i6," Slices (",i4," Nodes, ",i4," PartitionRoot) to File: ",a)') & list(n)%Slices,list(n)%Psize,list(n)%Root, & trim(MAPL_CFIOGetFilename(list(n)%MCFIO)) diff --git a/MAPL_Base/MAPL_LocStreamMod.F90 b/MAPL_Base/MAPL_LocStreamMod.F90 index 83f512660df3..626cae205b18 100644 --- a/MAPL_Base/MAPL_LocStreamMod.F90 +++ b/MAPL_Base/MAPL_LocStreamMod.F90 @@ -491,6 +491,14 @@ subroutine MAPL_LocStreamCreateFromFile(LocStream, LAYOUT, FILENAME, NAME, MASK, VERIFY_(STATUS) end do + ! adjust EASE grid index from tile file + do N=1,STREAM%N_GRIDS + if(index(STREAM%TILING(N)%NAME,'EASE') /=0 ) then + AVR(:,NumGlobalVars+1+NumLocalVars*(N-1)) = AVR(:,NumGlobalVars+1+NumLocalVars*(N-1))+1 + AVR(:,NumGlobalVars+2+NumLocalVars*(N-1)) = AVR(:,NumGlobalVars+2+NumLocalVars*(N-1))+1 + endif + enddo + call FREE_FILE(UNIT) ! Allocate msk for which tiles to include in the stream being created.