Ignore:
Timestamp:
Jan 13, 2025, 4:52:20 PM (5 months ago)
Author:
jbclement
Message:

COMMON:
The compilation generates a Fortran subroutine to track compilation and version (SVN or Git) details through the executable file. Put the argument 'version' as an option when executing the code to display these information and create a file "version_diff.txt" containing the diff result.
It can work with every program but it has been implemented only for: 'gcm', 'parallel gcm', 'pem', '1D Mars PCM', 'Mars newstart', 'Mars start2archive' and '1D Generic PCM'.
JBC

Location:
trunk/LMDZ.COMMON/libf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90

    r3316 r3574  
    3030  USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref, &
    3131                itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end
     32  use version_info_mod, only: print_version_info
    3233
    3334
     
    133134  character (len=20) :: modname
    134135  character (len=80) :: abort_message
     136  character(100)     :: arg ! To read command-line arguments
    135137  ! locales pour gestion du temps
    136138  INTEGER :: an, mois, jour
     
    142144!   Initialisations:
    143145!   ----------------
     146
     147  if (command_argument_count() > 0) then ! Get the number of command-line arguments
     148      call get_command_argument(1,arg) ! Read the argument given to the program
     149      select case (trim(adjustl(arg)))
     150          case('version')
     151              call print_version_info()
     152              stop
     153          case default
     154              error stop "The argument given to the program is unknown!"
     155      end select
     156  endif
    144157
    145158  abort_message = 'last timestep reached'
  • TabularUnified trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F

    r3316 r3574  
    2727     &                       ecritstart
    2828      use cpdet_mod, only: ini_cpdet
     29      use version_info_mod, only: print_version_info
    2930
    3031
     
    134135      character (len=20) :: modname
    135136      character (len=80) :: abort_message
     137      character(100)     :: arg ! To read command-line arguments
    136138! locales pour gestion du temps
    137139      INTEGER :: an, mois, jour
     
    156158c   Initialisations:
    157159c   ----------------
     160
     161      if (command_argument_count() > 0) then ! Get the number of command-line arguments
     162          call get_command_argument(1,arg) ! Read the argument given to the program
     163          select case (trim(adjustl(arg)))
     164              case('version')
     165                  call print_version_info()
     166                  stop
     167              case default
     168                  error stop 'The argument given to the program '
     169     &//'is unknown!'
     170          end select
     171      endif
    158172
    159173      abort_message = 'last timestep reached'
  • TabularUnified trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3571 r3574  
    238238real            :: n_myear         ! Maximum number of Martian years of the chained simulations
    239239real            :: timestep        ! Timestep [s]
    240 character(20)   :: job_id          ! Job id provided as argument passed on the command line when the program was invoked
     240character(100)  :: arg             ! To read command-line arguments program was invoked
    241241logical         :: timewall        ! Flag to use the time limit stopping criterion in case of a PEM job
    242242integer(kind=8) :: cr              ! Number of clock ticks per second (count rate)
     
    293293timewall = .true.
    294294timelimit = 86400 ! 86400 seconds = 24 h by default
    295 if (command_argument_count() > 0) then
    296     ! Read the job id passed as argument to the program
    297     call get_command_argument(1,job_id)
    298     ! Execute the system command
    299     call execute_command_line('squeue -j '//trim(job_id)//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat)
    300     if (cstat /= 0) then
    301         call execute_command_line('qstat -f '//trim(job_id)//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat)
    302         if (cstat > 0) then
    303             error stop 'pem: command execution failed!'
    304         else if (cstat < 0) then
    305             error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!'
    306         endif
    307     endif
    308     ! Read the output
    309     open(1,file = 'tmp_cmdout.txt',status = 'old')
    310     read(1,'(a)') chtimelimit
    311     close(1)
    312     chtimelimit = trim(chtimelimit)
    313     call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat)
    314     if (cstat > 0) then
    315         error stop 'pem: command execution failed!'
    316     else if (cstat < 0) then
    317         error stop 'pem: command execution not supported!'
    318     endif
    319     if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS"
    320         read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds
    321         timelimit = days*86400 + hours*3600 + minutes*60 + seconds
    322     else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS"
    323         read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds
    324         timelimit = hours*3600 + minutes*60 + seconds
    325     else ! 'chtimelimit' format is "MM:SS"
    326         read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds
    327         timelimit = minutes*60 + seconds
    328     endif
    329 else
    330     timewall = .false.
     295timewall = .false.
     296if (command_argument_count() > 0) then ! Get the number of command-line arguments
     297    call get_command_argument(1,arg) ! Read the argument given to the program
     298    select case (trim(adjustl(arg)))
     299        case('version')
     300            call print_version_info()
     301            stop
     302        case default ! This is the job id
     303           ! Execute the system command
     304            call execute_command_line('squeue -j '//trim(adjustl(arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat)
     305            if (cstat /= 0) then
     306                call execute_command_line('qstat -f '//trim(adjustl(arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat)
     307                if (cstat > 0) then
     308                    error stop 'pem: command execution failed!'
     309                else if (cstat < 0) then
     310                    error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!'
     311                endif
     312            endif
     313            ! Read the output
     314            open(1,file = 'tmp_cmdout.txt',status = 'old')
     315            read(1,'(a)') chtimelimit
     316            close(1)
     317            chtimelimit = trim(adjustl(chtimelimit))
     318            call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat)
     319            if (cstat > 0) then
     320                error stop 'pem: command execution failed!'
     321            else if (cstat < 0) then
     322                error stop 'pem: command execution not supported!'
     323            endif
     324            if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS"
     325                read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds
     326                timelimit = days*86400 + hours*3600 + minutes*60 + seconds
     327            else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS"
     328                read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds
     329                timelimit = hours*3600 + minutes*60 + seconds
     330            else ! 'chtimelimit' format is "MM:SS"
     331                read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds
     332                timelimit = minutes*60 + seconds
     333            endif
     334    end select
    331335endif
    332336
Note: See TracChangeset for help on using the changeset viewer.