Index: /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 3573)
+++ /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 3574)
@@ -30,4 +30,5 @@
   USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref, &
      		itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end
+  use version_info_mod, only: print_version_info
 
 
@@ -133,4 +134,5 @@
   character (len=20) :: modname
   character (len=80) :: abort_message
+  character(100)     :: arg ! To read command-line arguments
   ! locales pour gestion du temps
   INTEGER :: an, mois, jour
@@ -142,4 +144,15 @@
 !   Initialisations:
 !   ----------------
+
+  if (command_argument_count() > 0) then ! Get the number of command-line arguments
+      call get_command_argument(1,arg) ! Read the argument given to the program
+      select case (trim(adjustl(arg)))
+          case('version')
+              call print_version_info()
+              stop
+          case default
+              error stop "The argument given to the program is unknown!"
+      end select
+  endif
 
   abort_message = 'last timestep reached'
Index: /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 3573)
+++ /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 3574)
@@ -27,4 +27,5 @@
      &                       ecritstart
       use cpdet_mod, only: ini_cpdet
+      use version_info_mod, only: print_version_info
 
 
@@ -134,4 +135,5 @@
       character (len=20) :: modname
       character (len=80) :: abort_message
+      character(100)     :: arg ! To read command-line arguments
 ! locales pour gestion du temps
       INTEGER :: an, mois, jour
@@ -156,4 +158,16 @@
 c   Initialisations:
 c   ----------------
+
+      if (command_argument_count() > 0) then ! Get the number of command-line arguments
+          call get_command_argument(1,arg) ! Read the argument given to the program
+          select case (trim(adjustl(arg)))
+              case('version')
+                  call print_version_info()
+                  stop
+              case default
+                  error stop 'The argument given to the program '
+     &//'is unknown!'
+          end select
+      endif
 
       abort_message = 'last timestep reached'
Index: /trunk/LMDZ.COMMON/libf/evolution/pem.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/pem.F90	(revision 3573)
+++ /trunk/LMDZ.COMMON/libf/evolution/pem.F90	(revision 3574)
@@ -238,5 +238,5 @@
 real            :: n_myear         ! Maximum number of Martian years of the chained simulations
 real            :: timestep        ! Timestep [s]
-character(20)   :: job_id          ! Job id provided as argument passed on the command line when the program was invoked
+character(100)  :: arg             ! To read command-line arguments program was invoked
 logical         :: timewall        ! Flag to use the time limit stopping criterion in case of a PEM job
 integer(kind=8) :: cr              ! Number of clock ticks per second (count rate)
@@ -293,40 +293,44 @@
 timewall = .true.
 timelimit = 86400 ! 86400 seconds = 24 h by default
