New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
rebuild_nemo in NEMO/trunk/tools/REBUILD_NEMO – NEMO

source: NEMO/trunk/tools/REBUILD_NEMO/rebuild_nemo @ 9596

Last change on this file since 9596 was 9048, checked in by timgraham, 6 years ago

New version of rebuild_nemo

  • Property svn:executable set to *
File size: 2.9 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
71#Find out the maximum number of files that can be opened and increase if necessary)
72nopen=$(ulimit -n)
73if [[ $ndomain -gt $nopen ]] ; then
74  nopen=$((ndomain+2))
75fi
76
77if [[ -n ${DIM1} && -n ${DIM2} ]] ; then
78   dim_str=" dims '${DIM1}','${DIM2}'"
79   dims="dims='${DIM1}','${DIM2}'"
80fi
81
82echo "file ${file},  num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}"
83
84cat > $nam_rebuild << EOC
85&nam_rebuild
86filebase='${file}'
87ndomain=${ndomain}
88EOC
89if [[ -n ${dims} ]] ; then
90   echo ${dims} >> $nam_rebuild
91fi
92if [[ -n ${NCHUNKSIZE} ]] ; then
93   echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild
94fi
95if [[ -n ${NMASK} ]] ; then
96   echo " l_maskout=.true." >> $nam_rebuild
97fi
98if [[ -n ${DEFLATE} ]] ; then
99   echo " deflate_level=${DEFLATE}" >> $nam_rebuild
100fi
101
102echo "/" >> $nam_rebuild
103
104if [[ ${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
118else
119   ulimit -n $nopen
120   ${script_dir}/rebuild_nemo.exe $nam_rebuild
121fi
122
Note: See TracBrowser for help on using the repository browser.