diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 9bf0cc59a2..6e80869833 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -174,7 +174,7 @@ subroutine initialize2(ni,nj) use SatellitePhenologyMod , only : SatellitePhenologyInit, readAnnualVegetation, interpMonthlyVeg, SatellitePhenology use SnowSnicarMod , only : SnowAge_init, SnowOptics_init use lnd2atmMod , only : lnd2atm_minimal - use controlMod , only : NLFilename + use controlMod , only : NLFilename, check_missing_initdata_status use clm_instMod , only : clm_fates use BalanceCheckMod , only : BalanceCheckInit use CNSharedParamsMod , only : CNParamsSetSoilDepth @@ -520,17 +520,7 @@ subroutine initialize2(ni,nj) else if (trim(finidat) == trim(finidat_interp_dest)) then ! Check to see if status file for finidat exists - klen = len_trim(finidat_interp_dest) - 3 ! remove the .nc - locfn = finidat_interp_dest(1:klen)//'.status' - inquire(file=trim(locfn), exist=lexists) - if (.not. lexists) then - if (masterproc) then - write(iulog,'(a)')' failed to find file '//trim(locfn) - write(iulog,'(a)')' this indicates a problem in creating '//trim(finidat_interp_dest) - write(iulog,'(a)')' remove '//trim(finidat_interp_dest)//' and try again' - end if - call endrun() - end if + call check_missing_initdata_status(finidat_interp_dest) end if if (masterproc) then write(iulog,'(a)')'Reading initial conditions from file '//trim(finidat) diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index f876e97176..1af68b0af6 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -59,6 +59,7 @@ module controlMod public :: control_setNL ! Set namelist filename public :: control_init ! initial run control information public :: control_print ! print run control information + public :: check_missing_initdata_status ! check for missing finidat_interp_dest .status file ! ! ! !PRIVATE MEMBER FUNCTIONS: @@ -1221,6 +1222,38 @@ subroutine control_print () end subroutine control_print + !----------------------------------------------------------------------- + subroutine check_missing_initdata_status(finidat_interp_dest) + ! + ! !DESCRIPTION: + ! Checks that the finidat_interp_dest .status file was written (i.e., that write of + ! finidat_interp_dest succeeded) + ! + ! !ARGUMENTS: + character(len=*), intent(in) :: finidat_interp_dest + ! + ! !LOCAL VARIABLES: + logical :: lexists + integer :: klen + character(len=SHR_KIND_CL) :: status_file + character(len=*), parameter :: subname = 'check_missing_initdata_status' + !----------------------------------------------------------------------- + + klen = len_trim(finidat_interp_dest) - 3 ! remove the .nc + status_file = finidat_interp_dest(1:klen)//'.status' + inquire(file=trim(status_file), exist=lexists) + if (.not. lexists) then + if (masterproc) then + write(iulog,'(a)')' failed to find file '//trim(status_file) + write(iulog,'(a)')' this indicates a problem in creating '//trim(finidat_interp_dest) + write(iulog,'(a)')' remove '//trim(finidat_interp_dest)//' and try again' + end if + call endrun(subname//': finidat_interp_dest file exists but is probably bad') + end if + + end subroutine check_missing_initdata_status + + !----------------------------------------------------------------------- subroutine apply_use_init_interp(finidat_interp_dest, finidat, finidat_interp_source) ! @@ -1271,6 +1304,10 @@ subroutine apply_use_init_interp(finidat_interp_dest, finidat, finidat_interp_so inquire(file=trim(finidat_interp_dest), exist=lexists) if (lexists) then + + ! Check that the status file also exists (i.e., that finidat_interp_dest was written successfully) + call check_missing_initdata_status(finidat_interp_dest) + ! open the input file and check for the name of the input source file status = nf90_open(trim(finidat_interp_dest), 0, ncid) if (status /= nf90_noerr) call handle_err(status)