-if (command_argument_count() > 0) then
-    ! Read the job id passed as argument to the program
-    call get_command_argument(1,job_id)
-    ! Execute the system command
-    call execute_command_line('squeue -j '//trim(job_id)//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat)
-    if (cstat /= 0) then
-        call execute_command_line('qstat -f '//trim(job_id)//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat)
-        if (cstat > 0) then
-            error stop 'pem: command execution failed!'
-        else if (cstat < 0) then
-            error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!'
-        endif
-    endif
-    ! Read the output
-    open(1,file = 'tmp_cmdout.txt',status = 'old')
-    read(1,'(a)') chtimelimit
-    close(1)
-    chtimelimit = trim(chtimelimit)
-    call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat)
-    if (cstat > 0) then
-        error stop 'pem: command execution failed!'
-    else if (cstat < 0) then
-        error stop 'pem: command execution not supported!'
-    endif
-    if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS"
-        read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds
-        timelimit = days*86400 + hours*3600 + minutes*60 + seconds
-    else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS"
-        read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds
-        timelimit = hours*3600 + minutes*60 + seconds
-    else ! 'chtimelimit' format is "MM:SS"
-        read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds
-        timelimit = minutes*60 + seconds
-    endif
-else
-    timewall = .false.
+timewall = .false.
+if (command_argument_count() > 0) then ! Get the number of command-line arguments
+    call get_command_argument(1,arg) ! Read the argument given to the program
+    select case (trim(adjustl(arg)))
+        case('version')
+            call print_version_info()
+            stop
+        case default ! This is the job id
+           ! Execute the system command
+            call execute_command_line('squeue -j '//trim(adjustl(arg))//' -h --Format TimeLimit > tmp_cmdout.txt',cmdstat = cstat)
+            if (cstat /= 0) then
+                call execute_command_line('qstat -f '//trim(adjustl(arg))//' | grep "Walltime" | awk ''{print $3}'' > tmp_cmdout.txt',cmdstat = cstat)
+                if (cstat > 0) then
+                    error stop 'pem: command execution failed!'
+                else if (cstat < 0) then
+                    error stop 'pem: command execution not supported (neither SLURM nor PBS/TORQUE is installed)!'
+                endif
+            endif
+            ! Read the output
+            open(1,file = 'tmp_cmdout.txt',status = 'old')
+            read(1,'(a)') chtimelimit
+            close(1)
+            chtimelimit = trim(adjustl(chtimelimit))
+            call execute_command_line('rm tmp_cmdout.txt',cmdstat = cstat)
+            if (cstat > 0) then
+                error stop 'pem: command execution failed!'
+            else if (cstat < 0) then
+                error stop 'pem: command execution not supported!'
+            endif
+            if (index(chtimelimit,'-') > 0) then ! 'chtimelimit' format is "D-HH:MM:SS"
+                read(chtimelimit,'(i1,a1,i2,a1,i2,a1,i2)') days, sep, hours, sep, minutes, sep, seconds
+                timelimit = days*86400 + hours*3600 + minutes*60 + seconds
+            else if (index(chtimelimit,':') > 0 .and. len_trim(chtimelimit) > 5) then ! 'chtimelimit' format is "HH:MM:SS"
+                read(chtimelimit,'(i2,a1,i2,a1,i2)') hours, sep, minutes, sep, seconds
+                timelimit = hours*3600 + minutes*60 + seconds
+            else ! 'chtimelimit' format is "MM:SS"
+                read(chtimelimit,'(i2,a1,i2)') minutes, sep, seconds
+                timelimit = minutes*60 + seconds
+            endif
+    end select
 endif
 
Index: /trunk/LMDZ.COMMON/makelmdz_fcm
===================================================================
--- /trunk/LMDZ.COMMON/makelmdz_fcm	(revision 3573)
+++ /trunk/LMDZ.COMMON/makelmdz_fcm	(revision 3574)
@@ -78,4 +78,8 @@
 ########################################################################
 
+# Get the compilation command
+compilation_command="$(basename $0) $@"
+
+# Parse arguments and capture options
 while (($# > 0))
   do
@@ -120,67 +124,67 @@
  exec                      : executable to build
 fin
-	  exit;;
+      exit;;
 
       "-d")
-	  dim=$2 ; shift ; shift ;;
+      dim=$2 ; shift ; shift ;;
 
       "-p")
-	  physique="$2" ;  shift ; shift ;;
+      physique="$2" ;  shift ; shift ;;
 
       "-s")
-	  scatterers=$2 ; shift ; shift ;;
+      scatterers=$2 ; shift ; shift ;;
 
       "-b")
-	  bands=$2 ; shift ; shift ;;
+      bands=$2 ; shift ; shift ;;
 
       "-g")
-	  grille="$2" ; shift ; shift ;;
+      grille="$2" ; shift ; shift ;;
 
       "-c")
-	  couple="$2" ; shift ; shift ;;
+      couple="$2" ; shift ; shift ;;
 
       "-prod")
-	  compil_mod="prod" ; shift ;;
+      compil_mod="prod" ; shift ;;
 
       "-dev")
-	  compil_mod="dev" ; shift ;;
+      compil_mod="dev" ; shift ;;
 
       "-debug")
-	  compil_mod="debug" ; shift ;;
+      compil_mod="debug" ; shift ;;
 
       "-io")
