Changeset 4939


Ignore:
Timestamp:
May 13, 2024, 10:11:39 AM (8 months ago)
Author:
abarral
Message:

(WIP)
add compile physics, aerosols, snow scheme and isotopes to install_lmdz.sh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install_amaury/install_lmdz.sh

    r4934 r4939  
    5858    veget="none"
    5959    grid_resolution="32x32x39"
    60     physiq=""
     60    benchphysiq=""
     61    compphysiq="lmd"
    6162
    6263    parallel="none"
     
    8485
    8586    local mpi_file
    86     mpi_file=$(readlink -f "$(which mpif90)")
     87    mpi_file=$(readlink -e -f "$(which mpif90)")
    8788    path_mpi=$(dirname "$mpi_file")
    8889    root_mpi=$(dirname "$path_mpi")
     
    128129        -debug      compile everything in debug mode
    129130
    130         -physiq     to choose which physics package to use in the bench (default <$physiq>)
     131        -benchphysiq   to choose which physics.def package to use in the bench (default <$benchphysiq>)
     132
     133        -compilephysiq   physics to compile the model with (default <$compphysiq>)
    131134
    132135        -veget      surface/vegetation scheme treatment controlled by the single variable veget which can have the following values: none: bucket scheme (default); CMIP6 | veget2.0: orchidee version used in CMIP exercise, rev 5661; veget2.2: orchidee branch 2.2, rev 8529 (bundled); number: orchidee version number (default $veget)
     136
     137        -spla       activate interactive aerosols
     138
     139        -inlandsis  activate new snow scheme
    133140
    134141        -arch       name of the arch to use (default <$arch>)
     
    165172            "-name") MODEL=$2; shift; shift;;
    166173            "-netcdf") netcdf=$2; shift; shift;;
    167             "-physiq") physiq=$2; shift; shift;;
     174            "-benchphysiq") benchphysiq=$2; shift; shift;;
     175            "-compilephysiq") compphysiq=$2; shift; shift;;
    168176            "-xios") with_xios=1; shift;;
    169177            "-arch") arch=$2; shift; shift;;
    170178            "-arch_dir") arch_dir=$2; shift; shift;;
    171179            "-veget") veget=$2; shift; shift;;
     180            "-spla") aerosols=1; shift;;
     181            "-inlandsis") inlandsis=1; shift;;
    172182            "-make_j") make_j=$2; shift; shift;;
    173183            *)  bash install_lmdz.sh -h; exit 1
    174184        esac
    175185    done
     186
     187    # Isotopes : Compile and run with isotopes if lmdz_phys="lmdiso" in main.sh
     188    if [[ $compphysiq = "lmdiso" ]]; then isotopes=1; else isotopes=0; fi
    176189
    177190    # Option de compilation pour Cosp
     
    182195    esac
    183196
     197    #Define veget-related suffix for gcm name
     198    if [[ $veget = 'none' ]]; then
     199        suff_orc=''
     200    else
     201        suff_orc='_orch'
     202    fi
     203
     204
     205    if [[ $parallel = "none" ]]; then
     206        suff_para='_seq'
     207    else
     208        suff_para='_para_mem'
     209    fi
     210
     211    if [[ $with_xios = 1 ]]; then opt_makelmdz_xios="-io xios"; fi
     212
     213    if [[ $aerosols = 1 ]]; then
     214      opt_aer="-dust true"; suff_aer="_spla"
     215    else
     216      opt_aer=""; suff_aer=""
     217    fi
     218
     219    if [[ $inlandsis = 1 ]]; then
     220       opt_inlandsis="-inlandsis true"
     221    else
     222       opt_inlandsis=""
     223    fi
     224
     225    if [[ $isotopes = 1 ]]; then
     226      opt_isotopes="-isotopes true"; suff_iso="_iso"
     227    else
     228      opt_isotopes="" ; suff_iso=""
     229    fi
     230
     231
     232    # Name of the model's folder. The convention taken here is that models that requires different compilation sources should have a different names.
     233    local xios_name=""
     234    if [[ $with_xios = 1 ]]; then xios_name="XIOS"; fi
     235    if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version${svn_lmdz}OR$veget$xios_name"; fi
     236
     237    if [[ $arch_dir = "" ]]; then arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"; fi
     238}
     239
     240function ensure_correct_option_combinations {
    184241    # Check on veget version
    185242    if [[ $veget != 'none' && $veget != "CMIP6" && $veget != "orch2.0" && $veget != "orch2.2" ]]; then
     
    190247    fi
    191248
    192     #Define veget-related suffix for gcm name
    193     if [[ $veget = 'none' ]]; then
    194         suff_orc=''
    195     else
    196         suff_orc='_orch'
    197     fi
    198 
    199 
    200     if [[ $parallel = "none" ]]; then
    201         suff_exe='_seq'
    202     else
    203         suff_exe='_para_mem'
    204     fi
    205 
    206     #Chemin pour placer le modele
    207     if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version$svn_lmdz$optim_debug"; fi
    208 
    209249    ## if also compiling XIOS, parallel must be mpi_omp
    210250    if [[ $with_xios = 1 && $parallel != "mpi_omp" ]]; then
     
    212252    fi
    213253
    214     if [[ $with_xios = 1 ]]; then
    215         opt_makelmdz_xios="-io xios"
    216     fi
    217 
    218254    if [[ $cosp = "v2" && $with_xios = 0 ]]; then
    219255        echo "Error, Cospv2 cannot run without Xios"; exit 1
    220256    fi
    221257
    222     if [[ $arch_dir = "" ]]; then
    223         arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"
    224     fi
    225     arch_dir=$(readlink -f "$arch_dir")  # full path
     258    # STOP if trying to use both ORCHIDEE and Isotopes :
     259    if [[ $isotopes = 1 && $veget != "NONE" ]]; then
     260      echo "STOP: You cannot run LMDZ with ORCHIDEE and ISOtopes at the same time"; exit 1
     261    fi
     262
     263    # STOP if trying to use both SPLA and Isotopes :
     264    if [[ $isotopes = 1 && $aerosols = 1 ]]; then
     265      echo "STOP: You cannot run LMDZ with Isotopes and aerosols=spla at the same time"; exit 1
     266    fi
     267
     268    # (Temporary) STOP if trying to use Isotopes with XIOS :
     269    # TODO Amaury: check if still relevant
     270    if [[ $isotopes = 1 && $with_xios = 1 ]]; then
     271      echo "STOP: Isotopes cannont yet be run with XIOS"; exit 1
     272    fi
     273
     274    # (Temporary) Constraints for aerosols=spla :
     275    # --> resolution 128x88x79 and rad=rrtm
     276    if [[ $aerosols = 1 && $grid_resolution != "128x88x79" ]]; then
     277      echo 'For now, <aerosols=spla> requires <resol=128x88x79>, and uses the zoomed grid from gcm.def_zNAfrica_BiJe, for which forcing & initial files are available'
     278      echo "Right now resol=<$grid_resolution>"
     279      exit 1
     280    fi
     281
     282    if [[ $aerosols = 1 && $rad != "rrtm" ]]; then
     283      echo "STOP: For the time being, <aerosols=spla> requires <rad=rrtm>"; exit 1
     284    fi
    226285}
    227286
     
    250309function download_model {
    251310    mkdir -p "$MODEL"
    252     MODEL=$(readlink -f "$MODEL"); echo "$MODEL"  # absolute path
     311    MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL"  # absolute path
    253312
    254313    rm -rf "$MODEL/modipsl"
     
    292351        mv MODEL_REF "$MODEL"
    293352    fi
    294     MODEL=$(readlink -f "$MODEL"); echo "$MODEL"  # absolute path
     353    MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL"  # absolute path
    295354}
    296355
    297356function init_arch {
     357    arch_dir=$(readlink -e -f "$arch_dir")  # full path. readlink must be called *after* the path is created
    298358    if [[ ! -d $arch_dir ]]; then
    299359        echo "Error: no arch dir $arch_dir"; exit 1
     
    559619
    560620function get_lmdz_version {
    561     LMDZPATH=$(readlink -f "$MODEL/modipsl/modeles/LMD"*)
     621    LMDZPATH=$(readlink -e -f "$MODEL/modipsl/modeles/LMD"*)
    562622    cd "$LMDZPATH"
    563623    lmdzlog="$(pwd)/lmdz.log"
     
    587647    cd "$LMDZPATH"
    588648
    589     exe_name="bin/gcm_${grid_resolution}_phylmd_${rad}${suff_exe}${suff_orc}.e"
     649    if [[ $used_lmdz_rev -le 4185 ]]; then
     650        exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${suff_para}${suff_orc}${suff_aer}${suff_iso}.e"
     651    else
     652        exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${rad}${suff_para}${suff_orc}${suff_aer}${suff_iso}.e"
     653    fi
    590654
    591655    local opt_rad
     
    608672    local varenv="IOIPSL_LIBDIR_=\"$IOIPSL_LIBDIR_\" IOIPSL_INCDIR_=\"$IOIPSL_INCDIR_\" ORCH_INCDIR_=\"$ORCH_INCDIR_\" ORCH_LIBDIR_=\"$ORCH_LIBDIR_\" XIOS_INCDIR_=\"$XIOS_INCDIR_\" XIOS_LIBDIR_=\"$XIOS_LIBDIR_\""
    609673    makelmdz="makelmdz_fcm $optim_debug -arch $arch -j $make_j"
    610     if [[ $parallel = "none" ]]; then
    611         echo "$varenv ./$makelmdz $opt_rad $opt_cosp -d ${grid_resolution} -v $fcm_veget_version gcm " > compile.sh
    612     else
    613         echo "$varenv ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios -d ${grid_resolution} -v $fcm_veget_version -mem -parallel $parallel gcm" > compile.sh
    614     fi
     674    local para_compile_opt="-mem -parallel $parallel"; if [[ $parallel = "none" ]]; then para_compile_opt=""; fi
     675    echo "$varenv ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios $opt_aer $opt_inlandsis $opt_isotopes -p $compphysiq -d ${grid_resolution} -v $fcm_veget_version $para_compile_opt gcm" > compile.sh
    615676    echo "Compiling lmdz using $(\cat compile.sh) (log: $lmdzlog) $(date)"
    616677    chmod +x ./compile.sh
     
    621682
    622683    # Check executable
    623     # TODO $mysev -ge 4186 => other name convention ! check original install
    624684    if [[ ! -f $exe_name ]]; then
    625685        echo "Compilation failed, can't find the executable"; exit 1
     
    652712        fi
    653713
    654         if [[ -n "$physiq" ]]; then
     714        if [[ -n "$benchphysiq" ]]; then
    655715            cd "BENCH${grid_resolution}"
    656             if [[ -f "physiq.def_${physiq}" ]]; then
    657                 cp "physiq.def_${physiq}" physiq.def
    658                 echo "using physiq.def_${physiq}"
     716            if [[ -f "physiq.def_${benchphysiq}" ]]; then
     717                cp "physiq.def_${benchphysiq}" benchphysiq.def
     718                echo "using physiq.def_${benchphysiq}"
    659719            else
    660720                echo "using standard physiq.def"
     
    849909set_default_params
    850910read_cmdline_args "$@"
     911ensure_correct_option_combinations
    851912#download_model
    852913create_model_tar
Note: See TracChangeset for help on using the changeset viewer.