From 3115ecdabb0db9390fbe7ecfedab3abd07ab089c Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Wed, 19 Aug 2020 22:38:51 -0300 Subject: [PATCH 1/2] IO: Restart job from the last available restart snapshot. If parameter 'restart_number' was not set or is negative, it is determined from the last available restart snapshot. The restart snapshots should be all in the same restart path in the complete sequence, i.e., from first one to the last one. Signed-off-by: Grzegorz Kowal --- sources/io.F90 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sources/io.F90 b/sources/io.F90 index 93fcf99..43fe3cf 100644 --- a/sources/io.F90 +++ b/sources/io.F90 @@ -251,6 +251,7 @@ module io use hdf5 , only : h5pset_deflate_f, h5pset_filter_f #endif /* HDF5 */ use iso_fortran_env, only : error_unit + use mpitools , only : nproc use parameters , only : get_parameter ! local variables are not implicit by default @@ -264,6 +265,8 @@ module io ! local variables ! + logical :: test + character(len=255) :: dname character(len=255) :: sformat = "xml" character(len=255) :: precise = "off" character(len=255) :: ghosts = "on" @@ -275,6 +278,7 @@ module io integer, dimension(1) :: cd_values = 3 #endif /* HDF5 */ + #ifdef HDF5 ! local parameters ! @@ -341,6 +345,38 @@ module io restart_format = snapshot_xml end select +! check the last available restart snapshot +! + if (nrest < 0) then + + test = .true. + nrest = 0 + + select case(restart_format) +#ifdef HDF5 + case(snapshot_hdf5) + do while (test) + nrest = nrest + 1 + write(dname, "(a,'r',i6.6,'_',i5.5,'.h5')") & + trim(respath), nrest, nproc + inquire(file = dname, exist = test) + end do +#endif /* HDF5 */ + case default + do while (test) + nrest = nrest + 1 + write(dname, "(a,'restart-',i5.5)") trim(respath), nrest +#ifdef __INTEL_COMPILER + inquire(directory = dname, exist = test) +#else /* __INTEL_COMPILER */ + inquire(file = dname, exist = test) +#endif /* __INTEL_COMPILER */ + end do + end select + + nrest = nrest - 1 + end if + ! get compression format and level for XML+binary files ! call get_parameter("compression_format", cformat) From fe9c22348973fd35ebbf62d1ad5ed619581cfeeb Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Wed, 19 Aug 2020 22:49:46 -0300 Subject: [PATCH 2/2] IO: Fix a warning in the case of no forcing modes. Signed-off-by: Grzegorz Kowal --- sources/io.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/io.F90 b/sources/io.F90 index 43fe3cf..25bbd57 100644 --- a/sources/io.F90 +++ b/sources/io.F90 @@ -4255,8 +4255,8 @@ module io ! restore forcing coefficients ! call read_attribute(gid, 'nmodes', lnmodes) - if (lnmodes == nmodes .and. lnmodes > 0) then - call read_attribute(gid, 'fcoefs', fcoefs) + if (lnmodes == nmodes) then + if (lnmodes > 0) call read_attribute(gid, 'fcoefs', fcoefs) else write(error_unit,"('[',a,']: ',a)") trim(loc) & , "The number of driving modes does not match!"