Changeset 5031


Ignore:
Timestamp:
Jul 9, 2024, 11:45:07 AM (2 months ago)
Author:
abarral
Message:

Fix arch retrieval and overriding
Add Adriana comment for orchtrunk compilation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install_amaury/install_lmdz.sh

    r5027 r5031  
    247247    if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version${svn_lmdz}OR$veget$xios_name"; fi
    248248
    249     if [[ $arch_dir = "" ]]; then arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"; fi
     249    if [[ $arch_dir = "" ]]; then
     250      arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/";
     251    elif ! readlink -fe "$arch_dir"; then
     252      echo "STOP: no arch dir <$arch_dir>"; exit 1
     253    fi
    250254}
    251255
     
    317321    mkdir -p "$MODEL"
    318322    MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL"  # absolute path
    319     if [[ ! -f "$MODEL/modipsl" ]]; then
     323    if [[ ! -d "$MODEL/modipsl" ]]; then
    320324        echo "##########################################################"
    321         echo "Download a slightly modified version of  LMDZ"
     325        echo "Download a slightly modified version of LMDZ"
    322326        echo "##########################################################"
    323327        cd "$MODEL"
     
    334338
    335339function init_arch {
    336     arch_dir=$(readlink -e -f "$arch_dir")  # full path. readlink must be called *after* the path is created
    337     if [[ ! -d $arch_dir ]]; then
    338         echo "STOP: no arch dir $arch_dir"; exit 1
    339     fi
    340 
    341     local fcm_path
    342     if [[ -f $arch_dir/arch-$arch.fcm ]]; then
    343         fcm_path="$arch_dir/arch-$arch.fcm"
    344     else
    345         fcm_path="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.fcm"
    346         if [[ ! -f $fcm_path ]]; then
    347             echo "STOP: no $fcm_path"; exit 1
    348         fi
    349     fi
    350 
    351     local env_path
    352     if [[ -f $arch_dir/arch-$arch.env ]]; then
    353         env_path="$arch_dir/arch-$arch.env"
    354     else
    355         env_path="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.env"
    356         if [[ ! -f $env_path ]]; then
    357             echo "STOP: no $env_path"; exit 1
    358         fi
    359     fi
     340    set +e; arch_dir=$(readlink -f "$arch_dir"); set -e  # full path. readlink must be called *after* the path is created
     341
     342    # Check where default fcm, path, env are located - by default in $arch_path, instead in $MODEL/modipsl/modeles/LMDZ/arch/
     343    local i fcm_path path_path env_path
     344    for i in "path" "fcm" "env"; do
     345      local varname=${i}_path
     346      if [[ -f $arch_dir/arch-$arch.$i ]]; then
     347          declare $varname="$arch_dir/arch-$arch.$i"
     348      else
     349          declare $varname="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.$i"
     350          if [[ ! -f ${!varname} ]]; then
     351              echo "STOP: no ${!varname}"; exit 1
     352          fi
     353      fi
     354    done
     355    default_fcm_path=$fcm_path
     356    default_path_path=$path_path
     357    default_env_path=$env_path
    360358
    361359    # check compiler
    362     compiler=$(< "$fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//")
     360    compiler=$(< "$default_fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//")
    363361
    364362    # load env
    365363    # shellcheck disable=SC1090
    366     if [[ -f $env_path ]]; then source "$env_path"; fi
     364    if [[ -f $default_env_path ]]; then source "$default_env_path"; fi
    367365}
    368366
     
    370368    local component=$1
    371369
    372     if [[ -f "$arch_dir/arch-$arch.env" ]]; then
    373         cp -f "$arch_dir/arch-$arch."{fcm,path,env} "$MODEL/modipsl/modeles/$component/arch" &> /dev/null || true  # allow failure if doesn't exist
     370    # Use same .env for all components (for module compatibility)
     371    cp -f "$default_env_path" "$MODEL/modipsl/modeles/$component/arch" &> /dev/null || true  # allow failure if we're copying the file to itself
     372
     373    # Use local .path and .fcm is available, otherwise default
     374    if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.path" ]]; then
     375        cp -f "$default_path_path" "$MODEL/modipsl/modeles/$component/arch"
     376
     377        if [[ $component = "ORCHIDEE" ]]; then
     378            if [[ $orcbranch = "/tags/ORCHIDEE_2_0/ORCHIDEE" ]]; then  # 2.0 and before have a different fcm convention
     379                sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path"  # /!\ we only replace first occurence on purpose
     380            fi
     381        fi
     382    fi
     383    if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.fcm" ]]; then
     384        cp -f "$default_fcm_path"  "$MODEL/modipsl/modeles/$component/arch"
    374385
    375386        if [[ $component = "XIOS" ]]; then
    376387            # Adapt for XIOS, which uses different naming conventions
    377388            sed -i'' -e "s/%COMPILER/%FCOMPILER/" -e "s/%LINK/%LINKER/" -e "s/-fdefault-real-8//" "$MODEL/modipsl/modeles/XIOS/arch/arch-$arch.fcm"
    378         elif [[ $component = "ORCHIDEE" ]]; then
    379             if [[ $orcbranch = "/tags/ORCHIDEE_2_0/ORCHIDEE" ]]; then  # 2.0 and before have a different fcm convention
    380                 sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path"  # /!\ we only replace first occurence on purpose
    381             fi
    382389        fi
    383390    fi
     
    469476        myget src_archives/netcdf/NetCDF95-0.3.tar.gz
    470477        tar -xf NetCDF95-0.3.tar.gz
    471         \rm NetCDF95-0.3.tar.gz
     478        rm NetCDF95-0.3.tar.gz
    472479        cd NetCDF95-0.3
    473480        mkdir -p build && cd build
     
    533540        "orch2.2") fcm_veget_version=orchidee2.1; orcbranch="/branches/ORCHIDEE_2_2/ORCHIDEE" ;; # the bundled version
    534541        *) fetch_rev=$veget; fcm_veget_version=orchidee2.1;;  # /!\ arbitary rev only works for orch>=2.1
     542          # /!\ Note: for orch>=4, we should be using fcm_vegt_version="orchideetrunk". Below copied comment by Adriana in LMDZ_Setup docs:
     543#          Avec orchidee2.1, on va compiler LMDZ avec le cle cpp ORCHIDEE_NOLIC. On ne va donc pas prendre en compte les avancements fait dans le trunk qui permet que les fractions lic soitent traité par ORCHIDEE. Ca marche très bien sans cela puisque dans tout façon c'est en cours de développement et ce n'est pas activé par default. En fait on devrait compiler le trunk avec -v orchideetrunk mais avec landice_opt>2, ce qui ne change rien par rapport à orchidee2.1
     544#Si on voudrait activer landice_opt=2 , il faut compiler avec -v orchideetrunk.
     545
    535546    esac
    536547
Note: See TracChangeset for help on using the changeset viewer.