Commit 2d1cbdc9 authored by Daniel Wortmann's avatar Daniel Wortmann

Added a command line switch -wtime to limit the runtime of FLEUR. This switch is used

to stop SCF iterations if the remaining time is not sufficient
parent 2b0d8afb
......@@ -34,4 +34,21 @@ CONTAINS
IF (i==0) ok=INDEX(str,ADJUSTL(arg))>0
END FUNCTION juDFT_was_argument
FUNCTION juDFT_string_for_argument(arg) RESULT(argstring)
IMPLICIT NONE
CHARACTER(len=*),INTENT(IN)::arg
CHARACTER(len=20)::argstring
INTEGER:: i
CHARACTER(LEN=30)::str
argstring=""
DO i=1,COMMAND_ARGUMENT_COUNT()
CALL GET_COMMAND_ARGUMENT(i,str)
IF(ADJUSTL(str)==ADJUSTL(arg)) THEN
if (i<=COMMAND_ARGUMENT_COUNT()) CALL GET_COMMAND_ARGUMENT(i+1,argstring)
endif
ENDDO
END FUNCTION juDFT_string_for_argument
END MODULE m_juDFT_args
......@@ -38,7 +38,7 @@ MODULE m_juDFT_time
INTEGER ,SAVE :: lastline=0
PUBLIC timestart,timestop,writetimes,writelocation,writeTimesXML
PUBLIC resetIterationDependentTimers
PUBLIC resetIterationDependentTimers,check_time_for_next_iteration
PUBLIC juDFT_time_lastlocation !should not be used
CONTAINS
......@@ -393,19 +393,58 @@ CONTAINS
END IF
END SUBROUTINE privWriteTimesXML
SUBROUTINE check_time_for_next_iteration(it,l_cont)
USE m_judft_args
IMPLICIT NONE
INTEGER,INTENT(IN) :: it
LOGICAL,INTENT(INOUT) :: l_cont
CHARACTER(len=20)::wtime_string
INTEGER :: wtime,time_used,time_per_iter
INTEGER:: irank=0
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err,isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,err)
#endif
IF (.NOT.l_cont) RETURN !stop anyway
IF (.NOT.ASSOCIATED(globaltimer)) RETURN !do nothing if no timing recorded
IF (judft_was_argument("-wtime")) THEN
wtime_string=judft_string_for_argument("-wtime")
READ(wtime_string,*) wtime
time_used=FLOOR((cputime()-globaltimer%starttime)/60.0)+1
time_per_iter=FLOOR((cputime()-globaltimer%starttime)/60.0/it)+1
IF (irank==0) THEN
WRITE(*,*) "Test for time of next iteration:"
WRITE(*,*) "Time provided (min):",wtime
WRITE(*,*) "Time used (min):",time_used
WRITE(*,*) "Time per iter (min):",time_per_iter
ENDIF
IF (time_used+time_per_iter>wtime) THEN
l_cont=.FALSE.
IF (irank==0) WRITE(*,*) "No further iterations"
ENDIF
END IF
END SUBROUTINE check_time_for_next_iteration
SUBROUTINE resetIterationDependentTimers()
IMPLICIT NONE
INTEGER :: fn,irank=0
LOGICAL :: l_out
TYPE(t_timer), POINTER :: timer, parenttimer
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err,isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,err)
#endif
!Check if not enough time for another iteration is left
IF (irank.NE.0) RETURN
IF (.NOT.ASSOCIATED(globaltimer)) RETURN !write nothing if no timing recorded
......
......@@ -859,6 +859,7 @@
END IF
CALL writeTimesXML()
CALL resetIterationDependentTimers()
CALL check_time_for_next_iteration(it,l_cont)
IF ((mpi%irank.EQ.0).AND.(isCurrentXMLElement("iteration"))) THEN
CALL closeXMLElement('iteration')
END IF
......
......@@ -12,7 +12,7 @@ CONTAINS
USE m_juDFT
IMPLICIT NONE
CHARACTER(LEN=50):: gitdesc,githash,compile_date,compile_user,compile_host
PRINT *," Welcome to FLEUR (www.flapw.de) "
PRINT *," MaX-Release 1 (www.max-centre.eu)"
......@@ -41,6 +41,8 @@ CONTAINS
WRITE(*,*)""
WRITE(*,*)"-xmlInput : use inp.xml instead of inp"
WRITE(*,*)""
WRITE(*,*)"-wtime XXXXX : run for XXXX minutes (used to estimate if another iteration is started"
WRITE(*,*)""
WRITE(*,*)"-j #:DIR : run subjob in directory DIR using # PEs"
WRITE(*,*)"-f FILENAME : obtain info on subjobs from file FILENAME"
WRITE(*,*)""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment