Skip to content

Commit

Permalink
make mct cap be able to read multiple restart files from rpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
alperaltuntas committed Aug 5, 2020
1 parent 829aade commit 648bb1c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions config_src/mct_driver/ocn_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
integer :: year, month, day, hour, minute, seconds, seconds_n, seconds_d, rc
character(len=240) :: runid !< Run ID
character(len=32) :: runtype !< Run type
character(len=240) :: restartfile !< Path/Name of restart file
character(len=512) :: restartfile !< Path/Name of restart file
character(len=2048) :: restartfiles !< Path/Name of restart files.
!! (same as restartfile if a single restart file is to be read in)
integer :: nu !< i/o unit to read pointer file
character(len=240) :: restart_pointer_file !< File name for restart pointer file
character(len=240) :: restartpath !< Path of the restart file
Expand Down Expand Up @@ -164,6 +166,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
!logical :: lsend_precip_fact !< If T,send precip_fact to cpl for use in fw balance
!! (partially-coupled option)
character(len=128) :: err_msg !< Error message
integer :: iostat

! set the cdata pointers:
call seq_cdata_setptrs(cdata_o, id=MOM_MCT_ID, mpicom=mpicom_ocn, &
Expand Down Expand Up @@ -296,15 +299,27 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
nu = shr_file_getUnit()
restart_pointer_file = trim(glb%pointer_filename)
if (is_root_pe()) write(glb%stdout,*) 'Reading ocn pointer file: ',restart_pointer_file
restartfile = ""; restartfiles = "";
open(nu, file=restart_pointer_file, form='formatted', status='unknown')
read(nu,'(a)') restartfile
do
read(nu,'(a)', iostat=iostat) restartfile
if (len(trim(restartfiles))>1 .and. iostat<0) then
exit ! done reading restart files list.
else if (iostat/=0) then
call MOM_error(FATAL, 'Error reading rpointer.ocn')
endif
! check if the length of restartfiles variable is sufficient:
if (len(restartfiles)-len(trim(restartfiles)) < len(trim(restartfile))) then
call MOM_error(FATAL, "Restart file name(s) too long.")
endif
restartfiles = trim(restartfiles) // " " // trim(restartfile)
enddo
close(nu)
!restartfile = trim(restartpath) // trim(restartfile)
if (is_root_pe()) then
write(glb%stdout,*) 'Reading restart file: ',trim(restartfile)
write(glb%stdout,*) 'Reading restart file(s): ',trim(restartfiles)
end if
call shr_file_freeUnit(nu)
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfile))
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfiles))
endif
if (is_root_pe()) then
write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
Expand Down

0 comments on commit 648bb1c

Please sign in to comment.