Changeset 5398 for BOL/script_install


Ignore:
Timestamp:
Dec 9, 2024, 3:50:19 PM (7 days ago)
Author:
abarral
Message:

Major:

  • Export used netcdf bin path in arch.env to ensure same path will be used in this project later on

Minor:

  • Add confirmation before overwriting existing install
  • Add explicit stop message if requesting parallel without mpif90
File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install/install_lmdz.sh

    r5387 r5398  
    365365
    366366function download_modipsl_tar {
    367     if [[ $clean_install = 1 ]]; then rm -rf "$MODEL"; fi
     367    if [[ $clean_install = 1 ]]; then
     368      local ans
     369      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."
     370      read -r ans
     371      ans="${ans,,}"  # to lowercase
     372      if [[ $ans != "y" ]]; then exit 0; fi
     373      rm -rf "$MODEL"
     374    fi
    368375
    369376    mkdir -p "$MODEL"
     
    411418
    412419    # load env
    413     # shellcheck disable=SC1090
    414420    if [[ -f $default_env_path ]]; then source "$default_env_path"; fi
    415421
    416422    local mpi_file  # can't be done before as it depends on sourcing the env
    417     set +e  # install_lmdz must be able to run without mpi
    418     mpi_file=$(readlink -e -f "$(which mpif90)")
    419     path_mpi=$(dirname "$mpi_file")
    420     root_mpi=$(dirname "$path_mpi")
    421     set -e
     423    if [[ $parallel != "none" ]]; then
     424      if [[ $(which "mpif90") = "" ]]; then
     425        echo "STOP: parallel=$parallel but <mpif90> could not be found"; exit 1
     426      fi
     427      mpi_file=$(readlink -e -f "$(which mpif90)")
     428      path_mpi=$(dirname "$mpi_file")
     429      root_mpi=$(dirname "$path_mpi")
     430    fi
    422431}
    423432
     
    523532    fi
    524533
     534    # 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.
     535    if [[ $(nf-config --prefix) = "" || $(nc-config --prefix) = "" ]]; then
     536      echo "STOP: missing nf-config or nc-config in \$PATH"; exit 1
     537    fi
     538    local nc_path nf_path env_msg env_msg_tail
     539    nc_path=$(nc-config --prefix)
     540    nf_path=$(nf-config --prefix)
     541    env_msg="export PATH=\"$nc_path/bin:\$PATH\""
     542    if [[ $nf_path != "$nc_path" ]]; then
     543      env_msg="export PATH=\"$nf_path/bin:$env_msg\""
     544    fi
     545    env_msg_tail="# netcdf bin path auto-added by install_lmdz.sh"
     546    env_msg="$env_msg $env_msg_tail"
     547    if ! < "$default_env_path" grep -q "$env_msg"; then
     548      sed -i "1s@^@$env_msg\n@" "$default_env_path"
     549    fi
     550
     551    # Test if netcdf works fine on a simple program
    525552    cat >test_netcdf90.f90 <<EOF
    526553    use netcdf
     
    911938                echo "ulimit -s unlimited" >> bench.sh
    912939            fi
    913             if which mpirun &> /dev/null; then
     940            if [[ $(which "mpirun") != "" ]]; then
    914941                echo "mpirun -np 2 gcm.e &> listing" >> bench.sh
    915942            elif grep -q "Adastra" /etc/motd; then
     
    10501077
    10511078function wrapper_run_all() {
     1079    # This is a wrapper to catch any "unexpected" error due to set -e and avoid abrupt stoppage which may confuse the user
    10521080    set_default_params
    10531081    read_cmdline_args "$@"
Note: See TracChangeset for help on using the changeset viewer.