source: CONFIG/UNIFORM/v6/IPSLESM6/GENERAL/DRIVER/opa9.driver @ 3687

Last change on this file since 3687 was 3687, checked in by acosce, 6 years ago

Update IPSLESM to comply with v6 standard and add the AER experiment for the coupled model

File size: 9.9 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    RESOL_OCE_ICE=$( echo ${RESOL} | awk "-Fx" '{print $1}' )
10    case ${RESOL_OCE_ICE} in
11        ( *LIM2* ) SEAICE_MODEL=LIM2 ;  LIM_VERSION=2 ;;
12        ( *LIM3* ) SEAICE_MODEL=LIM3 ;  LIM_VERSION=3 ;;
13        ( *CICE* ) SEAICE_MODEL=CICE                  ;;
14        ( *      ) SEAICE_MODEL=UNKNOWN               ;;
15    esac
16    RESOL_OCE=$( echo ${RESOL_OCE_ICE} | sed "s/${SEAICE_MODEL}//" )
17
18    IGCM_debug_Print 1 "RESOL          : ${RESOL}"
19    IGCM_debug_Print 1 "RESOL_OCE_ICE  : ${RESOL_OCE_ICE}"
20    IGCM_debug_Print 1 "SEAICE_MODEL   : ${SEAICE_MODEL}"
21    IGCM_debug_Print 1 "LIM_VERSION    : ${LIM_VERSION}"
22    IGCM_debug_Print 1 "RESOL_OCE      : ${RESOL_OCE}"
23
24    # Local function to find namelists parameters
25    #supergrep () { grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" ; }
26    supergrep () { grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" -e "s%^ *$1 *=%%" ; }
27    ##--Variables used by OPA --
28    NAMELIST_OPA_CFG=${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}_cfg
29    IGCM_debug_Print 1 "namelist_cfg : ${NAMELIST_OPA_CFG}"
30    if [ ! -r ${NAMELIST_OPA_CFG} ] ; then
31        IGCM_debug_Exit "${NAMELIST_OPA_CFG} not found"
32        IGCM_debug_Verif_Exit
33    fi
34    OPA_RDT=$(       supergrep rn_rdt        ${NAMELIST_OPA_CFG} )
35    OPA_NN_FSBC=$(   supergrep nn_fsbc       ${NAMELIST_OPA_CFG} )
36    #
37    # OPA_RDT=$(       supergrep rn_rdt        namelist_cfg )
38    # OPA_NN_FSBC=$(   supergrep nn_fsbc       namelist_cfg )
39    (( OPA_NPDT_DAY   =  86400 / OPA_RDT        ))
40    (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
41    (( OPA_RDT_SBC    =  OPA_RDT * OPA_NN_FSBC ))
42 
43    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
44    # /!\ Needed by OPA namelist to compute file names /!\
45    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
46
47    IGCM_debug_Print 1 " "
48    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
49    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
50    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
51    IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
52    IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
53    IGCM_debug_Print 1 "DaysSinceJC    ${DaysSinceJC}"
54
55    ## Check that nn_fsbc is correct compare to coupling frequency
56    FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
57   
58    ## This informations are used for diaptr, trends and diagap files
59    ## only the first frequency is used for this files
60   
61    IGCM_debug_Print 1 "FreqCoupling    ${FreqCoupling}"
62    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
63    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
64    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
65   
66    if [[ ${OPA_RDT_SBC} -gt ${FreqCoupling} ]] ; then
67        IGCM_debug_Exit "OPA_RDT_SBC=${OPA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}"
68        IGCM_debug_Verif_Exit
69    fi
70   
71    IGCM_debug_PopStack "OCE_Initialize"
72   
73}
74
75#-----------------------------------------------------------------
76function OCE_Update
77{
78    IGCM_debug_PushStack "OCE_Update"
79 
80    ##--Write Frequency for iomput
81    ## Differents frequencies are allowed for OCE files
82
83    V1D_ENABLE=".FALSE."
84    V5D_ENABLE=".FALSE."
85    V1M_ENABLE=".FALSE."
86    V1Y_ENABLE=".FALSE."
87
88    for frequency in ${config_OCE_WriteFrequency} ; do
89        case ${frequency} in
90            ( 1D|1d ) V1D_ENABLE=".TRUE." ;;
91            ( 5D|5d ) V5D_ENABLE=".TRUE." ;;
92            ( 1M|1m ) V1M_ENABLE=".TRUE." ;;
93            ( *[yY] ) V1Y_ENABLE=".TRUE." ;;
94        esac
95    done
96
97    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
98    # Needed by OPA namelist to compute correct file names
99    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
100
101    ##-- Number of time steps updated : the first, the last and the number of time steps
102    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
103    (( OPA_NPDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
104    (( OPA_NITEND = OPA_NIT000 + OPA_NPDT - 1))
105
106    ##-- We force one restart file at the end of the trunk
107    OPA_NSTOCK="${OPA_NITEND}"
108
109
110    ##-- Additionnal Restart Option to force reproducibility ; force kt to kt red in restart file
111    ## ${opa9_UserChoices_Reproducibility_after_restart}
112
113    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices Reproducibility_after_restart
114
115   ##-- Restart configuration
116    if ( [ "${opa9_UserChoices_Reproducibility_after_restart}" = "y" ] ) ; then
117      OPA_LRSTAR=.TRUE.
118      OPA_NRSTDT=2
119      #echo "OPA RESTART"
120      IGCM_debug_Print 1 'WARNING : dangerous option'
121      IGCM_debug_Print 1 'Reproducibility_after_Restart forced ie kt forced to kt red in restart file : ' ${opa9_UserChoices_Reproducibility_after_restart}
122    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
123      OPA_LRSTAR=.FALSE.
124      OPA_NRSTDT=0
125      #echo "NO OPA RESTART"
126    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
127      OPA_LRSTAR=.TRUE.
128      OPA_NRSTDT=0
129      #echo "OPA RESTART"
130    else
131      OPA_LRSTAR=.TRUE.
132      OPA_NRSTDT=2
133      #echo "OPA RESTART"
134    fi
135
136    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${opa9_UserChoices_Restart_TS_only}" = "y" ] ) ; then
137      OPA_LRSTAR_TS=.TRUE.
138    else
139      OPA_LRSTAR_TS=.FALSE.
140    fi
141
142    ##-- Meshmask option. Forced only once.
143    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask
144
145    OPA_NMSH=0
146    if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
147        OPA_NMSH=1
148        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
149    fi
150
151    # nleapy configuration
152    case ${config_UserChoices_CalendarType} in
153        ( leap|gregorian) OPA_NLEAPY=1  ;;
154        ( noleap        ) OPA_NLEAPY=0  ;;
155        ( 360d          ) OPA_NLEAPY=30 ;;
156        ( *             ) OPA_NLEAPY=30 ;;
157    esac
158
159    if ( [ "${opa9_UserChoices_Reproducibility_after_restart}" = "y" ] ) ; then
160      NEMO_KT_FROM_RESTART=$(ncdump -v kt restartopa_0000.nc|grep 'kt ='|awk '{print $3}' )
161      (( NEMO_NIT000 = NEMO_KT_FROM_RESTART + 1 ))
162      (( NEMO_NITEND = NEMO_KT_FROM_RESTART + OPA_NITEND - OPA_NIT000 + 1 ))
163      IGCM_debug_Print 1 "NEMO_NIT000 (from Restart)        : ${NEMO_NIT000}"
164      IGCM_debug_Print 1 "NEMO_NITEND (from Restart + ... ) : ${NEMO_NITEND}"
165      ##-- We force one restart file at the end of the trunk
166      OPA_NSTOCK="${NEMO_NITEND}"
167      OPA_NIT000="${NEMO_NIT000}"
168      OPA_NITEND="${NEMO_NITEND}"
169    fi
170
171    typeset -r PRECIS=8
172    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
173
174    IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp       ${config_UserChoices_JobName}
175    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000     ${OPA_NIT000}
176    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend     ${OPA_NITEND}
177    IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart    ${OPA_LRSTAR}
178    IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart_ts ${OPA_LRSTAR_TS}
179    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock     ${OPA_NSTOCK}
180    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl    ${OPA_NRSTDT}
181    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0     ${PeriodDateBegin}
182    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh       ${OPA_NMSH}
183    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_rnf_depth_file  ${OPA_NMSH}
184    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy     ${OPA_NLEAPY}
185   
186    # Update iodef.xml
187
188    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then       
189        V1D_ENABLE=".FALSE."
190        V5D_ENABLE=".FALSE."
191        V1M_ENABLE=".FALSE."
192        V1Y_ENABLE=".FALSE."
193    fi
194
195    IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V5D_ENABLE V1M_ENABLE V1Y_ENABLE '
196    IGCM_debug_Print 1 ${V1D_ENABLE}  ${V5D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE}
197
198    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1d_opa enabled ${V1D_ENABLE}
199    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 5d_opa enabled ${V5D_ENABLE}
200    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1m_opa enabled ${V1M_ENABLE}
201    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1y_opa enabled ${V1Y_ENABLE}
202
203    IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${opa9_UserChoices_TimeOrigin}
204       
205 
206    # vargas/titane/MPP and switch from 1 proc to 5 procs. We need to suppres restartopa the second month, if restartopa_0000 exist
207    # same thing for restart_trc and restart_ice_in
208
209    for restartfilenemo in restartopa restart_trc restart_ice_in ; do
210      [ -f ${restartfilenemo}.nc ] && [ -f ${restartfilenemo}_0000.nc ] && IGCM_sys_Rm -f ${restartfilenemo}.nc
211    done
212
213    # Add include of nemo context in iodef.xml
214    # In iodef.xml add on next line after "COMPONENT CONTEXT"
215    #  <context id="nemo" src="./context_nemo.xml"/>
216    echo '<context id="nemo" src="./context_nemo.xml"/>' > add.tmp
217    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
218        echo '<context id="nemo" src="./ping_nemo.xml"/>' >> add.tmp
219        echo '<context id="nemo" src="./dr2xml_opa9.xml"/>' >> add.tmp
220    fi
221    cp iodef.xml iodef.xml.tmp
222    sed -e "/COMPONENT CONTEXT/r add.tmp" \
223        iodef.xml.tmp > iodef.xml
224    rm iodef.xml.tmp add.tmp
225
226    #Long Name as global attribute (if LongName is not empty)
227    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
228        listfile=$(ls file_def_nemo*.xml)
229        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
230        for file in ${listfile}
231        do
232            cp ${file} ${file}.tmp
233            sed -e "/<file id/r add.tmp" \
234                ${file}.tmp > ${file}
235            rm ${file}.tmp
236        done
237        rm add.tmp
238    fi
239
240    IGCM_debug_PopStack "OCE_Update"
241}
242
243#-----------------------------------
244function OCE_Finalize
245{
246    IGCM_debug_PushStack "OCE_Finalize"
247
248    IGCM_debug_Print 1 FINALIZE OCE !!!
249
250    IGCM_debug_PopStack "OCE_Finalize"
251}
Note: See TracBrowser for help on using the repository browser.