Ignore:
Timestamp:
Mar 18, 2026, 11:47:32 AM (2 weeks ago)
Author:
jbclement
Message:

PEM:
Partial reversion of r4138: relocating "job_mod" to "LMDZ.COMMON/libf/misc/" because "parse_arg_mod" needs to know "job_mod" even if it is not the PEM.
JBC

Location:
trunk/LMDZ.COMMON/libf/misc
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/misc/job_mod.F90

    r4138 r4139  
    1 MODULE job
     1MODULE job_mod
    22
    33!-----------------------------------------------------------------------
    44! NAME
    5 !     job
     5!     job_mod
    66!
    77! DESCRIPTION
    8 !     Management of memory throughout the modules of the code.
     8!     Tools to retieve job information of the program.
    99!
    1010! AUTHORS & DATE
     
    1515!-----------------------------------------------------------------------
    1616
    17 ! DEPENDENCIES
    18 ! ------------
    19 use numerics, only: dp, di, k4
    20 
    2117! DECLARATION
    2218! -----------
     
    2521! PARAMETERS
    2622! ----------
    27 real(dp)            :: timelimit = 86400._dp ! Time limit for the job: 86400 s = 24 h by default
    28 real(dp), parameter :: antetime  = 3600._dp  ! Anticipation time to prevent reaching the job time limit: 3600 s = 1 h by default
    29 logical(k4)         :: timewall = .false.    ! Flag to enable the program self-termination before timeout
     23real            :: timelimit = 86400. ! Time limit for the job: 86400 s = 24 h by default
     24real, parameter :: antetime  = 3600.  ! Anticipation time to prevent reaching the job time limit: 3600 s = 1 h by default
     25logical         :: timewall = .false. ! Flag to enable the program self-termination before timeout
    3026
    3127contains
     
    4844!-----------------------------------------------------------------------
    4945
    50 ! DEPENDENCIES
    51 ! ------------
    52 use stoppage, only: stop_clean
    53 
    5446! DECLARATION
    5547! -----------
     
    6254! LOCAL VARIABLES
    6355! ---------------
    64 integer(di)    :: sts
     56integer        :: sts
    6557character(256) :: tmp
    6658
     
    8274endif
    8375
    84 call stop_clean(__FILE__,__LINE__,"neither SLURM_JOB_ID nor PBS_JOBID found in environment!",1)
     76error stop 'Error: neither SLURM_JOB_ID nor PBS_JOBID found in environment!'
    8577
    8678END SUBROUTINE get_job_id
     
    10496!-----------------------------------------------------------------------
    10597
    106 ! DEPENDENCIES
    107 ! ------------
    108 use stoppage, only: stop_clean
    109 
    11098! DECLARATION
    11199! -----------
     
    118106! LOCAL VARIABLES
    119107! ---------------
    120 logical(k4)    :: num_str
     108logical        :: num_str
    121109character(256) :: chtimelimit ! Time limit for the job outputted by the SLURM or PBS/TORQUE command
    122 integer(di)    :: i, ierr, funit, cstat, days, hours, minutes, seconds
     110integer        :: i, ierr, funit, cstat, days, hours, minutes, seconds
    123111character(1)   :: sep
    124112
     
    133121    endif
    134122enddo
    135 if (.not. num_str) call stop_clean(__FILE__,__LINE__,"job ID must be numeric!",1)
     123if (.not. num_str) error stop "Error: job ID must be numeric!"
    136124
    137125! Try SLURM (squeue)
     
    141129    call execute_command_line('qstat -f '//trim(adjustl(jobid))//' | grep "Walltime" | awk ''{print $3}'' > tmp_timelimit.txt',cmdstat = cstat)
    142130    if (cstat > 0) then
    143         call stop_clean(__FILE__,__LINE__,'command execution failed!',1)
     131        error stop 'Error: command execution failed!'
    144132    else if (cstat < 0) then
    145         call stop_clean(__FILE__,__LINE__,'command execution not supported (neither SLURM nor PBS/TORQUE is installed)!',1)
     133        error stop 'Error: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!'
    146134    endif
    147135endif
     
    149137! Read the output
    150138open(newunit = funit,file = 'tmp_timelimit.txt',status = 'old',form = 'formatted',action = 'read',iostat = ierr)
    151 if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "tmp_timelimit.txt"!',ierr)
     139if (ierr /= 0) error stop 'Error: error opening file "tmp_timelimit.txt"!'
    152140read(funit,'(a)') chtimelimit
    153141close(funit)
     
    157145call execute_command_line('rm tmp_timelimit.txt',cmdstat = cstat)
    158146if (cstat > 0) then
    159     call stop_clean(__FILE__,__LINE__,'command execution failed!',1)
     147    error stop 'Error: command execution failed!'
    160148else if (cstat < 0) then
    161     call stop_clean(__FILE__,__LINE__,'command execution not supported!',1)
     149    error stop 'Error: command execution not supported!'
    162150endif
    163151
     
    165153if (index(chtimelimit,'-') > 0) then ! Format "D-HH:MM:SS"
    166154    read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds
    167     timelimit = real(days,dp)*86400._dp + real(hours,dp)*3600._dp + real(minutes,dp)*60._dp + real(seconds,dp)
     155    timelimit = real(days)*86400. + real(hours)*3600. + real(minutes)*60. + real(seconds)
    168156else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! Format "HH:MM:SS"
    169157    read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds
    170     timelimit = real(hours,dp)*3600._dp + real(minutes,dp)*60._dp + real(seconds,dp)
     158    timelimit = real(hours)*3600. + real(minutes)*60. + real(seconds)
    171159else ! Format "MM:SS"
    172160    read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds
    173     timelimit = real(minutes,dp)*60._dp + real(seconds,dp)
     161    timelimit = real(minutes)*60. + real(seconds)
    174162endif
    175163
     
    179167!=======================================================================
    180168
    181 END MODULE job
     169END MODULE job_mod
  • trunk/LMDZ.COMMON/libf/misc/parse_args_mod.F90

    r4138 r4139  
    1414use pgrm_version_mod,  only: print_pgrm_version
    1515#endif
    16 use job,               only: get_job_id, get_job_timelimit
     16use job_mod,           only: get_job_id, get_job_timelimit
    1717
    1818implicit none
Note: See TracChangeset for help on using the changeset viewer.