Index: /trunk/LMDZ.COMMON/libf/evolution/changelog.txt
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/changelog.txt	(revision 3579)
@@ -537,2 +537,5 @@
 - Renaming of variables and subroutines to make everything clearer. In particular, the suffixes: '_avg' = average, '_start' = PCM start file, '_dev' = deviation, '_ini' or '0' = initial, '_dyn' = dynamical grid, '_timeseries' = daily average of last PCM year.
 - Cosmetic cleanings for readability.
+
+== 15/01/2025 == JBC
+Improvement of the Bash script tools in the deftank with an automatic error detection which ends the script with a message.
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job	(revision 3579)
@@ -13,5 +13,7 @@
 #SBATCH --time=10:00:00
 
-# A few parameters that might need to be changed depending on your setup
+########################################################################
+# Modify here the parameters depending on your setup
+####################################################
 # Path to the arch.env to source:
 source ../trunk/LMDZ.COMMON/arch.env
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/PEMrun.job	(revision 3579)
@@ -13,4 +13,7 @@
 #SBATCH --mem=29000M
 
+########################################################################
+# Modify here the parameters depending on your setup
+####################################################
 # A few parameters that might need to be changed depending on your setup
 # Path to the arch.env to source:
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/README
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/README	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/README	(revision 3579)
@@ -34,5 +34,5 @@
 
 # obl_ecc_lsp.asc
-  File describing orbital parameters for Mars from Laskar data. It contains the Earth year and the corresponding obliquity, eccentricity and Ls of perihelion.
+  File describing orbital parameters for Mars from Laskar's data. It contains the Earth year and the corresponding obliquity, eccentricity and Ls of perihelion.
 
 # modify_startfi_orbit.sh:
@@ -49,8 +49,8 @@
 
 # clean.sh:
-  Bash script file to clean the folder after a PEM simulation.
+  Bash script file to clean the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.
 
 # multiple_exec.sh:
-  Bash script to execute multiple scripts in subdirectories, useful to launch multiple simulations at once.
+  Bash script file to execute multiple scripts in subdirectories. It is useful to launch multiple simulations at once.
 
 # visu_layering.py:
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/clean.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/clean.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/clean.sh	(revision 3579)
@@ -2,5 +2,9 @@
 #########################################################
 ### Script to clean the folder after a PEM simulation ###
+### and reset the initial starting files to prepare a ###
+### new simulation                                    ###
 #########################################################
+# There is no argument, you can just execute it.
+################################################
 
 echo "Cleaning..."
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/concat_diagpem.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/concat_diagpem.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/concat_diagpem.sh	(revision 3579)
@@ -3,5 +3,10 @@
 ### Script to concatenate "diagpem.nc" outputs into one file ###
 ################################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
+################################################################
+# Modify here the parameters for the script
+###########################################
 # Output file name
 output_file="diagpem_concat.nc"
@@ -20,7 +25,7 @@
 files=($directory/diagpem*.nc)
 output_file=($directory/$output_file)
+################################################################
 
 
-################################################################
 # Checking if everything is ok
 if [ ! -d "$directory" ]; then
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/inipem_orbit.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/inipem_orbit.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/inipem_orbit.sh	(revision 3579)
@@ -4,5 +4,10 @@
 ### according to the date set in the file "run_PEM.def"            ###
 ######################################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
+######################################################################
+# Modify here the parameters for the script
+###########################################
 # Name of the file to be modified
 name_file="startfi.nc"
@@ -10,7 +15,7 @@
 # Name of the file containing the orbital data
 orb_data="obl_ecc_lsp.asc"
+######################################################################
 
 
-######################################################################
 # Check if files necessary for the script exist
 if [ ! -f "$orb_data" ]; then
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh	(revision 3579)
@@ -8,4 +8,6 @@
 #     It will ask for parameters to know the starting point that you want to. 
 ########################################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
 
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh	(revision 3579)
@@ -10,5 +10,5 @@
 
     date
-    echo "Successful end of the launching script for the PEM simulation."
+    echo "Success: the launching script for the PEM simulation completed normally!"
     exit 0
 }
@@ -20,5 +20,5 @@
 
     date
-    echo "End with error of the launching script for the PEM."
+    echo "Error: an issue occured in the launching script for the PEM simulation!"
     exit 1
 }
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_orbit.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_orbit.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_orbit.sh	(revision 3579)
@@ -3,7 +3,12 @@
 ### Script to modify the orbital parameters of a file "startfi.nc" ###
 ######################################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
+######################################################################
+# Modify here the parameters for the script
+###########################################
 # Name of the file
-name_file="startfi.nc"
+name_file = "startfi.nc"
 
 # New values for the orbital parameters
@@ -12,7 +17,7 @@
 new_Lsp=251.06881714
 new_iniLs=0.
+######################################################################
 
 
-######################################################################
 # Calculate modified values
 if [ ! -f "$name_file" ]; then
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_var.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_var.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_var.sh	(revision 3579)
@@ -3,5 +3,10 @@
 ### Script to modify the value of a variable in a file "startfi.nc" ###
 #######################################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
+#######################################################################
+# Modify here the parameters for the script
+###########################################
 # Name of the file
 name_file="startfi.nc"
@@ -12,7 +17,7 @@
 # New value for the variable
 new_var=8.
+#######################################################################
 
 
-#######################################################################
 # Update the netCDF file
 ncap2 -O -s "$var_name=$new_var" \
Index: /trunk/LMDZ.COMMON/libf/evolution/deftank/multiple_exec.sh
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/deftank/multiple_exec.sh	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/deftank/multiple_exec.sh	(revision 3579)
@@ -3,5 +3,10 @@
 ### Script to execute multiple scripts in subdirectories ###
 ############################################################
+set -e
+trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
 
+############################################################
+# Modify here the parameters for the script
+###########################################
 # Name of the file to execute in all subdirectories
 script_name="launchPEM.sh"
@@ -12,4 +17,6 @@
 # Name of the template directory to skip
 tempdir_name="Template"
+############################################################
+
 
 # Traverse all subdirectories, excluding the template
Index: /trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90	(revision 3578)
+++ /trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90	(revision 3579)
@@ -11,4 +11,5 @@
 !=======================================================================
 use netcdf
+use version_info_mod, only: print_version_info
 
 implicit none
@@ -23,7 +24,20 @@
 character(1)                          :: str
 character(30)                         :: name_, namevar
+character(100)                        :: arg ! To read command-line arguments
 integer                               :: xtype_var, len_, len_1, len_2, len_lat, len_lon, len_time, len_soil
 integer                               :: dimid_lon, dimid_lat, dimid_time, dimid_soil, dimid_2, numdims, numatts, numyear
 logical                               :: yes
+
+
+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
 
 do numyear = 1,2
