source: trunk/LMDZ.COMMON/libf/misc/job_id_mod.F90 @ 3985

Last change on this file since 3985 was 3869, checked in by jbclement, 5 months ago

PEM:
Bug correction to detect the job time limit with PBS/TORQUE. Making it more robust and automatic for the launching script and the Fortran code.
JBC

File size: 1.2 KB
Line 
1MODULE job_id_mod
2
3!***********************************************************************
4! DESCRIPTION:
5!    Retrieves the ID for a given job ID via SLURM or PBS/TORQUE.
6!***********************************************************************
7
8implicit none
9
10!=======================================================================
11contains
12!=======================================================================
13
14SUBROUTINE get_job_id(jobid)
15
16implicit none
17
18!---- Arguments
19character(256), intent(out) :: jobid
20
21!---- Variables
22integer        :: stat
23character(256) :: tmp
24
25!---- Code
26! Try SLURM
27call get_environment_variable("SLURM_JOBID",tmp,status = stat)
28if (stat == 0 .and. len_trim(tmp) > 0) then
29    jobid = trim(adjustl(tmp))
30    return
31endif
32   
33! Try PBS/TORQUE 
34call get_environment_variable("PBS_JOBID",tmp,status = stat)
35if (stat == 0 .and. len_trim(tmp) > 0) then
36    ! Extract only the part before the point in '12345.master.cluster' to get the numeric job ID
37    jobid = trim(adjustl(tmp(1:index(tmp,'.') - 1)))
38    return
39endif
40   
41error stop 'Error: neither SLURM_JOB_ID nor PBS_JOBID found in environment!'
42
43END SUBROUTINE get_job_id
44
45END MODULE job_id_mod
Note: See TracBrowser for help on using the repository browser.