Changeset 9048
- Timestamp:
- 2017-12-14T14:40:24+01:00 (5 years ago)
- Location:
- branches/2017/dev_merge_2017/NEMOGCM/TOOLS/REBUILD_NEMO
- Files:
-
- 1 deleted
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2017/dev_merge_2017/NEMOGCM/TOOLS/REBUILD_NEMO/rebuild_nemo
r3025 r9048 1 1 #!/bin/ksh 2 # 3 # Script to run the NEMO rebuild tool to rebuild NEMO 4 # diagnostic or restart files. 5 # 6 # The scripts creates the nam_rebuild namelist based upon 7 # the command line options you give it (see usage below) 8 # 9 # Ed Blockley, September 2011 10 # 11 # 2 3 # CALLS: rebuild_nemo.exe 12 4 13 5 #set -ax … … 18 10 echo " ************" 19 11 echo 20 echo " usage: ${0##*/} [- t -c] filebase ndomain [rebuild dimensions]"12 echo " usage: ${0##*/} [-l -t -c -m -n] filebase ndomain [rebuild dimensions]" 21 13 echo 22 echo " flags: -t num use num threads" 23 echo " -c num split 4D vars into time chuncks of size num" 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)" 24 21 echo 25 22 exit 1 26 23 } 27 24 28 while getopts c: t:opt25 while getopts c:n:t:d:r:lm opt 29 26 do 30 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 ;; 31 34 t) 32 35 OMP_NUM_THREADS=${OPTARG} … … 35 38 NCHUNKSIZE=${OPTARG} 36 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 ;; 37 53 esac 38 54 done 39 55 shift $(expr ${OPTIND} - 1) 40 56 41 if [[ $# <2 ]] ; then57 if [[ $# -lt 2 ]] ; then 42 58 usage 43 59 fi … … 49 65 DIM1=$3 50 66 DIM2=$4 51 export OMP_NUM_THREADS=${OMP_NUM_THREADS:-16} 67 export OMP_NUM_THREADS=${OMP_NUM_THREADS:-1} 68 nam_rebuild=${nam_rebuild:-nam_rebuild_$$} 69 MEMORY=${MEMORY:-10Gb} 70 71 #Find out the maximum number of files that can be opened and increase if necessary) 72 nopen=$(ulimit -n) 73 if [[ $ndomain -gt $nopen ]] ; then 74 nopen=$((ndomain+2)) 75 fi 52 76 53 77 if [[ -n ${DIM1} && -n ${DIM2} ]] ; then 54 78 dim_str=" dims '${DIM1}','${DIM2}'" 55 79 dims="dims='${DIM1}','${DIM2}'" 56 echo ${dim_str} >> nam_rebuild57 80 fi 58 81 59 82 echo "file ${file}, num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}" 60 83 61 cat > nam_rebuild << EOC84 cat > $nam_rebuild << EOC 62 85 &nam_rebuild 63 86 filebase='${file}' … … 65 88 EOC 66 89 if [[ -n ${dims} ]] ; then 67 echo ${dims} >> nam_rebuild90 echo ${dims} >> $nam_rebuild 68 91 fi 69 92 if [[ -n ${NCHUNKSIZE} ]] ; then 70 echo " nchunksize=${NCHUNKSIZE}" >> nam_rebuild93 echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild 71 94 fi 72 echo "/" >> nam_rebuild 95 if [[ -n ${NMASK} ]] ; then 96 echo " l_maskout=.true." >> $nam_rebuild 97 fi 98 if [[ -n ${DEFLATE} ]] ; then 99 echo " deflate_level=${DEFLATE}" >> $nam_rebuild 100 fi 73 101 74 # run the rebuild code 75 ${script_dir}/rebuild_nemo.exe 102 echo "/" >> $nam_rebuild 103 104 if [[ ${BATCH} == "yes" ]] ; then 105 batch_file=rebuild_nemo_batch_${ARCH} 106 107 #Create a modified local copy of the batch submission file 108 #The process ID is appended to the end of the file name so it is unique 109 cat ${script_dir}/BATCH_TEMPLATES/${batch_file} | sed -e"s/NTHREADS/${OMP_NUM_THREADS}/" \ 110 -e"s/MEMORY/${MEMORY}/" \ 111 -e"s:INDIR:${script_dir}:" \ 112 -e"s/NOPEN/${nopen}/" \ 113 -e"s/NAMELIST/${nam_rebuild}/" > ${batch_file}_$$.sh 114 115 #Submit the job 116 $BATCH_CMD ${batch_file}_$$.sh 117 118 else 119 ulimit -n $nopen 120 ${script_dir}/rebuild_nemo.exe $nam_rebuild 121 fi 122
Note: See TracChangeset
for help on using the changeset viewer.