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 7683 for branches – NEMO

Changeset 7683 for branches


Ignore:
Timestamp:
2017-02-15T12:53:23+01:00 (7 years ago)
Author:
timgraham
Message:

#1848 First commit of modified code

Location:
branches/UKMO/dev_r7681_rebuild_nemo/NEMOGCM/TOOLS/REBUILD_NEMO
Files:
4 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r7681_rebuild_nemo/NEMOGCM/TOOLS/REBUILD_NEMO/rebuild_nemo

    r3025 r7683  
    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)" 
    2420   echo 
    2521   exit 1 
    2622} 
    2723 
    28 while getopts c:t: opt 
     24while getopts c:n:t:d:lm opt 
    2925do 
    3026  case ${opt} in 
     27      l)  
     28         BATCH="yes" 
     29         BATCH_CMD="qsub"  
     30         ARCH="XC40_METO" 
     31         echo "Submitting job to compute node" 
     32      ;; 
    3133      t) 
    3234         OMP_NUM_THREADS=${OPTARG} 
     
    3537         NCHUNKSIZE=${OPTARG} 
    3638      ;; 
     39      m)  
     40         NMASK="TRUE" 
     41      ;; 
     42      d) 
     43         DEFLATE=${OPTARG} 
     44      ;; 
     45      n) 
     46         nam_rebuild=${OPTARG} 
     47      ;; 
    3748  esac 
    3849done 
    3950shift $(expr ${OPTIND} - 1) 
    4051 
    41 if [[ $# < 2 ]] ; then 
     52if [[ $# -lt 2 ]] ; then 
    4253   usage 
    4354fi 
     
    4960DIM1=$3 
    5061DIM2=$4 
    51 export OMP_NUM_THREADS=${OMP_NUM_THREADS:-16} 
     62export OMP_NUM_THREADS=${OMP_NUM_THREADS:-1} 
     63nam_rebuild=${nam_rebuild:-nam_rebuild_$$} 
    5264 
    5365if [[ -n ${DIM1} && -n ${DIM2} ]] ; then 
    5466   dim_str=" dims '${DIM1}','${DIM2}'" 
    5567   dims="dims='${DIM1}','${DIM2}'" 
    56    echo ${dim_str} >> nam_rebuild 
    5768fi 
    5869 
    5970echo "file ${file},  num_domains ${ndomain}, num_threads ${OMP_NUM_THREADS}${dim_str}" 
    6071 
    61 cat > nam_rebuild << EOC 
     72cat > $nam_rebuild << EOC 
    6273&nam_rebuild 
    6374filebase='${file}' 
     
    6576EOC 
    6677if [[ -n ${dims} ]] ; then 
    67    echo ${dims} >> nam_rebuild 
     78   echo ${dims} >> $nam_rebuild 
    6879fi 
    6980if [[ -n ${NCHUNKSIZE} ]] ; then 
    70    echo " nchunksize=${NCHUNKSIZE}" >> nam_rebuild 
     81   echo " nchunksize=${NCHUNKSIZE}" >> $nam_rebuild 
    7182fi 
    72 echo "/" >> nam_rebuild 
     83if [[ -n ${NMASK} ]] ; then 
     84   echo " l_maskout=.true." >> $nam_rebuild 
     85fi 
     86if [[ -n ${DEFLATE} ]] ; then 
     87   echo " deflate_level=${DEFLATE}" >> $nam_rebuild 
     88fi 
    7389 
    74 # run the rebuild code 
    75 ${script_dir}/rebuild_nemo.exe  
     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 TracChangeset for help on using the changeset viewer.