Changeset 3574
- Timestamp:
- Jan 13, 2025, 4:52:20 PM (21 hours ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90
r3316 r3574 30 30 USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref, & 31 31 itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end 32 use version_info_mod, only: print_version_info 32 33 33 34 … … 133 134 character (len=20) :: modname 134 135 character (len=80) :: abort_message 136 character(100) :: arg ! To read command-line arguments 135 137 ! locales pour gestion du temps 136 138 INTEGER :: an, mois, jour … … 142 144 ! Initialisations: 143 145 ! ---------------- 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 144 157 145 158 abort_message = 'last timestep reached' -
trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
r3316 r3574 27 27 & ecritstart 28 28 use cpdet_mod, only: ini_cpdet 29 use version_info_mod, only: print_version_info 29 30 30 31 … … 134 135 character (len=20) :: modname 135 136 character (len=80) :: abort_message 137 character(100) :: arg ! To read command-line arguments 136 138 ! locales pour gestion du temps 137 139 INTEGER :: an, mois, jour … … 156 158 c Initialisations: 157 159 c ---------------- 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 158 172 159 173 abort_message = 'last timestep reached' -
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3571 r3574 238 238 real :: n_myear ! Maximum number of Martian years of the chained simulations 239 239 real :: timestep ! Timestep [s] 240 character( 20) :: job_id ! Job id provided as argument passed on the command line when theprogram was invoked240 character(100) :: arg ! To read command-line arguments program was invoked 241 241 logical :: timewall ! Flag to use the time limit stopping criterion in case of a PEM job 242 242 integer(kind=8) :: cr ! Number of clock ticks per second (count rate) … … 293 293 timewall = .true. 294 294 timelimit = 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. 295 timewall = .false. 296 if (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 331 335 endif 332 336 -
trunk/LMDZ.COMMON/makelmdz_fcm
r3499 r3574 78 78 ######################################################################## 79 79 80 # Get the compilation command 81 compilation_command="$(basename $0) $@" 82 83 # Parse arguments and capture options 80 84 while (($# > 0)) 81 85 do … … 120 124 exec : executable to build 121 125 fin 122 126 exit;; 123 127 124 128 "-d") 125 129 dim=$2 ; shift ; shift ;; 126 130 127 131 "-p") 128 132 physique="$2" ; shift ; shift ;; 129 133 130 134 "-s") 131 135 scatterers=$2 ; shift ; shift ;; 132 136 133 137 "-b") 134 138 bands=$2 ; shift ; shift ;; 135 139 136 140 "-g") 137 141 grille="$2" ; shift ; shift ;; 138 142 139 143 "-c") 140 144 couple="$2" ; shift ; shift ;; 141 145 142 146 "-prod") 143 147 compil_mod="prod" ; shift ;; 144 148 145 149 "-dev") 146 150 compil_mod="dev" ; shift ;; 147 151 148 152 "-debug") 149 153 compil_mod="debug" ; shift ;; 150 154 151 155 "-io") 152 156 io="$2" ; shift ; shift ;; 153 157 154 158 "-v") 155 159 veget="$2" ; shift ; shift ;; 156 160 157 161 "-sisvat") 158 162 sisvat="$2" ; shift ; shift ;; 159 163 160 164 "-rrtm") 161 165 rrtm="$2" ; shift ; shift ;; 162 166 163 167 "-dust") 164 168 dust="$2" ; shift ; shift ;; 165 169 166 170 "-strataer") 167 171 strataer="$2" ; shift ; shift ;; 168 172 169 173 "-chimie") 170 174 chimie="$2" ; shift ; shift ;; 171 175 172 176 "-parallel") 173 177 parallel="$2" ; shift ; shift ;; 174 178 175 179 "-include") 176 180 INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;; 177 181 178 182 "-cpp") 179 183 CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; 180 184 181 185 "-adjnt") 182 183 184 186 echo "not operational ... work to be done here ";exit 1 187 opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " 188 optim="$optim -Dadj" ; shift ;; 185 189 186 190 "-cosp") … … 191 195 192 196 "-filtre") 193 197 filtre=$2 ; shift ; shift ;; 194 198 195 199 "-link") 196 200 LIB="$LIB $2" ; shift ; shift ;; 197 201 198 202 "-fcm_path") 199 203 fcm_path=$2 ; shift ; shift ;; 200 204 201 205 "-ext_src") 202 206 EXT_SRC=$2 ; shift ; shift ;; 203 207 204 208 "-j") 205 209 job=$2 ; shift ; shift ;; 206 210 207 211 "-full") 208 212 full="-full" ; shift ;; 209 213 210 214 "-libphy") 211 215 libphy="true" ; shift ;; 212 216 213 217 "-arch") 214 218 arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; 215 219 216 220 "-arch_path") 217 221 arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; 218 222 219 223 *) 220 224 code="$1" ; shift ;; 221 225 esac 222 226 done … … 333 337 if [[ "$couple" == "MPI1" ]] 334 338 then 335 336 337 338 339 339 CPP_KEY="$CPP_KEY CPP_COUPLE" 340 export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 341 export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib 342 INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" 343 LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" 340 344 else 341 342 343 345 CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" 346 INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" 347 LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" 344 348 fi 345 349 fi … … 588 592 fi 589 593 fi 594 595 596 ######################################################################## 597 # Generation of a Fortran subroutine to track compilation and version 598 # details through the executable file 599 ######################################################################## 600 601 # Path and name of the generated file 602 info_file="$LIBFGCM/misc/version_info.F90" 603 604 # Path and name of the file containing the difference result 605 diff_file="version_diff.txt" 606 607 # Get the current date 608 current_date=$(date) 609 610 # Determine version control system (SVN, Git or none) 611 if command -v svn > /dev/null && svn info > /dev/null 2>&1; then 612 vcs="svn" 613 vcs_info=$(svn info $LMDGCM/..) 614 vcs_diff=$(svn diff $LMDGCM/..) 615 elif command -v git > /dev/null && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then 616 vcs="git" 617 vcs_info=$(git log -1 --pretty=format:"%H%n%an%n%ad%n%s" $LMDGCM/..) 618 vcs_diff=$(git diff $LMDGCM/..) 619 else 620 vcs="none" 621 fi 622 623 # Function to escape the simple quotation sign 624 escape_signs() { 625 echo "$1" | sed "s/'/''/g" 626 } 627 628 # Generate the Fortran subroutine 629 cat << EOF > "$info_file" 630 !*********************************************************************** 631 ! File generated automatically at compilation 632 ! 633 ! DESCRIPTION: 634 ! The subroutine 'print_version_info' prints compilation details, the 635 ! version control information (SVN or Git) and the diff result if 636 ! applicable. 637 ! 638 ! PARAMETERS: 639 ! None. 640 ! 641 ! USAGE: 642 ! Put the argument 'version' as an option when executing the code to 643 ! display compilation and version details. It is useful for tracking 644 ! code builds through the executable file. 645 !*********************************************************************** 646 647 MODULE version_info_mod 648 649 !======================================================================= 650 contains 651 !======================================================================= 652 653 SUBROUTINE print_version_info() 654 655 write(*,*) '=== Compilation details ===' 656 write(*,*) 'Date: ${current_date}' 657 write(*,*) 'Command: ${compilation_command}' 658 write(*,*) 659 EOF 660 661 if [ "$vcs" == "svn" ]; then # SVN info 662 echo " write(*,*) '===== SVN Information ====='" >> "$info_file" 663 while IFS= read -r line; do 664 echo " write(*,*) '${line//\"/\\\"}'" >> "$info_file" 665 done <<< "$vcs_info" 666 echo " write(*,*)" >> "$info_file" 667 echo " write(*,*) '======== SVN Diff ========='" >> "$info_file" 668 echo " write(*,*) 'Writing SVN diff to file: ${diff_file}'" >> "$info_file" 669 echo " open(unit = 1,file = \"${diff_file}\",status = 'replace')" >> "$info_file" 670 while IFS= read -r line; do 671 escaped_line=$(escape_signs "$line") 672 echo " write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file" 673 done <<< "$vcs_diff" 674 echo " close(1)" >> "$info_file" 675 676 677 elif [ "$vcs" == "git" ]; then # Git info 678 echo " write(*,*) '===== Git Information ====='" >> "$info_file" 679 while IFS= read -r line; do 680 echo " write(*,*) \"${line//\"/\\\"}\"" >> "$info_file" 681 done <<< "$vcs_info" 682 echo " write(*,*)" >> "$info_file" 683 echo " write(*,*) '======== Git Diff ========='" >> "$info_file" 684 echo " write(*,*) 'Writing Git diff to file: ${diff_file}'" >> "$info_file" 685 while IFS= read -r line; do 686 escaped_line=$(escape_signs "$line") 687 echo " write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file" 688 done <<< "$vcs_diff" 689 echo " close(1)" >> "$info_file" 690 else # Non-versioned code 691 echo " write(*,*) 'No version control information available.'" >> "$info_file" 692 fi 693 echo " write(*,*) '==========================='" >> "$info_file" 694 695 cat << EOF >> "$info_file" 696 697 END SUBROUTINE print_version_info 698 699 END MODULE version_info_mod 700 EOF 701 702 # Termination message 703 echo "'$info_file' has been successfully generated." 590 704 591 705 -
trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90
r3335 r3574 22 22 use dimphy, only : init_dimphy 23 23 use gases_h, only: ngasmx 24 use version_info_mod, only: print_version_info 24 25 25 26 implicit none … … 109 110 integer :: ios 110 111 integer :: k 112 113 character(100) :: arg ! To read command-line arguments 111 114 112 115 ! -------------- 113 116 ! Initialisation 114 117 ! -------------- 118 if (command_argument_count() > 0) then ! Get the number of command-line arguments 119 call get_command_argument(1,arg) ! Read the argument given to the program 120 select case (trim(adjustl(arg))) 121 case('version') 122 call print_version_info() 123 stop 124 case default 125 error stop 'The argument given to the program is unknown!' 126 end select 127 endif 115 128 116 129 pi=2.E+0*asin(1.E+0) -
trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F
r3562 r3574 43 43 & nf90_strerror,NF90_INQ_VARID, NF90_GET_VAR, 44 44 & NF90_CLOSE 45 use version_info_mod, only: print_version_info 46 45 47 implicit none 46 48 … … 164 166 LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def 165 167 168 character(100) :: arg ! To read command-line arguments 169 166 170 c======================================================================= 167 171 c INITIALISATION 168 172 c======================================================================= 173 if (command_argument_count() > 0) then ! Get the number of command-line arguments 174 call get_command_argument(1,arg) ! Read the argument given to the program 175 select case (trim(adjustl(arg))) 176 case('version') 177 call print_version_info() 178 stop 179 case default 180 error stop 'The argument given to the program is ' 181 &//'unknown!' 182 end select 183 endif 184 169 185 ! check if 'rcm1d.def' file is around 170 186 open(90,file='rcm1d.def',status='old',form='formatted', -
trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F
r3336 r3574 61 61 & ini_paleoclimate_h, end_paleoclimate_h 62 62 use subslope_mola_mod, ONLY: subslope_mola 63 use version_info_mod, only: print_version_info 63 64 64 65 implicit none … … 81 82 c et autres: 82 83 c---------- 84 character(100) :: arg ! To read command-line arguments 83 85 84 86 c Variables pour les lectures NetCDF des fichiers "start_archive" … … 211 213 212 214 215 216 if (command_argument_count() > 0) then ! Get the number of command-line arguments 217 call get_command_argument(1,arg) ! Read the argument given to the program 218 select case (trim(adjustl(arg))) 219 case('version') 220 call print_version_info() 221 stop 222 case default 223 error stop 'The argument given to the program is unknown!' 224 end select 225 endif 213 226 214 227 c sortie visu pour les champs dynamiques -
trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F
r3491 r3574 41 41 USE surfdat_h, ONLY: phisfi, albedodat, z0, z0_default, 42 42 & zmea, zstd, zsig, zgam, zthe, hmons, summit, base 43 use version_info_mod, only: print_version_info 44 43 45 implicit none 44 46 … … 141 143 integer :: nq,numvanle 142 144 character(len=30) :: txt ! to store some text 145 character(100) :: arg ! To read command-line arguments 143 146 144 147 c Netcdf … … 150 153 C here we assume and check that if there is an argument #1 then 151 154 C it should be --add-sso to signal adding SSO fileds to start_archive.nc 152 153 155 CALL get_command_argument(1,txt,j,ierr) 154 156 ! will return ierr==0 if there is an argument #1 to command line … … 158 160 add_sso_fields=.true. 159 161 write(*,*) "SSO fields will be included in start_archive" 162 ELSE IF (trim(txt) == 'version') then 163 call print_version_info() 164 stop 160 165 ELSE 161 166 write(*,*) "start2archive error: unexpected command line "// -
trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90
r3400 r3574 21 21 use mod_const_mpi, only: init_const_mpi 22 22 use parallel_lmdz, only: init_parallel 23 use version_info_mod, only: print_version_info 23 24 24 25 implicit none … … 77 78 real, dimension(:,:,:), allocatable :: q ! tracer mixing ratio (e.g. kg/kg) 78 79 real, dimension(1) :: wstar = 0. ! Thermals vertical velocity 80 character(100) :: arg ! To read command-line arguments 79 81 80 82 ! Physical and dynamical tendencies (e.g. m.s-2, K/s, Pa/s) … … 100 102 ! INITIALISATION 101 103 !======================================================================= 104 if (command_argument_count() > 0) then ! Get the number of command-line arguments 105 call get_command_argument(1,arg) ! Read the argument given to the program 106 select case (trim(adjustl(arg))) 107 case('version') 108 call print_version_info() 109 stop 110 case default 111 error stop 'The argument given to the program is unknown!' 112 end select 113 endif 114 102 115 #ifdef CPP_XIOS 103 116 call init_const_mpi
Note: See TracChangeset
for help on using the changeset viewer.