Changeset 3574 for trunk/LMDZ.COMMON/makelmdz_fcm
- Timestamp:
- Jan 13, 2025, 4:52:20 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.