Changeset 3576 for trunk


Ignore:
Timestamp:
Jan 14, 2025, 4:05:38 PM (5 months ago)
Author:
jbclement
Message:

COMMON:
Follow-up of r3574:

  • Small corrections to make it work with Git;
  • Addition of the functionality with the programs 'Generic newstart' and 'Generic start2archive';
  • Improvements of the visualization format;
  • Diplaying version control information of every sub-folder in the "trunk" instead of only the "trunk" (who can do more can do less).

JBC

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/makelmdz_fcm

    r3574 r3576  
    608608current_date=$(date)
    609609
    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
     611vcs_info=""
     612vcs_diff=""
     613for 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
     628done
    627629
    628630# Generate the Fortran subroutine
     
    653655SUBROUTINE print_version_info()
    654656
    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}'
    658660    write(*,*)
    659661EOF
    660662
    661 if [ "$vcs" == "svn" ]; then # SVN info
    662     echo "    write(*,*) '===== SVN Information ====='" >> "$info_file"
     663if [ -n "$vcs_info" ]; then
     664    echo "    write(*,'(A)') '=== Version Control Information ==='" >> "$info_file"
    663665    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")"
     668fi
     669
     670if [ -n "$vcs_diff" ]; then
    666671    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"
     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"
    670675    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")"
    674678    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"
     679fi
    694680
    695681cat << EOF >> "$info_file"
     682    write(*,'(A)') '==================================='
    696683
    697684END SUBROUTINE print_version_info
  • trunk/LMDZ.GENERIC/libf/dynphy_lonlat/phystd/newstart.F

    r3423 r3576  
    4949      use geometry_mod, only: longitude,  ! longitudes (rad)
    5050     &                         latitude,  ! latitudes (rad)                       
    51      &                         cell_area ! physics grid area (m2)                       
     51     &                         cell_area ! physics grid area (m2)
     52      use version_info_mod, only: print_version_info
     53                       
    5254      implicit none
    5355
     
    189191      real fact2
    190192
     193
     194      if (command_argument_count() > 0) then ! Get the number of command-line arguments
     195          call get_command_argument(1,txt) ! Read the argument given to the program
     196          select case (trim(adjustl(txt)))
     197              case('version')
     198                  call print_version_info()
     199                  stop
     200              case default
     201                  error stop 'The argument given to the program is '
     202     &//'unknown!'
     203          end select
     204      endif
    191205
    192206c sortie visu pour les champs dynamiques
  • trunk/LMDZ.GENERIC/libf/dynphy_lonlat/phystd/start2archive.F

    r3423 r3576  
    3939     &                          east_gwstress, west_gwstress
    4040      use exner_hyb_m, only: exner_hyb
     41      use version_info_mod, only: print_version_info
     42
    4143      implicit none
    4244
     
    146148c   Initialisations
    147149c-----------------------------------------------------------------------
     150      if (command_argument_count() > 0) then ! Get the number of command-line arguments
     151          call get_command_argument(1,txt) ! Read the argument given to the program
     152          select case (trim(adjustl(txt)))
     153              case('version')
     154                  call print_version_info()
     155                  stop
     156              case default
     157                  error stop 'The argument given to the program is '
     158     &//'unknown!'
     159          end select
     160      endif
    148161
    149162      CALL defrun_new(99, .TRUE. )
  • trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F

    r3574 r3576  
    166166      LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
    167167
    168       character(100) :: arg ! To read command-line arguments
    169 
    170168c=======================================================================
    171169c INITIALISATION
    172170c=======================================================================
    173171      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)))
     172          call get_command_argument(1,txt) ! Read the argument given to the program
     173          select case (trim(adjustl(txt)))
    176174              case('version')
    177175                  call print_version_info()
  • trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F

    r3574 r3576  
    8282c et autres:
    8383c----------
    84       character(100) :: arg ! To read command-line arguments
    8584
    8685c Variables pour les lectures NetCDF des fichiers "start_archive"
     
    215214
    216215if (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)))
     216    call get_command_argument(1,txt) ! Read the argument given to the program
     217    select case (trim(adjustl(txt)))
    219218        case('version')
    220219            call print_version_info()
  • trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F

    r3574 r3576  
    143143      integer :: nq,numvanle
    144144      character(len=30) :: txt ! to store some text
    145       character(100) :: arg ! To read command-line arguments
    146145
    147146c Netcdf
Note: See TracChangeset for help on using the changeset viewer.