9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-11 16:03:38 +01:00
qp2/src/ezfio_files/qp_stop.irp.f

45 lines
1.0 KiB
Fortran

BEGIN_PROVIDER [ character*(256), qp_stop_filename ]
&BEGIN_PROVIDER [ character*(256), qp_kill_filename ]
&BEGIN_PROVIDER [ integer, qp_stop_variable ]
implicit none
BEGIN_DOC
! Name of the file to check for qp stop
END_DOC
qp_stop_filename = trim(ezfio_filename)//'/work/qpstop'
qp_kill_filename = trim(ezfio_filename)//'/work/qpkill'
qp_stop_variable = 0
END_PROVIDER
logical function qp_stop()
implicit none
BEGIN_DOC
! Checks if the qp_stop command was invoked for the clean termination of the program
END_DOC
integer :: iunit
integer, external :: getUnitAndOpen
if (qp_stop_variable == 0) then
INQUIRE(FILE=trim(qp_kill_filename), EXIST=qp_stop)
if (qp_stop) then
qp_stop_variable = 1
! qp_stop is true
return
endif
INQUIRE(FILE=trim(qp_stop_filename), EXIST=qp_stop)
if (qp_stop) then
iunit = getUnitAndOpen(trim(qp_stop_filename),'r')
close(iunit, STATUS='DELETE')
endif
else
qp_stop = .True.
endif
end