实现你问我发现我在程序中实现类似的功能,最近(提交https://bitbucket.org/LadaF/elmm/commits/f10a1b3421a3dd14fdcbe165aa70bf5c5001413f)之后。但我仍然需要手动设置时间限制。
最重要的部分:
time_stepping%clock_time_limit
是以秒为单位的时间限制。计算系统时钟周期数对应于:
call system_clock(count_rate = timer_rate)
call system_clock(count_max = timer_max_count)
timer_count_time_limit = int(min(time_stepping%clock_time_limit &
* real(timer_rate, knd), &
real(timer_max_count, knd) * 0.999_dbl) &
, dbl)
启动定时器
call system_clock(count = time_steps_timer_count_start)
检查计时器,如果时间到了
if (mod(time_step,time_stepping%check_period)==0) then
if (master) then
error_exit = time_steps_timer_count_2 - time_steps_timer_count_start > timer_count_time_limit
if (error_exit) write(*,*) "Maximum clock time exceeded."
end if
MPI_Bcast the error exit to other processes
if (error_exit) exit
end if
退出与
error_exit
集的主循环
.true.
现在,您可能想要自动从您的调度程序中获取时间限制。这在不同的作业调度软件之间会有所不同。将会有一个像$PBS_WALLTIME
这样的环境变量。请参阅Get walltime in a PBS job script,但请检查您的日程安排手册。
您可以阅读使用这个变量GET_ENVIRONMENT_VARIABLE()
http://gcc.gnu.org/onlinedocs/gcc-4.5.2/gfortran/DATE_005fAND_005fTIME.html – agentp
可以SYSTEM_CLOCK(),但我真的不明白会发生什么,为什么有NULL和你想要做什么。 –
评论,因为我猜你的意思。如果你想自动检测你在批处理作业中的时间限制,并在你接近时自动关闭,那么没有没有标准的方法。首先你要读你的批处理系统的文档工作如何才能找出限制或你的工作,然后制定出一个合适的方式来传递你的Fortran(注意拼写,它已经较低的情况下超过25年),然后如何检测您是否接近该限制以及如何“干净地”关闭。 –