-	  io="$2" ; shift ; shift ;;
+      io="$2" ; shift ; shift ;;
 
       "-v")
-	  veget="$2" ; shift ; shift ;;
+      veget="$2" ; shift ; shift ;;
 
       "-sisvat")
-	  sisvat="$2" ; shift ; shift ;;
+      sisvat="$2" ; shift ; shift ;;
 
       "-rrtm")
-	  rrtm="$2" ; shift ; shift ;;
+      rrtm="$2" ; shift ; shift ;;
 
       "-dust")
-	  dust="$2" ; shift ; shift ;;
+      dust="$2" ; shift ; shift ;;
 
       "-strataer")
-	  strataer="$2" ; shift ; shift ;;
+      strataer="$2" ; shift ; shift ;;
 
       "-chimie")
-	  chimie="$2" ; shift ; shift ;;
+      chimie="$2" ; shift ; shift ;;
 
       "-parallel")
-	  parallel="$2" ; shift ; shift ;;
+      parallel="$2" ; shift ; shift ;;
 
       "-include")
-	  INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;;
+      INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;;
 
       "-cpp")
-	  CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
+      CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
 
       "-adjnt")
-	  echo "not operational ... work to be done here ";exit 1
-	  opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
-	  optim="$optim -Dadj" ; shift ;;
+      echo "not operational ... work to be done here ";exit 1
+      opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
+      optim="$optim -Dadj" ; shift ;;
 
       "-cosp")
@@ -191,32 +195,32 @@
 
       "-filtre")
-	  filtre=$2 ; shift ; shift ;;
+      filtre=$2 ; shift ; shift ;;
 
       "-link")
-	  LIB="$LIB $2" ; shift ; shift ;;
+      LIB="$LIB $2" ; shift ; shift ;;
 
       "-fcm_path")
-	  fcm_path=$2 ; shift ; shift ;;
+      fcm_path=$2 ; shift ; shift ;;
 
       "-ext_src")
-	  EXT_SRC=$2 ; shift ; shift ;;
+      EXT_SRC=$2 ; shift ; shift ;;
 
       "-j")
-	  job=$2 ; shift ; shift ;;
+      job=$2 ; shift ; shift ;;
 
       "-full")
-	  full="-full" ; shift ;;
+      full="-full" ; shift ;;
 
       "-libphy")
-	  libphy="true" ; shift ;;
+      libphy="true" ; shift ;;
 
       "-arch")
-	  arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
+      arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
 
       "-arch_path")
-	  arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
+      arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
 
       *)
-	  code="$1" ; shift ;;
+      code="$1" ; shift ;;
   esac
 done
@@ -333,13 +337,13 @@
     if [[ "$couple" == "MPI1" ]]
     then
-	CPP_KEY="$CPP_KEY CPP_COUPLE"
-	export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
-	export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
-	INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
-	LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
+    CPP_KEY="$CPP_KEY CPP_COUPLE"
+    export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
+    export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
+    INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
+    LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
     else
-	CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
-	INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
-	LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
+    CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
+    INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
+    LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
     fi
 fi
@@ -588,4 +592,114 @@
   fi
 fi
