Skip to content

Commit

Permalink
add timestamp to rpointer files
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Sep 12, 2024
1 parent e707519 commit 4dcd4b4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/main/restFileMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ subroutine restFile_read_pfile( pnamer )
! !USES:
use fileutils , only : opnfil, getavu, relavu
use clm_varctl, only : rpntfil, rpntdir, inst_suffix
use clm_time_manager, only: get_prev_date
!
! !ARGUMENTS:
character(len=*), intent(out) :: pnamer ! full path of restart file
Expand All @@ -349,7 +350,10 @@ subroutine restFile_read_pfile( pnamer )
integer :: i ! indices
integer :: nio ! restart unit
integer :: status ! substring check status
integer :: yr, mon, day, tod ! time values
logical :: found ! check if file exists
character(len=256) :: locfn ! Restart pointer file name
character(len=16) :: timestamp ! Timestamp for restart pointer file
!-----------------------------------------------------------------------

! Obtain the restart file from the restart pointer file.
Expand All @@ -363,7 +367,20 @@ subroutine restFile_read_pfile( pnamer )
endif

nio = getavu()
locfn = trim(rpntdir) //'/'// trim(rpntfil)//trim(inst_suffix)
call get_prev_date(yr, mon, day, tod)
write(timestamp,'(".",i4.4,"-",i2.2,"-",i2.2,"-",i5.5)'),yr,mon,day,tod
locfn = trim(rpntdir) //'/'// trim(rpntfil)//trim(inst_suffix)//timestamp
inquire(file=locfn, exist=found)
if(.not.found) then
if(masterproc) then
write(iulog,*) 'Warning: rpointer file '//trim(locfn)//' not found.'
endif
locfn = trim(rpntdir) //'/'// trim(rpntfil)//trim(inst_suffix)
inquire(file=locfn, exist=found)
if(.not.found) then
call endrun(msg='rpointer file '//trim(locfn)//' not found '//errMsg(sourcefile, __LINE__))
endif
endif
call opnfil (locfn, nio, 'f')
read (nio,'(a256)') pnamer
call relavu (nio)
Expand Down Expand Up @@ -415,24 +432,31 @@ subroutine restFile_write_pfile( fnamer )
use clm_varctl, only : rpntdir, rpntfil, inst_suffix
use fileutils , only : relavu
use fileutils , only : getavu, opnfil
use clm_time_manager, only: get_curr_date

!
! !ARGUMENTS:
character(len=*), intent(in) :: fnamer
!
! !LOCAL VARIABLES:
integer :: m ! index
integer :: nio ! restart pointer file
integer :: yr, mon, day, tod
character(len=16) :: timestamp
character(len=256) :: filename ! local file name
!-----------------------------------------------------------------------

if (masterproc) then
call get_curr_date(yr, mon, day, tod)
write(timestamp,'(".",i4.4,"-",i2.2,"-",i2.2,"-",i5.5)'),yr,mon,day,tod

nio = getavu()
filename= trim(rpntdir) //'/'// trim(rpntfil)//trim(inst_suffix)
filename= trim(rpntdir) //'/'// trim(rpntfil)//trim(inst_suffix)//timestamp
call opnfil( filename, nio, 'f' )

write(nio,'(a)') fnamer
call relavu( nio )
write(iulog,'(a)')'Successfully wrote local restart pointer file'
write(iulog,'(a)')'Successfully wrote local restart pointer file: '//trim(filename)
end if

end subroutine restFile_write_pfile
Expand Down

0 comments on commit 4dcd4b4

Please sign in to comment.