Check if the stop file exists.
The check is only done by the root process and only if the stop_file setting is not empty. If the stop file exists, but is empty it is deleted after probing its existence. Non-empty files are kept. Thus, you can create a stop file that is to be deleted upon encountering with: touch stop While one, that should be kept can be created by: echo keep > stop
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_abortCriteria_type), | intent(in) | :: | abortCriteria | Abort criteria settings to use in this check for a stop file. |
||
integer, | intent(in) | :: | rank | Rank of the probing process, only rank==0 actually checks for the file. |
Result that indicates, if the stop files exists.
function tem_stop_file_exists(abortCriteria, rank) result(sf_exists)
! -------------------------------------------------------------------- !
!> Abort criteria settings to use in this check for a stop file.
type(tem_abortCriteria_type), intent(in) :: abortCriteria
!> Rank of the probing process, only rank==0 actually checks for the file.
integer, intent(in) :: rank
!> Result that indicates, if the stop files exists.
logical :: sf_exists
! -------------------------------------------------------------------- !
integer :: fu
integer :: ios
character(len=labelLen) :: probe
! -------------------------------------------------------------------- !
sf_exists = .false.
if (trim(abortCriteria%stop_file) /= '') then
if (rank == 0) then
inquire( file = trim(abortCriteria%stop_file), &
& exist = sf_exists )
if (sf_exists) then
fu = newunit()
open( unit = fu, &
& file = trim(abortCriteria%stop_File), &
& status = 'old' )
read(fu,'(a)', iostat=ios) probe
if (ios < 0) then
close( unit = fu, &
& status = 'DELETE' )
else
close(fu)
end if
end if
end if
end if
end function tem_stop_file_exists