source: CONFIG/UNIFORM/v6/NEMO_v6/GENERAL/DRIVER/opa9.driver @ 3203

Last change on this file since 3203 was 3203, checked in by cetlod, 7 years ago

NEMO_v6 for OMIP : phase with the latest revision number

File size: 7.0 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function OCE_Initialize
4{
5    IGCM_debug_PushStack "OCE_Initialize"
6
7    RESOL_OCE=${config_UserChoices_ExpType%%_*}
8    EXPTYPE=${config_UserChoices_ExpType##*/}
9
10    IGCM_debug_Print 1 " "
11    IGCM_debug_Print 1 "RESOL_OCE        : ${RESOL_OCE}"
12    IGCM_debug_Print 1 "EXPERIMENT TYPE  : ${EXPTYPE}"
13
14# Local function to find namelists parameters
15supergrep () {
16    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
17}
18
19    OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}${EXPTYPE}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
20
21    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
22    # /!\ Needed by OPA namelist to compute file names /!\
23    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
24
25    (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
26    (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
27
28    IGCM_debug_Print 1 " "
29    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
30    IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
31    IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
32
33    IGCM_debug_PopStack "OCE_Initialize"
34}
35
36#-----------------------------------------------------------------
37function OCE_Update
38{
39    IGCM_debug_PushStack "OCE_Update"
40
41
42    if [ "${EXPTYPE}" = "ia"   ] ; then
43       NbFileInter=${#opa9_UserChoices_ListForcing[*]}
44       if [ ${year} -ge ${opa9_UserChoices_YearForcingInit} ] ; then
45          year_forcing=${year}
46       else
47          (( LengthForcing=${opa9_UserChoices_YearForcingEnd} - ${opa9_UserChoices_YearForcingInit} + 1 ))
48          (( DiffForcing=${opa9_UserChoices_YearForcingEnd} - ${year} ))
49          (( ModuloForcing=${opa9_UserChoices_YearForcingEnd} % ${LengthForcing} ))
50          (( year_forcing=${opa9_UserChoices_YearForcingEnd} - ${ModuloForcing} ))
51       fi
52       (( year_forcing_m1 = ${year_forcing} - 1))
53       (( year_forcing_p1 = ${year_forcing} + 1))
54       (( i = 0 ))
55        while [ $i -lt ${NbFileInter} ] ; do
56           eval file=${opa9_UserChoices_ListForcing[$i]}
57           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_m1}.nc  ${file}_y${year_m1}.nc
58           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing}.nc     ${file}_y${year}.nc
59           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_p1}.nc  ${file}_y${year_p1}.nc
60           (( i = i + 1 ))
61        done
62    fi
63
64    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
65    ##--Write Frequency Purpose ....
66    typeset -Z1 i=1
67    while [ $i -le ${NbFreq} ]; do
68        frequency=$( echo ${config_OCE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
69        factor=$( echo ${frequency} | sed -e "s/[yYmMdDhH]//" )
70
71        case ${frequency} in
72            *Y|*y)
73                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
74                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_Y} ;
75                eval WF${i}=${factor}Y ;;
76            *M|*m)
77                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
78                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_M} ;
79                eval WF${i}=${factor}M ;;
80            *D|*d)
81                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
82                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_D} ;
83                eval WF${i}=${factor}D ;;
84            *H|*h)
85                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}h_${DatesPeriod} ;
86                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_H} ;
87                eval WF${i}=${factor}H ;;
88            *)
89        esac
90        let i=$i+1
91
92    done
93    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
94    # Needed by OPA namelist to compute correct file names
95    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
96
97    ## Count of number of time steps from begin of OPA job
98    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
99    (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
100    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
101
102    ## Forcing to write one restart file at the end of period
103    OPA_NSTOCK="${OPA_NITEND}"
104
105    ## Verification of number of time steps per day
106    (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT ))
107    (( NB_SEC_DAY = 60 * 60 * 24 ))
108
109    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
110        then
111        echo " NB_SEC_DAY_MODEL "${NB_SEC_DAY_MODEL} "NB_SEC_DAY" ${NB_SEC_DAY} "OPA_NPDT_DAY" ${OPA_NPDT_DAY} "OPA_RDT" ${OPA_RDT}
112        echo " VERIFY OPA_NPDT_DAY in opa9.card "
113        exit
114    fi
115
116    ##-- Restart configuration
117    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
118
119        #echo "NO OPA RESTART"
120        OPA_LRSTAR=.FALSE.
121        OPA_NRSTDT=0
122    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
123
124        #echo "OPA RESTART"
125        OPA_LRSTAR=.TRUE.
126        OPA_NRSTDT=0
127    else
128
129        #echo "OPA RESTART"
130        OPA_LRSTAR=.TRUE.
131        OPA_NRSTDT=2
132    fi
133   
134    OPA_NMSH=0
135    if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
136        OPA_NMSH=1
137        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
138    fi
139    ## nleapy configuration
140    case ${config_UserChoices_CalendarType} in
141        ( leap|gregorian) OPA_NLEAPY=1  ;;
142        ( noleap        ) OPA_NLEAPY=0  ;;
143        ( 360d          ) OPA_NLEAPY=30 ;;
144        ( *             ) OPA_NLEAPY=30 ;;
145    esac
146
147   typeset -r PRECIS=8
148   NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
149
150   IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
151   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
152   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
153   IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart ${OPA_LRSTAR}
154   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock ${OPA_NSTOCK}
155   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl ${OPA_NRSTDT}
156   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0 ${PeriodDateBegin}
157   IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh    ${OPA_NMSH}
158   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY} 
159
160# update domain_def.xml file
161   case ${RESOL_OCE} in
162       ( *ORCA025* ) 
163        sed -e 's/<zoom_domain id="1point" ibegin="139" jbegin="119"/<zoom_domain id="1point" ibegin="600" jbegin="600"/' domain_def.xml > domain_def.xml.tmp 
164         IGCM_sys_Mv domain_def.xml.tmp domain_def.xml  ;
165   esac
166
167   IGCM_debug_PopStack "OCE_Update"
168}
169
170#-----------------------------------
171function OCE_Finalize
172{
173    IGCM_debug_PushStack "OCE_Finalize"
174
175    if [ -f date.file ] ; then
176        # Prefix use in opa.card AND in lim2.card :
177        DATE_OPA=$( cat date.file | \
178            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
179        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
180        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
181        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
182    fi
183
184    echo FINALIZE OCE !!!
185
186    IGCM_debug_PopStack "OCE_Finalize"
187}
188
Note: See TracBrowser for help on using the repository browser.