Changeset 3576 for trunk/LMDZ.COMMON/makelmdz_fcm
- Timestamp:
- Jan 14, 2025, 4:05:38 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/makelmdz_fcm
r3574 r3576 608 608 current_date=$(date) 609 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 } 610 # Iterate through subdirectories in $LMDGCM/../ to determine version control system 611 vcs_info="" 612 vcs_diff="" 613 for dir in "$LMDGCM/.."/*; do 614 # Skip if it is not a directory or the name contains "git" or "svn" 615 [ -d "$dir" ] || continue 616 [[ "$dir" == *git* || "$dir" == *svn* ]] && continue 617 618 # Determine the version control system for each subdirectory 619 if command -v svn > /dev/null && svn info "$dir" > /dev/null 2>&1; then # SVN 620 vcs_info+="\n=== SVN Information for $dir ===\n$(svn info "$dir")\n" 621 vcs_diff+="\n=== SVN Diff for $dir ===\n$(svn diff "$dir")\n" 622 elif command -v git > /dev/null && git -C "$dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then # Git 623 vcs_info+="\n=== Git Information for $dir ===\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s")\n" 624 vcs_diff+="\n=== Git Diff for $dir ===\n$(git -C "$dir" diff)\n" 625 else # None 626 vcs_info+="\n=== No version control system for $dir ===\n" 627 fi 628 done 627 629 628 630 # Generate the Fortran subroutine … … 653 655 SUBROUTINE print_version_info() 654 656 655 write(*, *) '=== Compilation details==='656 write(*, *) 'Date: ${current_date}'657 write(*, *) 'Command: ${compilation_command}'657 write(*,'(A)') '======= Compilation details =======' 658 write(*,'(A)') 'Date: ${current_date}' 659 write(*,'(A)') 'Command: ${compilation_command}' 658 660 write(*,*) 659 661 EOF 660 662 661 if [ "$vcs" == "svn" ]; then # SVN info662 echo " write(*, *) '===== SVN Information ====='" >> "$info_file"663 if [ -n "$vcs_info" ]; then 664 echo " write(*,'(A)') '=== Version Control Information ==='" >> "$info_file" 663 665 while IFS= read -r line; do 664 echo " write(*,*) '${line//\"/\\\"}'" >> "$info_file" 665 done <<< "$vcs_info" 666 echo " write(*,'(A)') '${line//\'/\'\'}'" >> "$info_file" 667 done <<< "$(echo -e "$vcs_info")" 668 fi 669 670 if [ -n "$vcs_diff" ]; then 666 671 echo " write(*,*)" >> "$info_file" 667 echo " write(*, *) '======== SVN Diff ========='" >> "$info_file"668 echo " write(*, *) 'Writing SVNdiff to file: ${diff_file}'" >> "$info_file"669 echo " open(unit = 1, file = \"${diff_file}\",status = 'replace')" >> "$info_file"672 echo " write(*,'(A)') '====== Version Control Diff ======='" >> "$info_file" 673 echo " write(*,'(A)') 'Writing diff to file: ${diff_file}'" >> "$info_file" 674 echo " open(unit = 1, file = \"${diff_file}\", status = 'replace', action = 'write')" >> "$info_file" 670 675 while IFS= read -r line; do 671 escaped_line=$(escape_signs "$line") 672 echo " write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file" 673 done <<< "$vcs_diff" 676 echo " write(1,'(A)') '${line//\'/\'\'}'" >> "$info_file" 677 done <<< "$(echo -e "$vcs_diff")" 674 678 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" 679 fi 694 680 695 681 cat << EOF >> "$info_file" 682 write(*,'(A)') '===================================' 696 683 697 684 END SUBROUTINE print_version_info
Note: See TracChangeset
for help on using the changeset viewer.