Index: trunk/LMDZ.COMMON/makelmdz_fcm
===================================================================
--- trunk/LMDZ.COMMON/makelmdz_fcm	(revision 3499)
+++ 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."
 
 
