Changeset 3574 for trunk/LMDZ.COMMON/libf/evolution/pem.F90
- Timestamp:
- Jan 13, 2025, 4:52:20 PM (32 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3571 r3574 238 238 real :: n_myear ! Maximum number of Martian years of the chained simulations 239 239 real :: timestep ! Timestep [s] 240 character( 20) :: job_id ! Job id provided as argument passed on the command line when theprogram was invoked240 character(100) :: arg ! To read command-line arguments program was invoked 241 241 logical :: timewall ! Flag to use the time limit stopping criterion in case of a PEM job 242 242 integer(kind=8) :: cr ! Number of clock ticks per second (count rate) … … 293 293 timewall = .true. 294 294 timelimit = 86400 ! 86400 seconds = 24 h by default 295 if (command_argument_count() > 0) then 296 ! Read the job id passed as argument to the program 297 call get_command_argument(1,job_id) 298 ! Execute the system command 299 call execute_command_line('squeue -j '//trim(job_id)//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat) 300 if (cstat /= 0) then 301 call execute_command_line('qstat -f '//trim(job_id)//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat) 302 if (cstat > 0) then 303 error stop 'pem: command execution failed!' 304 else if (cstat < 0) then 305 error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!' 306 endif 307 endif 308 ! Read the output 309 open(1,file = 'tmp_cmdout.txt',status = 'old') 310 read(1,'(a)') chtimelimit 311 close(1) 312 chtimelimit = trim(chtimelimit) 313 call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat) 314 if (cstat > 0) then 315 error stop 'pem: command execution failed!' 316 else if (cstat < 0) then 317 error stop 'pem: command execution not supported!' 318 endif 319 if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS" 320 read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds 321 timelimit = days*86400 + hours*3600 + minutes*60 + seconds 322 else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS" 323 read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds 324 timelimit = hours*3600 + minutes*60 + seconds 325 else ! 'chtimelimit' format is "MM:SS" 326 read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds 327 timelimit = minutes*60 + seconds 328 endif 329 else 330 timewall = .false. 295 timewall = .false. 296 if (command_argument_count() > 0) then ! Get the number of command-line arguments 297 call get_command_argument(1,arg) ! Read the argument given to the program 298 select case (trim(adjustl(arg))) 299 case('version') 300 call print_version_info() 301 stop 302 case default ! This is the job id 303 ! Execute the system command 304 call execute_command_line('squeue -j '//trim(adjustl(arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat) 305 if (cstat /= 0) then 306 call execute_command_line('qstat -f '//trim(adjustl(arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat) 307 if (cstat > 0) then 308 error stop 'pem: command execution failed!' 309 else if (cstat < 0) then 310 error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!' 311 endif 312 endif 313 ! Read the output 314 open(1,file = 'tmp_cmdout.txt',status = 'old') 315 read(1,'(a)') chtimelimit 316 close(1) 317 chtimelimit = trim(adjustl(chtimelimit)) 318 call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat) 319 if (cstat > 0) then 320 error stop 'pem: command execution failed!' 321 else if (cstat < 0) then 322 error stop 'pem: command execution not supported!' 323 endif 324 if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS" 325 read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds 326 timelimit = days*86400 + hours*3600 + minutes*60 + seconds 327 else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS" 328 read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds 329 timelimit = hours*3600 + minutes*60 + seconds 330 else ! 'chtimelimit' format is "MM:SS" 331 read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds 332 timelimit = minutes*60 + seconds 333 endif 334 end select 331 335 endif 332 336
Note: See TracChangeset
for help on using the changeset viewer.