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.
AnnualChainHindcast.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/AnnualChainHindcast.pbs @ 15480

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

Changes as in the git branch NEMO-FABMv1-ERSEM

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