source: branches/UKMO/dev_r7681_rebuild_nemo/NEMOGCM/TOOLS/REBUILD_NEMO/rebuild_nemo @ 7685

Last change on this file since 7685 was 7685, checked in by timgraham, 4 years ago

Added option to specify required memory for jobs submitted to a compute node

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/bin/ksh
2
3# CALLS: rebuild_nemo.exe
4
5#set -ax
6usage ()
7{
8   echo
9   echo "  NEMO Rebuild"
10   echo "  ************"
11   echo
12   echo "  usage: ${0##*/} [-l -t -c -m -n] filebase ndomain [rebuild dimensions]"
13   echo
14   echo "  flags:    -l                 submit to compute node"
15   echo "            -t num             use num threads"
16   echo "            -c num             split 4D vars into time chuncks of size num"
17   echo "            -m                 force masking of global arrays (zero if no mdi)"
18   echo "            -d deflate_level   deflate level for output files (key_netcdf4 only)"
19   echo "            -n namelist        full path to namelist file to be created (otherwise default nam_rebuild+_process_id is used)"
20   echo "            -r memory          Memory to request on compute node including units (Default = 10Gb)"
21   echo
22   exit 1
23}
24
25while getopts c:n:t:d:r:lm opt
26do
27  case ${opt} in
28      l) 
29         BATCH="yes"
30         BATCH_CMD="qsub" 
31         ARCH="XC40_METO"
32         echo "Submitting job to compute node"
33      ;;
34      t)
35         OMP_NUM_THREADS=${OPTARG}
36      ;;
37      c)
38         NCHUNKSIZE=${OPTARG}
39      ;;
40      m) 
41         NMASK="TRUE"
42         echo "mask"
43      ;;
44      d)
45         DEFLATE=${OPTARG}
46      ;;
47      n)
48         nam_rebuild=${OPTARG}
49      ;;
50      r)
51         MEMORY=${OPTARG}
52      ;;
53  esac
54done
55shift $(expr ${OPTIND} - 1)
56
57if [[ $# -lt 2 ]] ; then
58   usage
59fi
60
61script_dir=$(dirname $0)
62
63file=$1
64ndomain=$2
65DIM1=$3
66DIM2=$4
67export OMP_NUM_THREADS=${OMP_NUM_THREADS:-1}
68nam_rebuild=${nam_rebuild:-nam_rebuild_$$}
69MEMORY=${MEMORY:-10Gb}
70
71if [[ -n ${DIM1} && -n ${DIM2} ]] ; then
72   dim_str=" dims '${DIM1}','${DIM2}'"
73   dims="dims='${DIM1}','${DIM2}'"
74fi
75
76echo "file ${file},  num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}"
77
78cat > $nam_rebuild << EOC
79&nam_rebuild
80filebase='${file}'
81ndomain=${ndomain}
82EOC
83if [[ -n ${dims} ]] ; then
84   echo ${dims} >> $nam_rebuild
85fi
86if [[ -n ${NCHUNKSIZE} ]] ; then
87   echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild
88fi
89if [[ -n ${NMASK} ]] ; then
90   echo " l_maskout=.true." >> $nam_rebuild
91fi
92if [[ -n ${DEFLATE} ]] ; then
93   echo " deflate_level=${DEFLATE}" >> $nam_rebuild
94fi
95
96echo "/" >> $nam_rebuild
97
98if [[ ${BATCH} == "yes" ]] ; then
99   batch_file=rebuild_nemo_batch_${ARCH}
100
101   #Create a modified local copy of the batch submission file
102   #The process ID is appended to the end of the file name so it is unique
103   cat ${script_dir}/BATCH_TEMPLATES/${batch_file} | sed -e"s/NTHREADS/${OMP_NUM_THREADS}/" \
104      -e"s/MEMORY/${MEMORY}/" \
105      -e"s:INDIR:${script_dir}:" \
106      -e"s/NAMELIST/${nam_rebuild}/" > ${batch_file}_$$.sh
107   
108   #Submit the job
109   $BATCH_CMD ${batch_file}_$$.sh
110
111else
112   ${script_dir}/rebuild_nemo.exe $nam_rebuild
113fi
114
Note: See TracBrowser for help on using the repository browser.