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/EXP04 – NEMO

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