Changeset 5175 for BOL


Ignore:
Timestamp:
Sep 9, 2024, 11:33:12 AM (3 months ago)
Author:
abarral
Message:

Automatically set root_dir via setup.sh

Location:
BOL/LMDZ_Setup_amaury
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BOL/LMDZ_Setup_amaury/lmdz_env.sh

    r5078 r5175  
    77# See the end of <set_env> for the explanation of each
    88########################################################
     9
     10# <root_dir> will be set by sed by setup.sh here
     11root_dir=/home/abarral/PycharmProjects/installLMDZ/LMDZ_Setup
    912
    1013function get_hostname {
     
    3942      #        alors $STORE, $WORK etc vont designer les espaces de "newproj")
    4043      account="lmd"  # $(idrproj | grep active | awk '{ print $1}') doesn't work on compute nodes
    41       root_dir="$WORK/LMDZ_Setup";
    4244      ARCH="X64_JEANZAY"
    4345      SIMRUNBASEDIR="$SCRATCH/"
     
    5759      module load cdo/2.3.0
    5860
    59       root_dir="/data/abarral/LMDZ_SETUP_ROOT/LMDZ_Setup";
    6061      ARCH="X64_MESOIPSL-GNU"
    6162      SIMRUNBASEDIR="$SCRATCH/"
     
    9394
    9495      account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-)
    95       root_dir="$WORKDIR/LMDZ_Setup";
    9696      ARCH="X64_ADASTRA-GNU"
    9797      SIMRUNBASEDIR="$SCRATCHDIR/"
     
    108108      ;;
    109109    *) echo "WARNING: RUNNING THIS SCRIPT ON A LOCAL COMPUTER IS DISCOURAGED (lackluster cpus and memory)"
    110       root_dir="/home/abarral/PycharmProjects/installLMDZ/LMDZ_Setup"; # Where you have extracted LMDZ_Setup. Can't use $(pwd) since this script gets copied and ran from several locations
    111110      ARCH="local-gfortran-parallel"  # The arch file to use
    112111      SIMRUNBASEDIR="/tmp/SCRATCH/"  # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...)
     
    128127set_env
    129128
    130 if [[ ! (-d $root_dir && -f $root_dir/lmdz_env.sh) ]]; then
    131   echo "STOP: root_dir $root_dir not found, either you are running on an unsupported cluster, or you haven't edited lmdz_env.sh properly"; exit 1
     129if [[ ! (-d $root_dir && -f $root_dir/.lmdz_setup_root_dir && -f $root_dir/lmdz_env.sh) ]]; then
     130  echo "STOP: root_dir $root_dir not found, either you are running on an unsupported cluster, or the initialisation failed midway"; exit 1
    132131fi
  • BOL/LMDZ_Setup_amaury/setup.sh

    r5078 r5175  
    77# EXPERT-LEVEL CHOICES, only available in setup.sh, not in main.sh :
    88####################################################################
    9 function define_expert_options {
     9function define_expert_options() {
    1010  # optim: either "" or "-debug" to compile in debug mode (slower but better diagnosis of segfaults)
    1111  optim=""
     
    5050# /!\ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING /!\
    5151
    52 function enable_platform {  # In job scripts, sed platform-specific headers
     52function enable_platform() {  # In job scripts, sed platform-specific headers
    5353  local file="$1"
    5454  local platform
     
    6464}
    6565
    66 function load_install_lib {
     66function load_install_lib() {
    6767  # Fetch and source install_lmdz.sh to get `myget`
    6868  if [[ ! -f "install_lmdz.sh" ]]; then
     
    7474}
    7575
    76 function set_default_params {
     76function set_default_params() {
    7777  # Default value of script parameters
    7878  SIM=$(basename "$local")CTL  # name
     
    107107}
    108108
    109 function read_cmdline_args {
     109function read_cmdline_args() {
    110110  while (($# > 0)); do
    111111    case $1 in
     
    188188}
    189189
    190 function ensure_correct_option_combinations {
     190function ensure_correct_option_combinations() {
    191191  # AVOID COMBINATIONS OF OPTIONS THAT DON'T WORK in user choices
    192192  if [[ $ok_guide = y && $climato = 1 ]]; then
     
    213213}
    214214
    215 function install_model {
     215function install_model() {
    216216  mkdir -p "$LMDZD"
    217217
     
    249249}
    250250
    251 function setup_def {  # modify various .def in ./DEF (+ xios xml as needed)
     251function setup_def() {  # modify various .def in ./DEF (+ xios xml as needed)
    252252  cd "$local"
    253253
     
    359359}
    360360
    361 function setup_ce0l { # Verification de l'existance de l'état initial, compilation eventuelle pour sa creation
     361function setup_ce0l() { # Verification de l'existance de l'état initial, compilation eventuelle pour sa creation
    362362  if [[ ! -d $INIT ]]; then
    363363    if [[ $init = 0 ]]; then
     
    379379}
    380380
    381 function setup_simu {
     381function setup_simu() {
    382382  SIMRUNTOPDIR="$SIMRUNBASEDIR/$(basename "$local")"
    383383  SIMRUNDIR=$SIMRUNTOPDIR
     
    461461}
    462462
    463 function fetch_simu_init_files {
     463function fetch_simu_init_files() {
    464464  #####################################################################
    465465  echo "Recuperation eventuelle de certains fichiers sur $LMDZ_INIT"
     
    542542}
    543543
    544 function run_sim_or_init {
     544function run_sim_or_init() {
    545545  cd "$local"
    546546
     
    715715}
    716716
    717 function message_post_submit {
     717function message_post_submit() {
    718718  if [[ $ok_guide = "y" && $init = 1 ]]; then
    719719    cd "$local"
     
    731731}
    732732
    733 # Set up the appropriate environment
    734 source lmdz_env.sh
     733function setup_and_load_lmdz_env() {
     734  if [[ ! -f .lmdz_setup_root_dir ]]; then echo "STOP: setup.sh is not located in the root dir ??!!"; exit 1; fi
     735  # sed root_dir in lmdz_env.sh
     736  sed -i'' "s<root_dir=.*<root_dir=$local<" lmdz_env.sh
     737
     738  # Set up the appropriate environment
     739  source lmdz_env.sh
     740}
    735741
    736742local=$(pwd)
    737743
     744setup_and_load_lmdz_env
    738745load_install_lib
    739746define_expert_options
Note: See TracChangeset for help on using the changeset viewer.