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.
opa9.driver in trunk/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP – NEMO

source: trunk/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/IGCM00/COMP/opa9.driver @ 2528

Last change on this file since 2528 was 2528, checked in by rblod, 13 years ago

Update NEMOGCM from branch nemo_v3_3_beta

  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function OCE_Initialize
4{
5    IGCM_debug_PushStack "OCE_Initialize"
6
7    JOB_NAME=${config_UserChoices_JobName}
8
9    OPA_NDT_DAY=${opa_UserChoices_OPA_NDT_DAY:=15}
10
11
12    ##--Variables used by OPA --
13
14    # cn_exp experience name for vairmer format
15    # nn_it000 number of the first time step
16    # nn_itend number of the last time step
17    # nn_leapy leap year calendar (0/1) (30 for 360d)
18    # nn_write frequency of OUTPUT file
19    # ln_rstart boolean term for restart (true or false)
20    # nn_stock frequency of restart file
21    # nn_rstctl control of the time step (0, 1 or 2)
22    # nn_date0 initial calendar date aammjj
23    # nn_msh  =1 create a mesh file (coordinates, scale factors, masks)
24    # rn_rdt time step in seconds (coming from namelist)
25    # nf_ptr_wri frequency of zonal means and transport output
26
27
28# Local function to find namelists parameters
29supergrep () {
30    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
31}
32
33
34    PAT_CEXPER=$( supergrep cn_exp    ${SUBMIT_DIR}/PARAM/namelist )
35    PAT_NIT000=$( supergrep nn_it000    ${SUBMIT_DIR}/PARAM/namelist )
36    PAT_NITEND=$( supergrep nn_itend    ${SUBMIT_DIR}/PARAM/namelist )
37    PAT_NLEAPY=$( supergrep nn_leapy    ${SUBMIT_DIR}/PARAM/namelist )
38    PAT_RESTAR=$( supergrep ln_rstart ${SUBMIT_DIR}/PARAM/namelist )
39    PAT_NSTOCK=$( supergrep nn_stock    ${SUBMIT_DIR}/PARAM/namelist )
40    PAT_NRSTAR=$( supergrep nn_rstctl    ${SUBMIT_DIR}/PARAM/namelist )
41    PAT_NDATE0=$( supergrep nn_date0    ${SUBMIT_DIR}/PARAM/namelist )
42    PAT_NMSH=$(   supergrep nn_msh      ${SUBMIT_DIR}/PARAM/namelist ) 
43   
44
45    OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/namelist | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
46
47    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
48    # /!\ Needed by OPA namelist to compute file names /!\
49    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
50
51    # Definition from opa9.card of List_jobsbc and List_runsbc used to do to interannual and climatological runs
52   IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/opa9.card Interannual List_jobsbc
53   IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/opa9.card Interannual List_runsbc
54        set -A ListFormulationJobsbc -- \${opa9_Interannual_Listjobsc${opa9_Interannual_List_jobsbc}[*]}
55        set -A ListFormulationRunsbc -- \${opa9_Interannual_Listrunsbc${opa9_Interannual_List_runsbc}[*]}
56
57    ##--Variables used for XMLIO_SERVER configuration file
58       # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
59       PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def )
60   
61    IGCM_debug_PopStack "OCE_Initialize"
62}
63
64#-----------------------------------------------------------------
65function OCE_Update
66{
67    IGCM_debug_PushStack "OCE_Update"
68
69    # Interannual run
70    # In this case job need to calculate previous and following year and give, and if every run needs to add "_y" before every year
71    if [ X${opa9_UserChoices_Interannual_Run} = Xy ] ; then
72
73   typeset file fileo
74
75        eval NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
76
77   (( i = 0 ))
78   while [ $i -lt ${NbFileInter} ] ; do
79       eval file=${opa9_Interannual_List_jobsbc[$i]}
80       eval jobsbc_file_ym1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year - 1 )).nc
81       eval jobsbc_file_y=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_${year}.nc
82       eval jobsbc_file_yp1=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}_$(( year + 1 )).nc
83     # Copy of List_jobsbc in List_runsbc if this last one is empty
84            if [ X${opa9_Interannual_List_runsbc[0]} = X${NULL_STR} ] ; then
85         eval fileo=${opa9_Interannual_List_jobsbc[$i]}
86               eval runsbc_file_ym1=${file}_y$(( year - 1 )).nc
87               eval runsbc_file_y=${file}_y${year}.nc
88               eval runsbc_file_yp1=${file}_y$(( year + 1 )).nc
89       else
90         eval fileo=${opa9_Interannual_List_runsbc[$i]}
91               eval runsbc_file_ym1=${fileo}_y$(( year - 1 )).nc
92               eval runsbc_file_y=${fileo}_y${year}.nc
93               eval runsbc_file_yp1=${fileo}_y$(( year + 1 )).nc
94      fi
95
96       if [ X${Period} = X1 ] ; then
97      if [ ${month} -eq 01 ] ; then
98          IGCM_sys_Get ${jobsbc_file_ym1} ${runsbc_file_ym1}
99      fi
100      if [ ! -f ${runsbc_file_y} ] ; then
101          IGCM_sys_Get ${jobsbc_file_y} ${runsbc_file_y}
102      fi
103      if [ ! -f ${runsbc_file_yp1} ] ; then
104          IGCM_sys_Get ${jobsbc_file_yp1} ${runsbc_file_yp1}
105      fi
106       else
107      if [ ! -f ${runsbc_file_yp1} ] ; then
108          IGCM_sys_Get ${jobsbc_file_yp1} ${runsbc_file_yp1}
109      fi
110       fi 
111
112       (( i = i + 1 ))
113   done
114    # End interannual
115    elif [ X${opa9_UserChoices_Interannual_Run} = Xn ] ; then
116    # Climatological run
117       typeset file fileo
118
119       eval NbFileInter=${#opa9_Interannual_List_jobsbc[*]}
120
121        (( i = 0 ))
122        while [ $i -lt ${NbFileInter} ] ; do
123            eval file=${opa9_Interannual_List_jobsbc[$i]}
124            eval jobsbc_file=${R_BC}/OCE/${config_UserChoices_TagName}/${opa9_UserChoices_OPA_version}/${file}.nc
125            if [ X${opa9_Interannual_List_runsbc[0]} = X${NULL_STR} ] ; then
126         eval fileo=${opa9_Interannual_List_jobsbc[$i]}
127               eval runsbc_file=${fileo}.nc
128       else
129         eval fileo=${opa9_Interannual_List_runsbc[$i]}
130               eval runsbc_file=${fileo}.nc
131      fi
132
133            IGCM_sys_Get ${jobsbc_file} ${runsbc_file}
134            (( i = i + 1 ))
135   done
136    fi
137    # End climatological
138
139    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
140
141    ##--Write Frequency Purpose ....
142    typeset -Z1 i=1
143    while [ $i -le ${NbFreq} ]; do
144        frequency=$( echo ${config_OCE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
145      factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
146      case ${frequency} in
147          *Y|*y)
148              eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
149              eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_Y} ;
150              eval WF${i}=${factor}Y ;;
151          *M|*m)
152              eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
153              eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_M} ;
154              eval WF${i}=${factor}M ;;
155          *D|*d)
156              eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
157              eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_D} ;
158              eval WF${i}=${factor}D ;;
159          *)
160      esac
161        let i=$i+1
162
163    done
164    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
165    # Needed by OPA namelist to compute correct file names
166    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
167
168    ## Count of number of time steps from begin of OPA job
169    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NDT_DAY + 1 ))
170    (( OPA_NDT   = PeriodLengthInDays * OPA_NDT_DAY ))
171    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
172
173    ## Forcing to write one restart file at the end of period
174    OPA_NSTOCK="${OPA_NITEND}"
175
176    ## Verification of number of time steps per day
177    (( NB_SEC_DAY_MODEL = OPA_NDT_DAY * OPA_RDT ))
178    (( NB_SEC_DAY = 60 * 60 * 24 ))
179
180    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
181   then
182        echo " VERIFY OPA_NDT_DAY in opa9.card "
183        exit
184    fi
185
186    ##-- Restart configuration
187    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
188
189        #echo "NO OPA RESTART"
190   OPA_LRSTAR=.FALSE.
191   OPA_NRSTDT=0
192        #Put OPA_NMSH=0 when OPA runnig in parallel mode
193   OPA_NMSH=1
194   ( [ X${BATCH_NUM_PROC_TOT} != X ] && [ "${BATCH_NUM_PROC_TOT}" -gt 1 ] ) && OPA_NMSH=0
195
196    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
197
198        #echo "OPA RESTART"
199   OPA_LRSTAR=.TRUE.
200   OPA_NRSTDT=1
201   OPA_NMSH=0
202
203    else
204
205        #echo "OPA RESTART"
206   OPA_LRSTAR=.TRUE.
207   OPA_NRSTDT=2
208   OPA_NMSH=0
209
210    fi
211   
212     ## nleapy configuration
213   case ${config_UserChoices_CalendarType} in
214         leap)
215               OPA_NLEAPY=1;;
216         noleap)
217               OPA_NLEAPY=0;;
218         360d)
219               OPA_NLEAPY=30;;
220      esac
221
222
223        typeset -r PRECIS=8
224   NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
225
226    sed -e "s%${PAT_CEXPER}%       cn_exp=\"${config_UserChoices_JobName}\"%" \
227   -e "s%${PAT_NIT000}%       nn_it000=${OPA_NIT000}%"                    \
228   -e "s%${PAT_NITEND}%       nn_itend=${OPA_NITEND}%"                    \
229   -e "s%${PAT_RESTAR}%       ln_rstart=${OPA_LRSTAR}%"                 \
230   -e "s%${PAT_NSTOCK}%       nn_stock=${OPA_NSTOCK}%"                    \
231   -e "s%${PAT_NRSTAR}%       nn_rstctl=${OPA_NRSTDT}%"                    \
232   -e "s%${PAT_NDATE0}%       nn_date0=${PeriodDateBegin}%"                \
233   -e "s%${PAT_NMSH}%         nn_msh=${OPA_NMSH}%"                        \
234   -e "s%${PAT_NLEAPY}%       nn_leapy=${OPA_NLEAPY}%"                 \
235   namelist > namelist.tmp
236
237    IGCM_sys_Mv namelist.tmp namelist
238
239    # update xmlio_server.def
240
241    if [ X${opa9_UserChoices_io_server} = Xy ] ; then
242        sed -e "s/${PAT_SERVER}/  using_server = .TRUE./" \
243        xmlio_server.def > xmlio_server.def.tmp
244        IGCM_sys_Mv xmlio_server.def.tmp xmlio_server.def
245    fi
246   
247    IGCM_debug_PopStack "OCE_Update"
248}
249
250#-----------------------------------
251function OCE_Finalize
252{
253    IGCM_debug_PushStack "OCE_Finalize"
254
255    if [ -f date.file ] ; then
256        # Prefix use in opa.card AND in lim2.card :
257   DATE_OPA=$( cat date.file | \
258       sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
259        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
260   MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
261   SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
262    fi
263
264    echo FINALIZE OCE !!!
265
266    IGCM_debug_PopStack "OCE_Finalize"
267}
Note: See TracBrowser for help on using the repository browser.