Index: BOL/script_install/install_lmdz.sh
===================================================================
--- BOL/script_install/install_lmdz.sh	(revision 5387)
+++ BOL/script_install/install_lmdz.sh	(revision 5398)
@@ -365,5 +365,12 @@
 
 function download_modipsl_tar {
-    if [[ $clean_install = 1 ]]; then rm -rf "$MODEL"; fi
+    if [[ $clean_install = 1 ]]; then
+      local ans
+      echo "$MODEL already exists. Do you want to erase it and proceed (Y/n) ? You can also rerun with \`-noclean\` to only recompile the necessary components."
+      read -r ans
+      ans="${ans,,}"  # to lowercase
+      if [[ $ans != "y" ]]; then exit 0; fi
+      rm -rf "$MODEL"
+    fi
 
     mkdir -p "$MODEL"
@@ -411,13 +418,15 @@
 
     # load env
-    # shellcheck disable=SC1090
     if [[ -f $default_env_path ]]; then source "$default_env_path"; fi
 
     local mpi_file  # can't be done before as it depends on sourcing the env
-    set +e  # install_lmdz must be able to run without mpi
-    mpi_file=$(readlink -e -f "$(which mpif90)")
-    path_mpi=$(dirname "$mpi_file")
-    root_mpi=$(dirname "$path_mpi")
-    set -e
+    if [[ $parallel != "none" ]]; then
+      if [[ $(which "mpif90") = "" ]]; then
+        echo "STOP: parallel=$parallel but <mpif90> could not be found"; exit 1
+      fi
+      mpi_file=$(readlink -e -f "$(which mpif90)")
+      path_mpi=$(dirname "$mpi_file")
+      root_mpi=$(dirname "$path_mpi")
+    fi
 }
 
@@ -523,4 +532,22 @@
     fi
 
+    # add exported netcdf path to .env if not already the case. This ensures we always use the same netcdf library as during the first install.
+    if [[ $(nf-config --prefix) = "" || $(nc-config --prefix) = "" ]]; then
+      echo "STOP: missing nf-config or nc-config in \$PATH"; exit 1
+    fi
+    local nc_path nf_path env_msg env_msg_tail
+    nc_path=$(nc-config --prefix)
+    nf_path=$(nf-config --prefix)
+    env_msg="export PATH=\"$nc_path/bin:\$PATH\""
+    if [[ $nf_path != "$nc_path" ]]; then
+      env_msg="export PATH=\"$nf_path/bin:$env_msg\""
+    fi
+    env_msg_tail="# netcdf bin path auto-added by install_lmdz.sh"
+    env_msg="$env_msg $env_msg_tail"
+    if ! < "$default_env_path" grep -q "$env_msg"; then
+      sed -i "1s@^@$env_msg\n@" "$default_env_path"
+    fi
+
+    # Test if netcdf works fine on a simple program
     cat >test_netcdf90.f90 <<EOF
     use netcdf
@@ -911,5 +938,5 @@
                 echo "ulimit -s unlimited" >> bench.sh
             fi
-            if which mpirun &> /dev/null; then
+            if [[ $(which "mpirun") != "" ]]; then
                 echo "mpirun -np 2 gcm.e &> listing" >> bench.sh
             elif grep -q "Adastra" /etc/motd; then
@@ -1050,4 +1077,5 @@
 
 function wrapper_run_all() {
+    # This is a wrapper to catch any "unexpected" error due to set -e and avoid abrupt stoppage which may confuse the user
     set_default_params
     read_cmdline_args "$@"
