source: CONFIG/UNIFORM/v6/IPSLCM5A2/GENERAL/DRIVER/opa9.driver @ 5983

Last change on this file since 5983 was 5879, checked in by snguyen, 3 years ago

Modified Makefile to add configuration PALEOIPSLCM5A2-VLR while retaining IPSLCM5A2-VLR as default configuration for compilation. Moved NEMO SOURCES of IPSLCM5A2-VLR to SOURCES/NEMO/STANDARD and created SOURCES/NEMO/PALEO for PALEOIPSLCM5A2-VLR configuration. Created paleolmdz in Makefile to compile LMDZ sources in SOURCES/LMDZ/PALEO. Added experiments IPSLCM/paleo and LMDZOR/paleo. Added file_def_nemo-lim2_paleo.xml file_def_histmth_lmdz_paleo.xml file_def_nemo-opa_paleo.xml file_def_nemo-pisces_rivers_paleo.xml file_def_nemo-pisces_paleo.xml file_def_orchidee_paleo.xml namelist_ORCA2_cfg_paleo namelist_pisces_ORCA2_cfg_paleo to GENERAL/PARAM for paleo configurations. Set day_step=720 in GENERAL/PARAM/gcm.def_96x95 for paleo configurations. Modified GENERAL/DRIVER/opa9.driver to use namelist_ORCA2_cfg_paleo for paleo configurations.

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