source: CONFIG/UNIFORM/v6/NEMO_v6.5/GENERAL/DRIVER/pisces.driver @ 6230

Last change on this file since 6230 was 6230, checked in by cetlod, 16 months ago

NEMOv6.5 : Improvment of ORCA2 PISCES run offline when using IPSL-CM5 outputs ocean dynamic

File size: 10.6 KB
Line 
1#!/bin/ksh
2
3#-----------------------------------
4function MBG_Initialize
5{ 
6    IGCM_debug_PushStack "MBG_Initialize"
7
8# Local function to find namelists parameters
9supergrep () {
10    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
11}
12
13    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
14
15       if [ X$ResolOce != X ]; then
16          #ResolOce is set in config.card
17          RESOL_OCE=${ResolOce}
18       else
19          RESOL_OCE=${config_UserChoices_ExpType%%_*}
20       fi
21       ORCAGRID=${opa9_UserChoices_ORCA_version%%.*}
22       exptype=${config_UserChoices_ExpType##*/}
23
24       IGCM_debug_Print 1 " "
25       IGCM_debug_Print 1 "RESOL_OCE        : ${RESOL_OCE}"
26       IGCM_debug_Print 1 "ORCAGRID         : ${ORCAGRID}"
27       IGCM_debug_Print 1 "EXPERIMENT TYPE  : ${exptype}"
28
29
30       OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}/namelist_offline_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
31       # Period Length In Days between DateBegin and first day of calendar 0001 01 01
32       # /!\ Needed by OPA namelist to compute file names /!\
33       (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
34
35       (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
36       (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
37
38
39       IGCM_debug_Print 1 " "
40       IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
41       IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
42       IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
43
44     fi
45
46    IGCM_debug_PopStack "MBG_Initialize"
47}
48
49#-----------------------------------
50function MBG_Update
51{
52    IGCM_debug_PushStack "MBG_Update"
53
54   
55    ##--Write Frequency for iomput
56    ## Differents frequencies are allowed for MBG files
57
58    VT1D_ENABLE=".FALSE."
59    VT5D_ENABLE=".FALSE."
60    VT1M_ENABLE=".FALSE."
61    VT1Y_ENABLE=".FALSE."
62
63    for frequency in ${config_MBG_WriteFrequency} ; do
64        case ${frequency} in
65            ( 1D|1d ) VT1D_ENABLE=".TRUE." ;;
66            ( 5D|5d ) VT5D_ENABLE=".TRUE." ;;
67            ( 1M|1m ) VT1M_ENABLE=".TRUE." ;;
68            ( *[yY] ) VT1Y_ENABLE=".TRUE." ;;
69        esac
70    done
71
72
73    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
74
75       # Period Length In Days between DateBegin and first day of calendar 0001 01 01
76       # Needed by OPA namelist to compute correct file names
77       (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
78
79       ## Count of number of time steps from begin of OPA job
80       (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
81       (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
82       (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
83
84       ## Forcing to write one restart file at the end of period
85       OPA_NSTOCK="${OPA_NITEND}"
86
87       # nleapy configuration
88       case ${config_UserChoices_CalendarType} in
89           leap)
90               OPA_NLEAPY=1;;
91           noleap)
92               OPA_NLEAPY=0;;
93           360d)
94               OPA_NLEAPY=30;;
95       esac
96
97       typeset -r PRECIS=8
98       NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) )
99
100
101       DYN_SSH_INI=.TRUE.
102       if [ "${exptype}" = "ia"   ] ; then
103          NbDynFile=${#pisces_UserChoices_DynFiles[*]}
104          (( LengthForcing=${pisces_UserChoices_DynYearEnd} - ${pisces_UserChoices_DynYearStart} + 1 ))
105          (( DiffForcing=abs( ${pisces_UserChoices_DynYearEnd} - ${year} ) ))
106          (( ModuloForcing=${DiffForcing} % ${LengthForcing} ))
107          if [ ${ModuloForcing} -eq 0 ] ; then
108             (( year_forcing=${pisces_UserChoices_DynYearEnd} ))
109          else
110             if [ ${year} -ge ${pisces_UserChoices_DynYearStart} ] && [ ${year} -le ${pisces_UserChoices_DynYearEnd} ] ; then
111                year_forcing=${year}
112             elif [ ${year} -lt ${pisces_UserChoices_DynYearStart} ] ; then
113                (( year_forcing=${pisces_UserChoices_DynYearEnd} - ${ModuloForcing} ))
114             else
115                (( year_forcing=${pisces_UserChoices_DynYearStart} + ${ModuloForcing} - 1 ))
116             fi
117          fi
118          (( year_forcing_m1 = ${year_forcing} - 1))
119          (( year_forcing_p1 = ${year_forcing} + 1))
120          eval CurrDateFor=${year_forcing}0101_${year_forcing}1231
121          eval PrevDateFor=${year_forcing_m1}0101_${year_forcing_m1}1231
122          eval NextDateFor=${year_forcing_p1}0101_${year_forcing_p1}1231
123          (( i = 0 ))
124           while [ $i -lt ${NbDynFile} ] ; do
125             eval Suffix=${pisces_UserChoices_DynFiles[$i]}
126             eval RunFileName=${pisces_UserChoices_DynRunName}_${Suffix}
127             eval PrevDynFileName=${pisces_UserChoices_DynName}_${PrevDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
128             eval CurrDynFileName=${pisces_UserChoices_DynName}_${CurrDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
129             eval NextDynFileName=${pisces_UserChoices_DynName}_${NextDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
130             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${PrevDynFileName}.nc  ${RunFileName}_y${year_m1}.nc
131             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${CurrDynFileName}.nc  ${RunFileName}_y${year}.nc
132             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${NextDynFileName}.nc  ${RunFileName}_y${year_p1}.nc
133             ln -sf ${RunFileName}_y${year}.nc ${RunFileName}.nc
134             (( i = i + 1 ))
135          done
136          if [ ${year_forcing} = ${pisces_UserChoices_DynYearStart} ] ; then
137             DYN_SSH_INI=.TRUE.
138          else
139             DYN_SSH_INI=.FALSE
140          fi
141       fi
142    fi
143   
144    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
145       if [ X"${pisces_UserChoices_Offline_DynTrp}" = X"y" ] ; then
146          OFF_DYNTRP=.TRUE.
147       else
148          OFF_DYNTRP=.FALSE.
149       fi
150    fi
151    ##-- Restart configuration
152    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
153
154        #echo "NO RESTART FOR TOP"
155        TOP_LRSTTR=.FALSE.
156        TOP_NRSTTR=0
157
158    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
159
160        #echo "RESTART TOP"
161        TOP_LRSTTR=.TRUE.
162        TOP_NRSTTR=0
163
164    else
165
166        #echo "RESTART TOP"
167        TOP_LRSTTR=.TRUE.
168        TOP_NRSTTR=2
169    fi
170
171# on force les sorties PISCES comme les sorties OPA
172    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
173      IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
174      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
175      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
176      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock  ${OPA_NSTOCK}
177      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0  ${PeriodDateBegin}
178      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY}
179      IGCM_comp_modifyNamelist blocker    namelist_cfg ln_dyntrp ${OFF_DYNTRP}
180
181# update domain_def.xml file
182      case ${RESOL_OCE} in
183          ( *ORCA025* ) 
184            sed -e 's/<zoom_domain id="1point" ibegin="139" jbegin="119"/<zoom_domain id="1point" ibegin="600" jbegin="600"/' domain_def_nemo.xml > domain_def.xml.tmp 
185            IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml  ;
186      esac
187
188      IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear}
189
190   fi
191
192   if [ X"${pisces_UserChoices_pis}" = X"n" ] ; then
193      echo "DeActivate pisces outputs"
194      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file33 enabled .FALSE.
195      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file34 enabled .FALSE.
196      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file35 enabled .FALSE.
197      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file36 enabled .FALSE.
198      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file37 enabled .FALSE.
199   fi
200
201   if [ X"${pisces_UserChoices_age}" = X"y" ] ; then
202      echo "Activate age tracer"
203      TOP_AGE=.TRUE.
204      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file38 enabled .TRUE.
205   else
206      TOP_AGE=.FALSE.
207   fi
208##
209   if [ X"${pisces_UserChoices_cfc11}" = X"y" ] ; then
210      echo "Activate CFC11  tracer"
211      TOP_CFC11=.TRUE.
212      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file39 enabled .FALSE.
213   else
214      TOP_CFC11=.FALSE.
215   fi
216##
217   if [ X"${pisces_UserChoices_cfc12}" = X"y" ] ; then
218      echo "Activate CFC12  tracer"
219      TOP_CFC12=.TRUE.
220      IGCM_comp_modifyXmlFile force file_def_nemo-top.xml file40 enabled .TRUE.
221   else
222      TOP_CFC12=.FALSE.
223   fi
224##
225   if [ X"${pisces_UserChoices_Co2Anthr}" = X"y" ] ; then
226      LCO2INT=.TRUE.
227   else
228      LCO2INT=.FALSE.
229   fi
230   ##-- Update namelist_top_cfg and namelist_pisces_cfg
231    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_rsttr  ${TOP_LRSTTR}
232    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     nn_rsttr  ${TOP_NRSTTR}
233    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_age    ${TOP_AGE}
234    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_cfc11  ${TOP_CFC11}
235    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_cfc12  ${TOP_CFC12}
236    if [ X"${pisces_UserChoices_pis}" = X"y" ] ; then
237       IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  ln_co2int ${LCO2INT}
238       IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  atcco2    ${pisces_UserChoices_AtmCo2}
239       IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nrdttrc   ${pisces_UserChoices_PisFreq}
240       IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nn_pisdmp ${OPA_NPDT_YEAR}
241    fi
242 
243    # Update iodef.xml
244
245    IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE '
246    IGCM_debug_Print 1 ${VT1D_ENABLE}  ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE}
247
248    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1d_pis enabled ${VT1D_ENABLE}
249    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 5d_pis enabled ${VT5D_ENABLE}
250    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1m_pis enabled ${VT1M_ENABLE}
251    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1y_pis enabled ${VT1Y_ENABLE}
252
253    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1d_pis output_level ${pisces_UserChoices_OutputLevel}
254    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 5d_pis output_level ${pisces_UserChoices_OutputLevel}
255    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1m_pis output_level ${pisces_UserChoices_OutputLevel}
256    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-top.xml 1y_pis output_level ${pisces_UserChoices_OutputLevel}
257
258
259
260   IGCM_debug_PopStack "MBG_Update"
261}
262
263#-----------------------------------
264function MBG_Finalize
265{
266    IGCM_debug_PushStack "MBG_Finalize"
267
268    echo FINALIZE MBG !!!
269
270    IGCM_debug_PopStack "MBG_Finalize"
271}
272
Note: See TracBrowser for help on using the repository browser.