source: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/opa9.driver @ 2768

Last change on this file since 2768 was 2768, checked in by jgipsl, 9 years ago

Changed to use option nonblocker instead of force for opa9 xml file.

File size: 8.4 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_JOUR  =  86400 / OPA_RDT        ))
40    (( OPA_RDT_SBC    =  OPA_RDT * OPA_NN_FSBC ))
41 
42    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
43    # /!\ Needed by OPA namelist to compute file names /!\
44    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
45
46    # Parallelism
47    OCE_PROC_MPI=$(echo ${config_Executable_OCE[2]} | sed s'/MPI//' )
48    OPA_JPNI=$(supergrep jpni  ${NAMELIST_OPA_CFG} )
49    OPA_JPNJ=$(supergrep jpnj  ${NAMELIST_OPA_CFG} )
50    IGCM_debug_Print 1 " "
51    IGCM_debug_Print 1 "Readed OPA_JPNI  ${OPA_JPNI}"
52    IGCM_debug_Print 1 "Readed OPA_JPNJ  ${OPA_JPNJ}"
53    IGCM_debug_Print 1 "OCE_PROC_MPI  ${OCE_PROC_MPI}"
54
55    (( Residu = OCE_PROC_MPI % OPA_JPNJ ))
56    if [[ ${Residu} != 0 ]] ; then
57        IGCM_debug_Exit "OCE_PROC_MPI (specified in config.card, [Executable]) is not a multiple of OPA_JPNJ"
58        #IGCM_debug_Verif_Exit
59    fi
60   
61    (( OPA_JPNI  = OCE_PROC_MPI / OPA_JPNJ ))
62    (( OPA_JPNIJ = OPA_JPNI * OPA_JPNJ     ))
63    IGCM_debug_Print 1 "Computed OPA_JPNI   ${OPA_JPNI}"
64    IGCM_debug_Print 1 "Computed OPA_JPNIJ  ${OPA_JPNIJ}"
65
66    if [[ ${OCE_PROC_MPI} != ${OPA_JPNIJ} ]] ; then
67        IGCM_debug_Exit "OCE_PROC_MPI /= OPA_JPNI * OPA_JPNJ"
68        IGCM_debug_Verif_Exit
69    fi 
70
71    #
72    IGCM_debug_Print 1 " "
73    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
74    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
75    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
76    IGCM_debug_Print 1 "OPA_NPDT_JOUR  ${OPA_NPDT_JOUR}"
77    IGCM_debug_Print 1 "DaysSinceJC    ${DaysSinceJC}"
78
79    ## Check that nn_fsbc is correct compare to coupling frequency
80    FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
81   
82    ## This informations are used for diaptr, trends and diagap files
83    ## only the first frequency is used for this files
84   
85    IGCM_debug_Print 1 "FreqCoupling    ${FreqCoupling}"
86    IGCM_debug_Print 1 "OPA_NN_FSBC    ${OPA_NN_FSBC}"
87    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
88    IGCM_debug_Print 1 "OPA_RDT_SBC    ${OPA_RDT_SBC}"
89   
90    if [[ ${OPA_RDT_SBC} -gt ${FreqCoupling} ]] ; then
91        IGCM_debug_Exit "OPA_RDT_SBC=${OPA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}"
92        IGCM_debug_Verif_Exit
93    fi
94   
95    IGCM_debug_PopStack "OCE_Initialize"
96   
97}
98
99#-----------------------------------------------------------------
100function OCE_Update
101{
102    IGCM_debug_PushStack "OCE_Update"
103 
104    ##--Write Frequency for iomput
105    ## Differents frequencies are allowed for grid_[TUVW] and icemod files
106
107    V1D_ENABLE=".FALSE."
108    V1M_ENABLE=".FALSE."
109    V1Y_ENABLE=".FALSE."
110
111    for frequency in ${config_OCE_WriteFrequency} ; do
112        case ${frequency} in
113            ( 1D|1d ) V1D_ENABLE=".TRUE." ;;
114            ( 1M|1m ) V1M_ENABLE=".TRUE." ;;
115            ( *[yY] ) V1Y_ENABLE=".TRUE." ;;
116        esac
117    done
118
119    ##-- Output level : 3 for more 1D variables
120    eval opa9_OUTPUT_LEVEL=\${opa9_UserChoices_OUTPUT_LEVEL} > /dev/null 2>&1
121    OUTPUT_LEVEL=${opa9_OUTPUT_LEVEL}
122
123    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
124    # Needed by OPA namelist to compute correct file names
125    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
126
127    ##-- Number of time steps updated : the first, the last and the number of time steps
128    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_JOUR + 1 ))
129    (( OPA_NPDT   = PeriodLengthInDays * OPA_NPDT_JOUR ))
130    (( OPA_NITEND = OPA_NIT000 + OPA_NPDT - 1))
131
132    ##-- We force one restart file at the end of the trunk
133    OPA_NSTOCK="${OPA_NITEND}"
134
135    ##-- Restart configuration
136    if ( [ "${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    # nleapy configuration
163    case ${config_UserChoices_CalendarType} in
164        ( leap|gregorian) OPA_NLEAPY=1  ;;
165        ( noleap        ) OPA_NLEAPY=0  ;;
166        ( 360d          ) OPA_NLEAPY=30 ;;
167        ( *             ) OPA_NLEAPY=30 ;;
168    esac
169
170    typeset -r PRECIS=8
171    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
172
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 ln_rstart ${OPA_LRSTAR}
177    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock  ${OPA_NSTOCK}
178    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl ${OPA_NRSTDT}
179    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0  ${PeriodDateBegin}
180    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh    ${OPA_NMSH}
181    IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_rnf_depth_file  ${OPA_NMSH}
182    IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY}
183   
184    # Update iodef.xml
185
186    IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V1M_ENABLE V1Y_ENABLE OUTPUT_LEVEL'
187    IGCM_debug_Print 1 ${V1D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} ${OUTPUT_LEVEL}
188
189    IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1d enabled ${V1D_ENABLE}
190    IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1m enabled ${V1M_ENABLE}
191    IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1y enabled ${V1Y_ENABLE}
192       
193    # vargas/titane/MPP and switch from 1 proc to 5 procs. We need to suppres restartopa the second month, if restartopa_0000 exist
194    # same thing for restart_trc and restart_ice_in
195
196    for restartfilenemo in restartopa restart_trc restart_ice_in ; do
197      [ -f ${restartfilenemo}.nc ] && [ -f ${restartfilenemo}_0000.nc ] && IGCM_sys_Rm -f ${restartfilenemo}.nc
198    done
199
200    # Add include of nemo context in iodef.xml
201    # In iodef.xml add on next line after "COMPONENT CONTEXT"
202    #  <context id="nemo" src="./context_nemo.xml"/>
203    echo '<context id="nemo" src="./context_nemo.xml"/>' > add.tmp
204    cp iodef.xml iodef.xml.tmp
205    sed -e "/COMPONENT CONTEXT/r add.tmp" \
206        iodef.xml.tmp > iodef.xml
207    rm iodef.xml.tmp add.tmp
208
209    IGCM_debug_PopStack "OCE_Update"
210}
211
212#-----------------------------------
213function OCE_Finalize
214{
215    IGCM_debug_PushStack "OCE_Finalize"
216
217    IGCM_debug_Print 1 FINALIZE OCE !!!
218
219    IGCM_debug_PopStack "OCE_Finalize"
220}
Note: See TracBrowser for help on using the repository browser.