Logical check for stop file Check if file exists Read line-by-line
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in), | optional | :: | file |
File to check for |
File found flag and output
function stop_check(file) result(output) !! Logical check for stop file implicit none ! Arguments character(*), optional, intent(in) :: file !! File to check for ! Local variables integer :: Reason, itmp1, unit !! I/O status, temporary integer, and unit logical :: lfound, output !! File found flag and output character(248) :: file_ !! File name character(128) :: buffer, tagname !! Buffer and tag name unit = 999 file_ = "STOPCAR" if(present(file)) file_ = file output = .false. !! Check if file exists inquire(file = trim(file_), exist = lfound) if(lfound)then itmp1 = 0 open(unit = unit, file = trim(file_)) !! Read line-by-line do read(unit, '(A)', iostat = Reason) buffer if(Reason .ne. 0) exit call rm_comments(buffer) if(trim(buffer) .eq. "") cycle tagname = trim(adjustl(buffer)) if(scan(buffer, "=") .ne. 0) & tagname = trim(tagname(:scan(tagname, "=") - 1)) select case(trim(tagname)) case("LSTOP") call assignL(buffer, output, itmp1) exit case("LABORT") call assignL(buffer, output, itmp1) if(output)then close(unit, status = 'delete') stop "LABORT ENCOUNTERED IN STOP FILE (" // trim(file_) // ")" end if end select end do close(unit, status = 'delete') end if end function stop_check