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.
MultipleYearHindcast.pbs in NEMO/branches/UKMO/AMM15_v3_6_STABLE_new_ersem/NEMOGCM/CONFIG/AMM7_FABM_ERSEM/EXP01 – NEMO

source: NEMO/branches/UKMO/AMM15_v3_6_STABLE_new_ersem/NEMOGCM/CONFIG/AMM7_FABM_ERSEM/EXP01/MultipleYearHindcast.pbs @ 15814

Last change on this file since 15814 was 15480, checked in by jcastill, 3 years ago

Changes as in the git branch NEMO-FABMv1-ERSEM

File size: 4.5 KB
Line 
1#!/bin/bash --login
2#PBS -N AMM7-v0-4
3#PBS -l select=65
4#PBS -l walltime=48:00:00
5#PBS -q long
6##PBS -l select=8
7##PBS -l walltime=00:20:00
8##PBS -q short
9#PBS -A n01-PML
10
11# NOTE:
12# the simulation year must be passed to this pbs script at runtime
13# by defning externally the variable y0 passing it to the pbs script,
14# e.g.:
15# "qsub -v y0=1980 MultipleYearHindcast.pbs"
16#
17
18set -u
19
20NNODES=64
21#NNODES=8
22NCORES=$(( NNODES*24 ))
23
24echo "Submitting year" $y0 "..."
25
26ystart=1981
27yend=2010
28
29RUNDIR=/work/n01/n01/momme/AMM7-v0-erosion
30INPUTS=/work/n01/n01/momme/AMM7-INPUTS
31
32cd $RUNDIR
33
34stopflag=0
35
36#general time setting:
37dt=300 #time step
38nsstart=$(date -d "$ystart-01-01 00:00:00 GMT" +%s) #seconds since EPOCH for total simulation start
39
40for iy in {1..4} #annual increment
41do
42 if [ $y0 -le $yend ]
43 then
44  #cleanup:
45  ./annualclean.sh
46
47  #link annual forcing files:
48  ./setAnnualLinks.sh $y0
49
50  for m0 in {1..12} #Month loop
51  do
52   ./monthlyclean.sh
53   #Compute previous and next month:
54   mp=$(( $m0 + 1 ))
55   if [ $mp -eq 13 ]
56   then
57      mp=1
58      yp=$(( y0 + 1 ))
59   else
60      yp=$y0
61   fi
62   mm=$(( $m0 - 1 ))
63   if [ $mm -eq 0 ]
64   then
65      mm=12
66      ym=$(( y0 - 1 ))
67   else
68      ym=$y0
69   fi
70
71   m0str=$(printf %02d $m0)
72   mpstr=$(printf %02d $mp)
73   mmstr=$(printf %02d $mm)
74
75   echo "Launching" $y0 $m0 "..."
76
77   ARCHIVEDIR=$RUNDIR/$y0/$m0str
78
79   #restarts:
80   rm -rf restart.nc restart_trc.nc restart_[0-9]???.nc restart_trc_[0-9]???.nc
81   if [ $y0 -eq $ystart ] && [ $m0 -eq 1 ]
82   then
83      ln -sf $INPUTS/RESTARTS/restart.nc restart.nc
84      ln -sf $INPUTS/RESTARTS/restart_trc.full.nc restart_trc.nc
85      rst=0
86      euler=0
87   else
88      if [ -s $RUNDIR/$ym/$mmstr/restart_0000.nc ]
89      then
90         ln -sf $RUNDIR/$ym/$mmstr/restart_????.nc .
91      elif [ -s $RUNDIR/$ym/$mmstr/restart.nc ]
92      then
93         ln -sf $RUNDIR/$ym/$mmstr/restart.nc .
94      else
95         stopflag=1
96      fi
97      if [ -s $RUNDIR/$ym/$mmstr/restart_trc_0000.nc ]
98      then
99         ln -sf $RUNDIR/$ym/$mmstr/restart_trc_????.nc .
100      elif [ -s $RUNDIR/$ym/$mmstr/restart_trc.nc ]
101      then
102         ln -sf $RUNDIR/$ym/$mmstr/restart_trc.nc .
103      else
104         stopflag=1
105      fi
106      rst=2
107      euler=0
108   fi
109
110   #compute run-time:
111   case $m0 in
112      4|6|9|11) nit=$(( 86400*30/dt )) ;;
113      2) if [ $(( y0 % 4 )) -ne 0 -o $(( y0 % 100)) -eq 0 -a $(( $y0 % 400 )) -ne 0 ]; then nit=$(( 86400*28/dt )); else nit=$(( 86400*29/dt )); fi ;;
114      *) nit=$(( 86400*31/dt )) ;;
115   esac
116
117   #compute start iteration and end iteration:
118   ns0=$(date -d "$y0-${m0str}-01 00:00:00 GMT" +%s) #seconds since EPOCH for this chunk
119   n0=$(( ns0 - nsstart ))
120   n0=$(( n0 / dt + 1 ))
121   nend=$(( n0 + nit -1 ))
122   d0=$y0${m0str}01
123   if [ $y0 -lt 1990 -o $y0 -gt 2009 ]
124   then
125      lclim=.true.
126   else
127      lclim=.false.
128   fi
129   cat namelist.template \
130                | sed "s,__DATE0__,$d0,g" \
131                | sed "s,__RST__,$rst,g" \
132                | sed "s,__N0__,$n0,g" \
133                | sed "s,__NEND__,$nend,g" \
134                | sed "s,__LCLIM__,$lclim,g" \
135                | sed "s,__EULER__,$euler,g" \
136                > namelist_cfg
137   cat namelist_top.template \
138                | sed "s,__RST__,$rst,g" \
139                > namelist_top_cfg
140
141   if [ $stopflag -ne 0 ]
142   then
143      echo "Not ready to launch. Forced exit."
144      exit
145   fi
146
147   echo "Launching $y0 $m0 at $(date +%s) seconds since 1970-01-01 00:00:00 on $NCORES cores"
148
149   aprun -b -n 1 -N 1 -S 1 ./xios_server.exe : -n $NCORES -N 24 ./nemo.exe
150   #aprun -n 192 -N 24 ./nemo.exe
151
152   echo "Finished $y0 $m0 at $(date +%s) seconds since 1970-01-01 00:00:00"
153
154   #prepare archive directory
155   mkdir -p $ARCHIVEDIR
156   #prepare restart files:
157   for file in amm7_*${nend}_restart_????.nc
158   do
159      fn=${file: -7:4} #file number
160      mv $file $ARCHIVEDIR/restart_$fn.nc
161   done
162   for file in amm7_*${nend}_restart_trc_????.nc
163   do
164      fn=${file: -7:4} #file number
165      mv $file $ARCHIVEDIR/restart_trc_$fn.nc
166   done
167
168   #move outputs:
169   mv amm7_1d_${d0}_[1-2]???????_*.nc $ARCHIVEDIR
170   mv amm7_1m_${d0}_[1-2]???????_ptrc_T.nc $ARCHIVEDIR
171   mv amm7_1m_${d0}_[1-2]???????_grid_?.nc $ARCHIVEDIR
172   bzip2 ocean.output && mv -f ocean.output.bz2 $ARCHIVEDIR
173   mv -f time.step $ARCHIVEDIR
174
175   #archive:
176   fname=$y0/$m0str
177   echo "Archiving in $fname ..."
178   qsub -v folder=$fname archiveFolder.pbs
179
180  done #end of month loop
181  fi
182  y0=$(( y0+1 ))
183done #end of annual loop
184
185
186#resubmit:
187if [ $y0 -le $yend ]
188then
189   echo 'Submitting' $y0 '...'
190   qsub -v year=$yp QuadrAnnualChainHindcast.pbs
191   echo "Done."
192else
193   echo "All done."
194fi
Note: See TracBrowser for help on using the repository browser.