Index: trunk/LMDZ.COMMON/makelmdz_fcm
===================================================================
--- trunk/LMDZ.COMMON/makelmdz_fcm	(revision 3830)
+++ trunk/LMDZ.COMMON/makelmdz_fcm	(revision 3836)
@@ -603,8 +603,8 @@
 
 # Path and name of the generated file
-info_file="$LIBFGCM/misc/version_info.F90"
-
-# Path and name of the file containing the difference result
-res_file="pgrm_version_details.txt"
+version_F90file="$LIBFGCM/misc/pgrm_version.F90"
+
+# Path and name of the file containing the compilation and version details
+default_out_file="pgrm_version_details.txt"
 
 # Get the current date
@@ -653,12 +653,13 @@
 
 # Generate the Fortran subroutine
-cat << EOF > "$info_file"
+cat << EOF > "$version_F90file"
+MODULE pgrm_version_mod
+
 !***********************************************************************
 ! File generated automatically at compilation
 !
 ! DESCRIPTION:
-!    The subroutine 'print_version_info' prints compilation details, the
-!    version control information (SVN or Git), the status and the diff
-!    result if applicable.
+!    The subroutine 'print_pgrm_version' prints compilation details, the version
+!    control information (SVN or Git), the status and the diff result if applicable.
 !
 ! PARAMETERS:
@@ -666,10 +667,15 @@
 !
 ! 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.
+!    Use the command-line option "--version [file]" when running your program:
+!       ./myprogram --version [file]
+!    This will write compilation and version details into the specified [file].
+!    If [file] is omitted, the default name "pgrm_version_details.txt" will be used.
+!    This feature helps track code builds and their exact compilation context
+!    directly from the executable.
 !***********************************************************************
 
-MODULE version_info_mod
+implicit none
+
+character(*), parameter :: default_out_file = "${default_out_file}"
 
 !=======================================================================
@@ -677,13 +683,26 @@
 !=======================================================================
 
-SUBROUTINE print_version_info()
-
-integer, parameter :: io_unit = 10
-
-open(io_unit, file = '${res_file}',status = 'replace',action = 'write')
-
-write(*,'(a)') '-> Writing compilation details to the file "${res_file}".'
+SUBROUTINE print_pgrm_version(user_out_file)
+
+!---- Arguments
+character(*), optional, intent(in) :: user_out_file
+
+!---- Variables
+integer, parameter        :: io_unit = 10
+character(:), allocatable :: out_file
+
+!---- Code
+if (present(user_out_file)) then
+    out_file = trim(adjustl(user_out_file))
+else
+    out_file = trim(adjustl(default_out_file))
+endif
+
+open(io_unit,file = out_file,status = 'replace',action = 'write')
+
+write(*,*)
+write(*,'(a)') '-> Writing compilation details to the file "'//out_file//'".'
 write(io_unit,'(a)') '========================= COMPILATION DETAILS =========================='
-write(io_unit,'(a)') '-> Date: ${current_date}'
+write(io_unit,'(a)') '-> Date   : ${current_date}'
 write(io_unit,'(a)') '-> Command: ${compilation_command}'
 write(io_unit,*)
@@ -691,43 +710,44 @@
 
 if [ -n "$vcs_info" ]; then
-    echo "write(*,'(a)') '-> Writing information result to the file \"${res_file}\".'" >> "$info_file"
-    echo "write(io_unit,'(a)') '===================== VERSION CONTROL INFORMATION ======================'" >> "$info_file"
+    echo "write(*,'(a)') '-> Writing information result to the file \"'//out_file//'\".'" >> "$version_F90file"
+    echo "write(io_unit,'(a)') '===================== VERSION CONTROL INFORMATION ======================'" >> "$version_F90file"
     while IFS= read -r line; do
-        echo "write(io_unit,'(a)') '${line}'" >> "$info_file"
+        echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file"
     done <<< "$(echo -e "$vcs_info")"
 else
-    echo "write(io_unit,'(a)') '====================== NO VERSION CONTROL SYSTEM ======================='" >> "$info_file"
+    echo "write(io_unit,'(a)') '====================== NO VERSION CONTROL SYSTEM ======================='" >> "$version_F90file"
 fi
 
 if [ -n "$vcs_stat" ]; then
-    echo "write(*,'(a)') '-> Writing status result to the file \"${res_file}\".'" >> "$info_file"
-    echo "write(io_unit,*)" >> "$info_file"
-    echo "write(io_unit,'(a)') '======================== VERSION CONTROL STATUS ========================'" >> "$info_file"
+    echo "write(*,'(a)') '-> Writing status result to the file \"'//out_file//'\".'" >> "$version_F90file"
+    echo "write(io_unit,*)" >> "$version_F90file"
+    echo "write(io_unit,'(a)') '======================== VERSION CONTROL STATUS ========================'" >> "$version_F90file"
     while IFS= read -r line; do
-        echo "write(io_unit,'(a)') '${line}'" >> "$info_file"
+        echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file"
     done <<< "$(echo -e "$vcs_stat")"
 fi
 
 if [ -n "$vcs_diff" ]; then
-    echo "write(*,'(a)') '-> Writing diff result to the file \"${res_file}\".'" >> "$info_file"
-    echo "write(io_unit,*)" >> "$info_file"
-    echo "write(io_unit,'(a)') '========================= VERSION CONTROL DIFF ========================='" >> "$info_file"
+    echo "write(*,'(a)') '-> Writing diff result to the file \"'//out_file//'\".'" >> "$version_F90file"
+    echo "write(io_unit,*)" >> "$version_F90file"
+    echo "write(io_unit,'(a)') '========================= VERSION CONTROL DIFF ========================='" >> "$version_F90file"
     while IFS= read -r line; do
-        echo "write(io_unit,'(a)') '${line}'" >> "$info_file"
+        echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file"
     done <<< "$(echo -e "$vcs_diff")"
 fi
 
-cat << EOF >> "$info_file"
+cat << EOF >> "$version_F90file"
 write(io_unit,'(a)') '========================================================================'
+write(*,*)
 
 close(io_unit)
 
-END SUBROUTINE print_version_info
-
-END MODULE version_info_mod
+END SUBROUTINE print_pgrm_version
+
+END MODULE pgrm_version_mod
 EOF
 
 # Termination message
-echo "'$info_file' has been generated successfully."
+echo "'$version_F90file' has been generated successfully."
 
 