+
+
+########################################################################
+# Generation of a Fortran subroutine to track compilation and version
+# details through the executable file
+########################################################################
+
+# Path and name of the generated file
+info_file="$LIBFGCM/misc/version_info.F90"
+
+# Path and name of the file containing the difference result
+diff_file="version_diff.txt"
+
+# Get the current date
+current_date=$(date)
+
+# Determine version control system (SVN, Git or none)
+if command -v svn > /dev/null && svn info > /dev/null 2>&1; then
+    vcs="svn"
+    vcs_info=$(svn info $LMDGCM/..)
+    vcs_diff=$(svn diff $LMDGCM/..)
+elif command -v git > /dev/null && git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
+    vcs="git"
+    vcs_info=$(git log -1 --pretty=format:"%H%n%an%n%ad%n%s" $LMDGCM/..)
+    vcs_diff=$(git diff $LMDGCM/..)
+else
+    vcs="none"
+fi
+
+# Function to escape the simple quotation sign
+escape_signs() {
+    echo "$1" | sed "s/'/''/g"
+}
+
+# Generate the Fortran subroutine
+cat << EOF > "$info_file"
+!***********************************************************************
+! File generated automatically at compilation
+!
+! DESCRIPTION:
+!    The subroutine 'print_version_info' prints compilation details, the
+!    version control information (SVN or Git) and the diff result if
+!    applicable.
+!
+! PARAMETERS:
+!    None.
+!
+! USAGE:
+!    Put the argument 'version' as an option when executing the code to
+!    display compilation and version details. It is useful for tracking
+!    code builds through the executable file.
+!***********************************************************************
+
+MODULE version_info_mod
+
+!=======================================================================
+contains
+!=======================================================================
+
+SUBROUTINE print_version_info()
+
+    write(*,*) '=== Compilation details ==='
+    write(*,*) 'Date: ${current_date}'
+    write(*,*) 'Command: ${compilation_command}'
+    write(*,*)
+EOF
+
+if [ "$vcs" == "svn" ]; then # SVN info
+    echo "    write(*,*) '===== SVN Information ====='" >> "$info_file"
+    while IFS= read -r line; do
+        echo "    write(*,*) '${line//\"/\\\"}'" >> "$info_file"
+    done <<< "$vcs_info"
+    echo "    write(*,*)" >> "$info_file"
+    echo "    write(*,*) '======== SVN Diff ========='" >> "$info_file"
+    echo "    write(*,*) 'Writing SVN diff to file: ${diff_file}'" >> "$info_file"
+    echo "    open(unit = 1,file = \"${diff_file}\",status = 'replace')" >> "$info_file"
+    while IFS= read -r line; do
+        escaped_line=$(escape_signs "$line")
+        echo "    write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file"
+    done <<< "$vcs_diff"
+    echo "    close(1)" >> "$info_file"
+
+
+elif [ "$vcs" == "git" ]; then # Git info
+    echo "    write(*,*) '===== Git Information ====='" >> "$info_file"
+    while IFS= read -r line; do
+        echo "    write(*,*) \"${line//\"/\\\"}\"" >> "$info_file"
+    done <<< "$vcs_info"
+    echo "    write(*,*)" >> "$info_file"
+    echo "    write(*,*) '======== Git Diff ========='" >> "$info_file"
+    echo "    write(*,*) 'Writing Git diff to file: ${diff_file}'" >> "$info_file"
+    while IFS= read -r line; do
+        escaped_line=$(escape_signs "$line")
+        echo "    write(1,*) '${escaped_line//\"/\\\"}'" >> "$info_file"
+    done <<< "$vcs_diff"
+    echo "    close(1)" >> "$info_file"
+else # Non-versioned code
+    echo "    write(*,*) 'No version control information available.'" >> "$info_file"
+fi
+    echo "    write(*,*) '==========================='" >> "$info_file"
+
+cat << EOF >> "$info_file"
+
+END SUBROUTINE print_version_info
+
+END MODULE version_info_mod
+EOF
+
+# Termination message
+echo "'$info_file' has been successfully generated."
 
 
Index: /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 3573)
+++ /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 3574)
@@ -22,4 +22,5 @@
   use dimphy, only : init_dimphy
   use gases_h, only: ngasmx
+  use version_info_mod, only: print_version_info
 
   implicit none
@@ -109,8 +110,20 @@
   integer :: ios
   integer :: k
+
+  character(100) :: arg ! To read command-line arguments
   
   ! --------------
   ! Initialisation
   ! --------------
+  if (command_argument_count() > 0) then ! Get the number of command-line arguments
+      call get_command_argument(1,arg) ! Read the argument given to the program
+      select case (trim(adjustl(arg)))
+          case('version')
+              call print_version_info()
+              stop
+          case default
+              error stop 'The argument given to the program is unknown!'
+      end select
+  endif
 
   pi=2.E+0*asin(1.E+0)
