Changeset 3869 for trunk/LMDZ.COMMON/libf/misc
- Timestamp:
- Jul 28, 2025, 4:56:58 PM (5 days ago)
- Location:
- trunk/LMDZ.COMMON/libf/misc
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/misc/job_timelimit_mod.F90
r3837 r3869 4 4 ! DESCRIPTION: 5 5 ! Retrieves the time limit (in seconds) for a given job ID via 6 ! SLURM (squeue) or PBS/TORQUE (qstat).6 ! SLURM or PBS/TORQUE. 7 7 !*********************************************************************** 8 8 … … 17 17 !======================================================================= 18 18 19 SUBROUTINE get_job_timelimit( arg)19 SUBROUTINE get_job_timelimit(jobid) 20 20 21 21 implicit none 22 22 23 23 !---- Arguments 24 character(*), intent(in) :: arg24 character(*), intent(in) :: jobid 25 25 26 26 !---- Variables … … 33 33 ! Check that the job ID is numeric 34 34 num_str = .true. 35 do i = 1,len_trim( arg)36 if ( arg(i:i) < '0' .or. arg(i:i) > '9') then35 do i = 1,len_trim(jobid) 36 if (jobid(i:i) < '0' .or. jobid(i:i) > '9') then 37 37 num_str = .false. 38 38 exit … … 42 42 43 43 ! Try SLURM (squeue) 44 call execute_command_line('squeue -j '//trim(adjustl( arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat)44 call execute_command_line('squeue -j '//trim(adjustl(jobid))//' -h --Format TimeLimit > tmp_timelimit.txt',cmdstat = cstat) 45 45 if (cstat /= 0) then 46 46 ! On failure, try PBS/TORQUE (qstat) 47 call execute_command_line('qstat -f '//trim(adjustl( arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat)47 call execute_command_line('qstat -f '//trim(adjustl(jobid))//' | grep "Walltime" | awk ''{print $3}'' > tmp_timelimit.txt',cmdstat = cstat) 48 48 if (cstat > 0) then 49 49 error stop 'Error: command execution failed!' … … 54 54 55 55 ! Read the output 56 open(1,file = 'tmp_ cmdout.txt',status = 'old')56 open(1,file = 'tmp_timelimit.txt',status = 'old') 57 57 read(1,'(a)') chtimelimit 58 58 close(1) … … 60 60 61 61 ! Remove temporary file 62 call execute_command_line('rm tmp_ cmdout.txt',cmdstat = cstat)62 call execute_command_line('rm tmp_timelimit.txt',cmdstat = cstat) 63 63 if (cstat > 0) then 64 64 error stop 'Error: command execution failed!' -
trunk/LMDZ.COMMON/libf/misc/parse_args_mod.F90
r3837 r3869 12 12 13 13 use pgrm_version_mod, only: print_pgrm_version 14 use job_id_mod, only: get_job_id 14 15 use job_timelimit_mod, only: get_job_timelimit 15 16 … … 30 31 !---- Variables 31 32 integer :: narg, i, eq_pos 32 character(256) :: arg, key, vlu 33 character(256) :: arg, key, vlu, jobid 33 34 34 35 !---- Code … … 73 74 write(*,*) 'SSO fields will be included in "start_archive.nc"' 74 75 75 case ('--jobid') 76 call get_job_timelimit(vlu) 76 case ('--auto-exit') 77 call get_job_id(jobid) 78 call get_job_timelimit(jobid) 77 79 78 80 case default … … 93 95 write(*,*) ' --version [file] Print program version and exit (optional output file)' 94 96 write(*,*) ' --add-sso Add SSO fields to "start_archive.nc" (only available for Mars start2archive)' 95 write(*,*) ' --jobid <id> Query the time limit for the specified job ID,' 96 write(*,*) ' enabling self-termination before timeout (only available for the PEM)' 97 write(*,*) ' --auto-exit Enable automatic termination before reaching the job time limit (only available for the PEM)' 97 98 write(*,*) 98 99 END SUBROUTINE print_usage
Note: See TracChangeset
for help on using the changeset viewer.