tem_stop_file_exists Function

public function tem_stop_file_exists(abortCriteria, rank) result(sf_exists)

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

Arguments

Type IntentOptional 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.

Return Value logical

Result that indicates, if the stop files exists.


Calls

proc~~tem_stop_file_exists~~CallsGraph proc~tem_stop_file_exists tem_stop_file_exists proc~newunit newunit proc~tem_stop_file_exists->proc~newunit

Called by

proc~~tem_stop_file_exists~~CalledByGraph proc~tem_stop_file_exists tem_stop_file_exists proc~tem_simcontrol_syncupdate tem_simControl_syncUpdate proc~tem_simcontrol_syncupdate->proc~tem_stop_file_exists

Source Code

  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