Index: /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 3573)
+++ /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 3574)
@@ -43,4 +43,6 @@
      &                  nf90_strerror,NF90_INQ_VARID, NF90_GET_VAR,
      &                  NF90_CLOSE
+      use version_info_mod, only: print_version_info
+
       implicit none
 
@@ -164,7 +166,21 @@
       LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
 
+      character(100) :: arg ! To read command-line arguments
+
 c=======================================================================
 c INITIALISATION
 c=======================================================================
+      if (command_argument_count() > 0) then ! Get the number of command-line arguments
+          call get_command_argument(1,arg) ! Read the argument given to the program
+          select case (trim(adjustl(arg)))
+              case('version')
+                  call print_version_info()
+                  stop
+              case default
+                  error stop 'The argument given to the program is '
+     &//'unknown!'
+          end select
+      endif
+
 ! check if 'rcm1d.def' file is around 
       open(90,file='rcm1d.def',status='old',form='formatted',
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 3573)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 3574)
@@ -61,4 +61,5 @@
      &             ini_paleoclimate_h, end_paleoclimate_h
       use subslope_mola_mod, ONLY: subslope_mola
+      use version_info_mod, only: print_version_info
       
       implicit none
@@ -81,4 +82,5 @@
 c et autres:
 c----------
+      character(100) :: arg ! To read command-line arguments
 
 c Variables pour les lectures NetCDF des fichiers "start_archive" 
@@ -211,4 +213,15 @@
 
 
+
+if (command_argument_count() > 0) then ! Get the number of command-line arguments
+    call get_command_argument(1,arg) ! Read the argument given to the program
+    select case (trim(adjustl(arg)))
+        case('version')
+            call print_version_info()
+            stop
+        case default
+            error stop 'The argument given to the program is unknown!'
+    end select
+endif
 
 c sortie visu pour les champs dynamiques
Index: /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F	(revision 3573)
+++ /trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/start2archive.F	(revision 3574)
@@ -41,4 +41,6 @@
       USE surfdat_h, ONLY: phisfi, albedodat, z0, z0_default,
      &    zmea, zstd, zsig, zgam, zthe, hmons, summit, base
+      use version_info_mod, only: print_version_info
+
       implicit none
 
@@ -141,4 +143,5 @@
       integer :: nq,numvanle
       character(len=30) :: txt ! to store some text
+      character(100) :: arg ! To read command-line arguments
 
 c Netcdf
@@ -150,5 +153,4 @@
 C here we assume and check that if there is an argument #1 then
 C it should be --add-sso to signal adding SSO fileds to start_archive.nc
-
       CALL get_command_argument(1,txt,j,ierr)
       ! will return ierr==0 if there is an argument #1 to command line
@@ -158,4 +160,7 @@
           add_sso_fields=.true.
           write(*,*) "SSO fields will be included in start_archive"
+        ELSE IF (trim(txt) == 'version') then
+            call print_version_info()
+            stop
         ELSE
           write(*,*) "start2archive error: unexpected command line "//
Index: /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3573)
+++ /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3574)
@@ -21,4 +21,5 @@
 use mod_const_mpi,       only: init_const_mpi
 use parallel_lmdz,       only: init_parallel
+use version_info_mod,    only: print_version_info
 
 implicit none
@@ -77,4 +78,5 @@
 real, dimension(:,:,:), allocatable :: q             ! tracer mixing ratio (e.g. kg/kg)
 real, dimension(1)                  :: wstar = 0.    ! Thermals vertical velocity
+character(100)                      :: arg           ! To read command-line arguments
 
 ! Physical and dynamical tendencies (e.g. m.s-2, K/s, Pa/s)
@@ -100,4 +102,15 @@
 ! INITIALISATION
 !=======================================================================
+if (command_argument_count() > 0) then ! Get the number of command-line arguments
+    call get_command_argument(1,arg) ! Read the argument given to the program
+    select case (trim(adjustl(arg)))
+        case('version')
+            call print_version_info()
+            stop
+        case default
+            error stop 'The argument given to the program is unknown!'
+    end select
+endif
+
 #ifdef CPP_XIOS
     call init_const_mpi
