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