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.
Changeset 9048 for branches/2017/dev_merge_2017/NEMOGCM/TOOLS – NEMO

Ignore:
Timestamp:
2017-12-14T14:40:24+01:00 (6 years ago)
Author:
timgraham
Message:

New version of rebuild_nemo

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  
    11#!/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 
    124 
    135#set -ax 
     
    1810   echo "  ************" 
    1911   echo 
    20    echo "  usage: ${0##*/} [-t -c] filebase ndomain [rebuild dimensions]" 
     12   echo "  usage: ${0##*/} [-l -t -c -m -n] filebase ndomain [rebuild dimensions]" 
    2113   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)" 
    2421   echo 
    2522   exit 1 
    2623} 
    2724 
    28 while getopts c:t: opt 
     25while getopts c:n:t:d:r:lm opt 
    2926do 
    3027  case ${opt} in 
     28      l)  
     29         BATCH="yes" 
     30         BATCH_CMD="qsub"  
     31         ARCH="XC40_METO" 
     32         echo "Submitting job to compute node" 
     33      ;; 
    3134      t) 
    3235         OMP_NUM_THREADS=${OPTARG} 
     
    3538         NCHUNKSIZE=${OPTARG} 
    3639      ;; 
     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      ;; 
    3753  esac 
    3854done 
    3955shift $(expr ${OPTIND} - 1) 
    4056 
    41 if [[ $# < 2 ]] ; then 
     57if [[ $# -lt 2 ]] ; then 
    4258   usage 
    4359fi 
     
    4965DIM1=$3 
    5066DIM2=$4 
    51 export OMP_NUM_THREADS=${OMP_NUM_THREADS:-16} 
     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 
    5276 
    5377if [[ -n ${DIM1} && -n ${DIM2} ]] ; then 
    5478   dim_str=" dims '${DIM1}','${DIM2}'" 
    5579   dims="dims='${DIM1}','${DIM2}'" 
    56    echo ${dim_str} >> nam_rebuild 
    5780fi 
    5881 
    5982echo "file ${file},  num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}" 
    6083 
    61 cat > nam_rebuild << EOC 
     84cat > $nam_rebuild << EOC 
    6285&nam_rebuild 
    6386filebase='${file}' 
     
    6588EOC 
    6689if [[ -n ${dims} ]] ; then 
    67    echo ${dims} >> nam_rebuild 
     90   echo ${dims} >> $nam_rebuild 
    6891fi 
    6992if [[ -n ${NCHUNKSIZE} ]] ; then 
    70    echo " nchunksize=${NCHUNKSIZE}" >> nam_rebuild 
     93   echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild 
    7194fi 
    72 echo "/" >> nam_rebuild 
     95if [[ -n ${NMASK} ]] ; then 
     96   echo " l_maskout=.true." >> $nam_rebuild 
     97fi 
     98if [[ -n ${DEFLATE} ]] ; then 
     99   echo " deflate_level=${DEFLATE}" >> $nam_rebuild 
     100fi 
    73101 
    74 # run the rebuild code 
    75 ${script_dir}/rebuild_nemo.exe  
     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 TracChangeset for help on using the changeset viewer.