Changeset 3836 for trunk/LMDZ.COMMON/libf/evolution/pem.F90
- Timestamp:
- Jul 7, 2025, 2:46:43 PM (21 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3809 r3836 73 73 print_layering 74 74 use dyn_ss_ice_m_mod, only: dyn_ss_ice_m 75 use version_info_mod, only: print_version_info 75 use parse_args_mod, only: parse_args 76 use job_timelimit_mod, only: timelimit, antetime, timewall 76 77 use paleoclimate_mod, only: h2o_ice_depth, zdqsdif_ssi_tot 77 78 … … 241 242 real :: n_myear ! Maximum number of Martian years of the chained simulations 242 243 real :: timestep ! Timestep [s] 243 character(100) :: arg ! To read command-line arguments program was invoked244 logical :: timewall ! Flag to use the time limit stopping criterion in case of a PEM job245 244 integer(kind = 8) :: cr ! Number of clock ticks per second (count rate) 246 245 integer(kind = 8) :: c1, c2 ! Counts of processor clock 247 character(100) :: chtimelimit ! Time limit for the PEM job outputted by the SLURM command248 real :: timelimit ! Time limit for the PEM job in seconds249 real, parameter :: antetime = 3600 ! Anticipation time to prevent reaching the job time limit: 3600 s by default (it should cover the computing time of the reshaping tool)250 integer :: cstat, days, hours, minutes, seconds251 character(1) :: sep252 246 character(8) :: date 253 247 character(10) :: time … … 313 307 call system_clock(count_rate = cr) 314 308 call system_clock(c1) 315 timewall = .true. 316 timelimit = 86400 ! 86400 seconds = 24 h by default 317 if (command_argument_count() > 0) then ! Get the number of command-line arguments 318 call get_command_argument(1,arg) ! Read the argument given to the program 319 num_str = .true. 320 do i = 1,len_trim(arg) 321 if (arg(i:i) < '0' .or. arg(i:i) > '9') then 322 num_str = .false. 323 exit 324 endif 325 enddo 326 327 if (num_str) then ! This is a numeric sting so we considerer this is the job id 328 ! Execute the system command 329 call execute_command_line('squeue -j '//trim(adjustl(arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat) 330 if (cstat /= 0) then 331 call execute_command_line('qstat -f '//trim(adjustl(arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat) 332 if (cstat > 0) then 333 error stop 'pem: command execution failed!' 334 else if (cstat < 0) then 335 error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!' 336 endif 337 endif 338 ! Read the output 339 open(1,file = 'tmp_cmdout.txt',status = 'old') 340 read(1,'(a)') chtimelimit 341 close(1) 342 chtimelimit = trim(adjustl(chtimelimit)) 343 call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat) 344 if (cstat > 0) then 345 error stop 'pem: command execution failed!' 346 else if (cstat < 0) then 347 error stop 'pem: command execution not supported!' 348 endif 349 if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS" 350 read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds 351 timelimit = days*86400 + hours*3600 + minutes*60 + seconds 352 else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS" 353 read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds 354 timelimit = hours*3600 + minutes*60 + seconds 355 else ! 'chtimelimit' format is "MM:SS" 356 read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds 357 timelimit = minutes*60 + seconds 358 endif 359 else ! Arg is not a numeric string 360 select case (trim(adjustl(arg))) 361 case('version') ! Handle command‐line argument "version" 362 call print_version_info() 363 stop 364 case default 365 error stop "The argument given to the program is unknown!" 366 end select 367 endif 368 else 369 timewall = .false. 370 endif 309 call parse_args() 371 310 372 311 ! Some user info
Note: See TracChangeset
for help on using the changeset viewer.