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 branches/UKMO/dev_r7681_rebuild_nemo/NEMOGCM/TOOLS/REBUILD_NEMO – NEMO

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

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

#1848 First commit of modified code

  • Property svn:executable set to *
File size: 2.5 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
21   exit 1
22}
23
24while getopts c:n:t:d:lm opt
25do
26  case ${opt} in
27      l) 
28         BATCH="yes"
29         BATCH_CMD="qsub" 
30         ARCH="XC40_METO"
31         echo "Submitting job to compute node"
32      ;;
33      t)
34         OMP_NUM_THREADS=${OPTARG}
35      ;;
36      c)
37         NCHUNKSIZE=${OPTARG}
38      ;;
39      m) 
40         NMASK="TRUE"
41      ;;
42      d)
43         DEFLATE=${OPTARG}
44      ;;
45      n)
46         nam_rebuild=${OPTARG}
47      ;;
48  esac
49done
50shift $(expr ${OPTIND} - 1)
51
52if [[ $# -lt 2 ]] ; then
53   usage
54fi
55
56script_dir=$(dirname $0)
57
58file=$1
59ndomain=$2
60DIM1=$3
61DIM2=$4
62export OMP_NUM_THREADS=${OMP_NUM_THREADS:-1}
63nam_rebuild=${nam_rebuild:-nam_rebuild_$$}
64
65if [[ -n ${DIM1} && -n ${DIM2} ]] ; then
66   dim_str=" dims '${DIM1}','${DIM2}'"
67   dims="dims='${DIM1}','${DIM2}'"
68fi
69
70echo "file ${file},  num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}"
71
72cat > $nam_rebuild << EOC
73&nam_rebuild
74filebase='${file}'
75ndomain=${ndomain}
76EOC
77if [[ -n ${dims} ]] ; then
78   echo ${dims} >> $nam_rebuild
79fi
80if [[ -n ${NCHUNKSIZE} ]] ; then
81   echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild
82fi
83if [[ -n ${NMASK} ]] ; then
84   echo " l_maskout=.true." >> $nam_rebuild
85fi
86if [[ -n ${DEFLATE} ]] ; then
87   echo " deflate_level=${DEFLATE}" >> $nam_rebuild
88fi
89
90echo "/" >> $nam_rebuild
91
92if [[ ${BATCH} == "yes" ]] ; then
93   batch_file=rebuild_nemo_batch_${ARCH}
94
95   #Create a modified local copy of the batch submission file
96   #The process ID is appended to the end of the file name so it is unique
97   cat ${script_dir}/BATCH_TEMPLATES/${batch_file} | sed -e"s/NTHREADS/${OMP_NUM_THREADS}/" \
98      -e"s:INDIR:${script_dir}:" \
99      -e"s/NAMELIST/${nam_rebuild}/" > ${batch_file}_$$.sh
100   
101   #Submit the job
102   $BATCH_CMD ${batch_file}_$$.sh
103
104else
105   ${script_dir}/rebuild_nemo.exe $nam_rebuild
106fi
107
Note: See TracBrowser for help on using the repository browser.