Skip to content
Snippets Groups Projects
Select Git revision
  • bd9ba495e22b1fb7a07eb71fa5427d0cfe5acd6b
  • bing_issues#190_tf2
  • bing_tf2_convert
  • bing_issue#189_train_modular
  • simon_#172_integrate_weatherbench
  • develop
  • bing_issue#188_restructure_ambs
  • yan_issue#100_extract_prcp_data
  • bing_issue#170_data_preprocess_training_tf1
  • Gong2022_temperature_forecasts
  • bing_issue#186_clean_GMD1_tag
  • yan_issue#179_integrate_GZAWS_data_onfly
  • bing_issue#178_runscript_bug_postprocess
  • michael_issue#187_bugfix_setup_runscript_template
  • bing_issue#180_bugs_postprpocess_meta_postprocess
  • yan_issue#177_repo_for_CLGAN_gmd
  • bing_issue#176_integrate_weather_bench
  • michael_issue#181_eval_era5_forecasts
  • michael_issue#182_eval_subdomain
  • michael_issue#119_warmup_Horovod
  • bing_issue#160_test_zam347
  • ambs_v1
  • ambs_gmd_nowcasting_v1.0
  • GMD1
  • modular_booster_20210203
  • new_structure_20201004_v1.0
  • old_structure_20200930
27 results

setup_runscript_templates.sh

Blame
  • setup_runscript_templates.sh 2.29 KiB
    #!/usr/bin/env bash
    #
    # __authors__ = Michael Langguth
    # __date__  = '2021_02_05'
    #
    # **************** Description ****************
    # Sets the base directory to the template runscripts under which all the data will be stored,
    # i.e. where the AMBS-directory tree will be set up.
    # If no argument is passed, the default defined by 'base_data_dir_default' is set.
    #
    # Example:
    #    ./setup_runscript_templates.sh [<my_path>]
    # **************** Description ****************
    #
    # **************** Auxiliary functions ****************
    
    # default value for base directory
    base_data_dir_default=/p/project/deepacf/deeprain/video_prediction_shared_folder/
    # some further directory paths
    CURR_DIR_FULL=`pwd`
    CURR_DIR="$(basename "$CURR_DIR_FULL")"
    BASE_DIR="$(dirname "$CURR_DIR_FULL")"
    USER=$USER
    
    ### Some sanity checks ###
    # ensure that the script is executed from the env_setup-subdirectory
    if [[ "${CURR_DIR}" != "config_runscripts"  ]]; then
      echo "ERROR: Execute 'setup_runscript_templates.sh' from the config_runscripts-subdirectory only!"
      exit 1
    fi
    # check/handle input arguments
    if [[ "$#" -lt 1 ]]; then
      data_dir=${base_data_dir_default}
      echo "No base directory passed. Thus, the default path ${base_data_dir_default} will be applied."
      echo "In order to set it pass the directory path as a first argument."
      echo "Example: ./setup_runscript_templates.sh /my/desired/path/"
    elif [[ "$#" -ge 2 ]]; then
      echo "ERROR: Too many arguments provided. Cannot continue..."
      exit 1
    else
      data_dir=$1
      base_data_dir="$(dirname "${data_dir}")"
      if [[ ! -d ${base_data_dir} ]]; then
        echo "ERROR: Top-level data directory ${base_data_dir} does not exist. Cannot create passed directory."
        exit 2
      fi
      if [[ ! -d ${data_dir} ]]; then
        mkdir ${data_dir}
        echo "Passed directory '${data_dir}' created successfully."
      fi
    fi
    
    echo "Start setting up templates under nonHPC_scripts/..."
    for f in ${BASE_DIR}/nonHPC_scripts/*template.sh; do
      echo "Setting up ${f}..."
      fnew=${f%%.*}_${USER}.sh
      cp ${f} ${fnew}
      sed -i "s|\(.*_dir=\).*|\1${data_dir}|g" ${fnew}
    done
    echo "Done!"
    
    echo "Start setting up templates under HPC_scripts/"
    for f in ${BASE_DIR}/HPC_scripts/*template.sh; do
      echo "Setting up ${f}..."
      fnew=${f%%.*}_${USER}.sh
      cp ${f} ${fnew}
      sed -i "s|\(.*_dir=\).*|\1${data_dir}|g" ${fnew}
    done
    echo "Done!"
    # end