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