#!/bin/bash # $HeadURL: https://svn.pasta.freemyip.com/main/miniade/trunk/bin/nop-sh $ $LastChangedRevision: 10133 $ # Modules . $(miniade) || { echo "${0##*/}: ERROR: miniade failed (hint: run 'miniade' to see error)" >&2; exit 1; } # Configurable stuff MODE=sbatch # 'sbatch' or 'direct' (everybody wants 'direct' except Alexis) BEGIN_TIME=now #BEGIN_TIME=midnight case $CLUSTER in RAVEN) # 'bz' takes 00:00:33; 'an' takes 00:03:34; 'ca' takes 00:07:31; 'au-oc' takes 00:09:31; 'sa' takes 00:27:02; 'af' takes 00:55:44; 'na' takes 01:41:37; 'as' takes 01:48:31; 'eu' takes 03:53:16 CORES=72 # Partition deliberately blank as RAVEN's slurm ignores # this and works this out for itself on RAVEN. PARTITION= BATCH_NODES_HAVE_INTERNET_FLAG=true ;; COBRA) CORES=40 PARTITION=fat BATCH_NODES_HAVE_INTERNET_FLAG=false ;; HERCULES) CORES=24 PARTITION=short.q BATCH_NODES_HAVE_INTERNET_FLAG=true ;; SAKURA) # 'eu' takes 03:02:31 CORES=40 PARTITION=p.sakura BATCH_NODES_HAVE_INTERNET_FLAG=true ;; esac WORK_DIR=$HOME/work-dir # Each job creates a separate directory under here and will be deleted at the end OUT_DIR=$HOME/out-dir # Where to write the products LOCK_DIR=$HOME/lock-dir # Where to write wget locks DOWNLOAD_CACHE_DIR=$HOME/download-cache-dir # Optional, but will speed up repeat executions MKGMAP_URL=https://www.mkgmap.org.uk/download/mkgmap-r4922.zip SPLITTER_URL=https://www.mkgmap.org.uk/download/splitter-r654.zip SEA_URL=https://www.thkukuk.de/osm/data/sea-latest.zip BOUNDS_URL=https://www.thkukuk.de/osm/data/bounds-latest.zip # This is ordered from biggest to smallest to ensure the longest executing job gets scheduled first. # Since all the jobs' Slurm parameters are the same, the first queued job will be executed first, # but nodes may only become available at long intervals, so it's important to start longest job first. TUPLES=( "1234:Belize:BZ:bz:http://download.geofabrik.de/central-america/belize-latest.osm.pbf:default:2000000" #"1245:Europe:EU:eu:http://download.geofabrik.de/europe-latest.osm.pbf:default:2000000" #"5989:Asia:AS:as:http://download.geofabrik.de/asia-latest.osm.pbf:800000:2000000" #"1001:North America:NA:na:http://download.geofabrik.de/north-america-latest.osm.pbf:400000:2000000" #"2689:Australia and Oceania:AU_OC:au-oc:http://download.geofabrik.de/australia-oceania-latest.osm.pbf:800000:2000000" #"3278:South America:SA:sa:http://download.geofabrik.de/south-america-latest.osm.pbf:default:2000000" #"5191:Central America:CA:ca:http://download.geofabrik.de/central-america-latest.osm.pbf:default:2000000" #"7312:Africa:AF:af:http://download.geofabrik.de/africa-latest.osm.pbf:1200000:2000000" #"4567:Antarctica:AN:an:http://download.geofabrik.de/antarctica-latest.osm.pbf:default:2000000" ) # Other globals main() { local MY_ARGS # Defaults for options # Process options miniade_process_options --help-handler=help MY_ARGS "$@" && set -- "${MY_ARGS[@]}" # Process arguments [ $# = 0 ] || miniade_bad_usage # Sanity checks and derivations BIN_DIR=$(dirname $0) # Guts for TUPLE in "${TUPLES[@]}"; do [[ $TUPLE =~ ^(.*):(.*):(.*):(.*):(http.*):(default|[0-9]+):([0-9]+)$ ]] || error "$TUPLE: unparsable tuple" FAMILY_ID=${BASH_REMATCH[1]} COUNTRY_NAME=${BASH_REMATCH[2]} COUNTRY_ABBR=${BASH_REMATCH[3]} OVERVIEW_NAME=${BASH_REMATCH[4]} OSM_INPUT_URL=${BASH_REMATCH[5]} MAX_NODES_PER_TILE=${BASH_REMATCH[6]} MBS=${BASH_REMATCH[7]} OSM_TO_GARMIN_WRAPPER_CMDLINE="$BIN_DIR/osm-to-garmin --wget-opts=\"\" --timestamps --work-dir=$WORK_DIR/$OVERVIEW_NAME --out-dir=$OUT_DIR --lock-dir=$LOCK_DIR --download-cache-dir=$DOWNLOAD_CACHE_DIR --family-id=$FAMILY_ID --country-name=\"$COUNTRY_NAME\" --country-abbr=$COUNTRY_ABBR --overview-name=$OVERVIEW_NAME --osm-input-url=$OSM_INPUT_URL --cores=$CORES --mbs=$MBS --splitter-url=$SPLITTER_URL --mkgmap-url=$MKGMAP_URL --sea-url=$SEA_URL --bounds-url=$BOUNDS_URL --max-nodes-per-tile=$MAX_NODES_PER_TILE" case $MODE in echo) echo "$OSM_TO_GARMIN_WRAPPER_CMDLINE" ;; direct) miniade_debug 10 "main: $OVERVIEW_NAME: calling [$OSM_TO_GARMIN_WRAPPER_CMDLINE] ..." eval "$OSM_TO_GARMIN_WRAPPER_CMDLINE" ;; sbatch) # needed to remove 'SLURM_HINT=nomultithread' from environment, which # impacts core count to be passed to slurm with --ntasks-per-node option. module purge module load jdk # If no internet on batch, then do the downloads while still running # on the login node. if ! $BATCH_NODES_HAVE_INTERNET_FLAG; then miniade_debug 10 "main: $OVERVIEW_NAME: doing download before job submission ..." eval "$OSM_TO_GARMIN_WRAPPER_CMDLINE --exit-after-download" fi miniade_debug 10 "main: $OVERVIEW_NAME: submitting job ..." # In order that the job execution environment can find miniade, # we rely on being able to find in the job *submission* environment # (i.e. where *this* script is run) and '--export=ALL' propagating # that environment onto the job execution environment. eval "sbatch --export=ALL -o $HOME/test_job.out.%j -e $HOME/test_job.err.%j -D $HOME -J $OVERVIEW_NAME ${PARTITION:+--partition=$PARTITION} --nodes=1 --ntasks-per-node=$CORES --mem=$MBS --mail-type=all --mail-user=alexis.huxley@mpcdf.mpg.de --time=0-12:00:00 --begin=$BEGIN_TIME $OSM_TO_GARMIN_WRAPPER_CMDLINE" ;; *) miniade_error "$MODE: unknown mode" ;; esac done } help() { local PROGNAME miniade_get_progname PROGNAME echo "Usage: $PROGNAME [ ]" exit 0 } main "$@"