Changeset 3836 for trunk/LMDZ.COMMON
- Timestamp:
- Jul 7, 2025, 2:46:43 PM (4 weeks ago)
- Location:
- trunk/LMDZ.COMMON
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90
r3615 r3836 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_info32 use parse_args_mod, only: parse_args 33 33 34 34 … … 134 134 character (len=20) :: modname 135 135 character (len=80) :: abort_message 136 character(100) :: arg ! To read command-line arguments137 136 ! locales pour gestion du temps 138 137 INTEGER :: an, mois, jour … … 144 143 ! Initialisations: 145 144 ! ---------------- 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 145 ! Parse command-line options 146 call parse_args() 157 147 158 148 abort_message = 'last timestep reached' -
trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
r3615 r3836 27 27 & ecritstart 28 28 use cpdet_mod, only: ini_cpdet 29 use version_info_mod, only: print_version_info29 use parse_args_mod, only: parse_args 30 30 31 31 … … 135 135 character (len=20) :: modname 136 136 character (len=80) :: abort_message 137 character(100) :: arg ! To read command-line arguments138 137 ! locales pour gestion du temps 139 138 INTEGER :: an, mois, jour … … 158 157 c Initialisations: 159 158 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 is ' 169 &//'unknown!' 170 end select 171 endif 159 ! Parse command-line options 160 call parse_args() 172 161 173 162 abort_message = 'last timestep reached' -
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3809 r3836 73 73 print_layering 74 74 use dyn_ss_ice_m_mod, only: dyn_ss_ice_m 75 use version_info_mod, only: print_version_info 75 use parse_args_mod, only: parse_args 76 use job_timelimit_mod, only: timelimit, antetime, timewall 76 77 use paleoclimate_mod, only: h2o_ice_depth, zdqsdif_ssi_tot 77 78 … … 241 242 real :: n_myear ! Maximum number of Martian years of the chained simulations 242 243 real :: timestep ! Timestep [s] 243 character(100) :: arg ! To read command-line arguments program was invoked244 logical :: timewall ! Flag to use the time limit stopping criterion in case of a PEM job245 244 integer(kind = 8) :: cr ! Number of clock ticks per second (count rate) 246 245 integer(kind = 8) :: c1, c2 ! Counts of processor clock 247 character(100) :: chtimelimit ! Time limit for the PEM job outputted by the SLURM command248 real :: timelimit ! Time limit for the PEM job in seconds249 real, parameter :: antetime = 3600 ! Anticipation time to prevent reaching the job time limit: 3600 s by default (it should cover the computing time of the reshaping tool)250 integer :: cstat, days, hours, minutes, seconds251 character(1) :: sep252 246 character(8) :: date 253 247 character(10) :: time … … 313 307 call system_clock(count_rate = cr) 314 308 call system_clock(c1) 315 timewall = .true. 316 timelimit = 86400 ! 86400 seconds = 24 h by default 317 if (command_argument_count() > 0) then ! Get the number of command-line arguments 318 call get_command_argument(1,arg) ! Read the argument given to the program 319 num_str = .true. 320 do i = 1,len_trim(arg) 321 if (arg(i:i) < '0' .or. arg(i:i) > '9') then 322 num_str = .false. 323 exit 324 endif 325 enddo 326 327 if (num_str) then ! This is a numeric sting so we considerer this is the job id 328 ! Execute the system command 329 call execute_command_line('squeue -j '//trim(adjustl(arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat) 330 if (cstat /= 0) then 331 call execute_command_line('qstat -f '//trim(adjustl(arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat) 332 if (cstat > 0) then 333 error stop 'pem: command execution failed!' 334 else if (cstat < 0) then 335 error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!' 336 endif 337 endif 338 ! Read the output 339 open(1,file = 'tmp_cmdout.txt',status = 'old') 340 read(1,'(a)') chtimelimit 341 close(1) 342 chtimelimit = trim(adjustl(chtimelimit)) 343 call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat) 344 if (cstat > 0) then 345 error stop 'pem: command execution failed!' 346 else if (cstat < 0) then 347 error stop 'pem: command execution not supported!' 348 endif 349 if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS" 350 read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds 351 timelimit = days*86400 + hours*3600 + minutes*60 + seconds 352 else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS" 353 read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds 354 timelimit = hours*3600 + minutes*60 + seconds 355 else ! 'chtimelimit' format is "MM:SS" 356 read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds 357 timelimit = minutes*60 + seconds 358 endif 359 else ! Arg is not a numeric string 360 select case (trim(adjustl(arg))) 361 case('version') ! Handle command‐line argument "version" 362 call print_version_info() 363 stop 364 case default 365 error stop "The argument given to the program is unknown!" 366 end select 367 endif 368 else 369 timewall = .false. 370 endif 309 call parse_args() 371 310 372 311 ! Some user info -
trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90
r3786 r3836 11 11 12 12 use netcdf 13 use version_info_mod, only: print_version_info13 use parse_args_mod, only: parse_args 14 14 15 15 implicit none … … 39 39 integer :: i, j, k 40 40 integer :: numDimsVar, numAttsVar 41 character(100) :: varName , arg41 character(100) :: varName 42 42 integer :: xtypeVar 43 43 integer, allocatable, dimension(:) :: dimids_var_in … … 72 72 73 73 ! CODE 74 ! Handle command‐line argument "version" 75 if (command_argument_count() > 0) then ! Get the number of command-line arguments 76 call get_command_argument(1,arg) ! Read the argument given to the program 77 select case (trim(adjustl(arg))) 78 case('version') 79 call print_version_info() 80 stop 81 case default 82 error stop 'The argument given to the program is unknown!' 83 end select 84 endif 74 ! Parse command-line options 75 call parse_args() 85 76 86 77 ! Main loop: two PCM years -
trunk/LMDZ.COMMON/makelmdz_fcm
r3830 r3836 603 603 604 604 # Path and name of the generated file 605 info_file="$LIBFGCM/misc/version_info.F90"606 607 # Path and name of the file containing the difference result608 res_file="pgrm_version_details.txt"605 version_F90file="$LIBFGCM/misc/pgrm_version.F90" 606 607 # Path and name of the file containing the compilation and version details 608 default_out_file="pgrm_version_details.txt" 609 609 610 610 # Get the current date … … 653 653 654 654 # Generate the Fortran subroutine 655 cat << EOF > "$info_file" 655 cat << EOF > "$version_F90file" 656 MODULE pgrm_version_mod 657 656 658 !*********************************************************************** 657 659 ! File generated automatically at compilation 658 660 ! 659 661 ! DESCRIPTION: 660 ! The subroutine 'print_version_info' prints compilation details, the 661 ! version control information (SVN or Git), the status and the diff 662 ! result if applicable. 662 ! The subroutine 'print_pgrm_version' prints compilation details, the version 663 ! control information (SVN or Git), the status and the diff result if applicable. 663 664 ! 664 665 ! PARAMETERS: … … 666 667 ! 667 668 ! USAGE: 668 ! Put the argument 'version' as an option when executing the code to 669 ! display compilation and version details. It is useful for tracking 670 ! code builds through the executable file. 669 ! Use the command-line option "--version [file]" when running your program: 670 ! ./myprogram --version [file] 671 ! This will write compilation and version details into the specified [file]. 672 ! If [file] is omitted, the default name "pgrm_version_details.txt" will be used. 673 ! This feature helps track code builds and their exact compilation context 674 ! directly from the executable. 671 675 !*********************************************************************** 672 676 673 MODULE version_info_mod 677 implicit none 678 679 character(*), parameter :: default_out_file = "${default_out_file}" 674 680 675 681 !======================================================================= … … 677 683 !======================================================================= 678 684 679 SUBROUTINE print_version_info() 680 681 integer, parameter :: io_unit = 10 682 683 open(io_unit, file = '${res_file}',status = 'replace',action = 'write') 684 685 write(*,'(a)') '-> Writing compilation details to the file "${res_file}".' 685 SUBROUTINE print_pgrm_version(user_out_file) 686 687 !---- Arguments 688 character(*), optional, intent(in) :: user_out_file 689 690 !---- Variables 691 integer, parameter :: io_unit = 10 692 character(:), allocatable :: out_file 693 694 !---- Code 695 if (present(user_out_file)) then 696 out_file = trim(adjustl(user_out_file)) 697 else 698 out_file = trim(adjustl(default_out_file)) 699 endif 700 701 open(io_unit,file = out_file,status = 'replace',action = 'write') 702 703 write(*,*) 704 write(*,'(a)') '-> Writing compilation details to the file "'//out_file//'".' 686 705 write(io_unit,'(a)') '========================= COMPILATION DETAILS ==========================' 687 write(io_unit,'(a)') '-> Date : ${current_date}'706 write(io_unit,'(a)') '-> Date : ${current_date}' 688 707 write(io_unit,'(a)') '-> Command: ${compilation_command}' 689 708 write(io_unit,*) … … 691 710 692 711 if [ -n "$vcs_info" ]; then 693 echo "write(*,'(a)') '-> Writing information result to the file \" ${res_file}\".'" >> "$info_file"694 echo "write(io_unit,'(a)') '===================== VERSION CONTROL INFORMATION ======================'" >> "$ info_file"712 echo "write(*,'(a)') '-> Writing information result to the file \"'//out_file//'\".'" >> "$version_F90file" 713 echo "write(io_unit,'(a)') '===================== VERSION CONTROL INFORMATION ======================'" >> "$version_F90file" 695 714 while IFS= read -r line; do 696 echo "write(io_unit,'(a)') '${line}'" >> "$ info_file"715 echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" 697 716 done <<< "$(echo -e "$vcs_info")" 698 717 else 699 echo "write(io_unit,'(a)') '====================== NO VERSION CONTROL SYSTEM ======================='" >> "$ info_file"718 echo "write(io_unit,'(a)') '====================== NO VERSION CONTROL SYSTEM ======================='" >> "$version_F90file" 700 719 fi 701 720 702 721 if [ -n "$vcs_stat" ]; then 703 echo "write(*,'(a)') '-> Writing status result to the file \" ${res_file}\".'" >> "$info_file"704 echo "write(io_unit,*)" >> "$ info_file"705 echo "write(io_unit,'(a)') '======================== VERSION CONTROL STATUS ========================'" >> "$ info_file"722 echo "write(*,'(a)') '-> Writing status result to the file \"'//out_file//'\".'" >> "$version_F90file" 723 echo "write(io_unit,*)" >> "$version_F90file" 724 echo "write(io_unit,'(a)') '======================== VERSION CONTROL STATUS ========================'" >> "$version_F90file" 706 725 while IFS= read -r line; do 707 echo "write(io_unit,'(a)') '${line}'" >> "$ info_file"726 echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" 708 727 done <<< "$(echo -e "$vcs_stat")" 709 728 fi 710 729 711 730 if [ -n "$vcs_diff" ]; then 712 echo "write(*,'(a)') '-> Writing diff result to the file \" ${res_file}\".'" >> "$info_file"713 echo "write(io_unit,*)" >> "$ info_file"714 echo "write(io_unit,'(a)') '========================= VERSION CONTROL DIFF ========================='" >> "$ info_file"731 echo "write(*,'(a)') '-> Writing diff result to the file \"'//out_file//'\".'" >> "$version_F90file" 732 echo "write(io_unit,*)" >> "$version_F90file" 733 echo "write(io_unit,'(a)') '========================= VERSION CONTROL DIFF ========================='" >> "$version_F90file" 715 734 while IFS= read -r line; do 716 echo "write(io_unit,'(a)') '${line}'" >> "$ info_file"735 echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" 717 736 done <<< "$(echo -e "$vcs_diff")" 718 737 fi 719 738 720 cat << EOF >> "$ info_file"739 cat << EOF >> "$version_F90file" 721 740 write(io_unit,'(a)') '========================================================================' 741 write(*,*) 722 742 723 743 close(io_unit) 724 744 725 END SUBROUTINE print_ version_info726 727 END MODULE version_info_mod745 END SUBROUTINE print_pgrm_version 746 747 END MODULE pgrm_version_mod 728 748 EOF 729 749 730 750 # Termination message 731 echo "'$ info_file' has been generated successfully."751 echo "'$version_F90file' has been generated successfully." 732 752 733 753
Note: See TracChangeset
for help on using the changeset viewer.