1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function 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 |
---|
15 | supergrep () { |
---|
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 | #----------------------------------------------------------------- |
---|
37 | function OCE_Update |
---|
38 | { |
---|
39 | IGCM_debug_PushStack "OCE_Update" |
---|
40 | |
---|
41 | |
---|
42 | V1D_ENABLE=".FALSE." |
---|
43 | V5D_ENABLE=".FALSE." |
---|
44 | V1M_ENABLE=".FALSE." |
---|
45 | V1Y_ENABLE=".FALSE." |
---|
46 | |
---|
47 | for frequency in ${config_OCE_WriteFrequency} ; do |
---|
48 | case ${frequency} in |
---|
49 | ( 1D|1d ) V1D_ENABLE=".TRUE." ;; |
---|
50 | ( 5D|5d ) V5D_ENABLE=".TRUE." ;; |
---|
51 | ( 1M|1m ) V1M_ENABLE=".TRUE." ;; |
---|
52 | ( *[yY] ) V1Y_ENABLE=".TRUE." ;; |
---|
53 | esac |
---|
54 | done |
---|
55 | |
---|
56 | if [ "${EXPTYPE}" = "ia" ] ; then |
---|
57 | NbFileInter=${#opa9_UserChoices_ListForcing[*]} |
---|
58 | (( LengthForcing=${opa9_UserChoices_YearForcingEnd} - ${opa9_UserChoices_YearForcingInit} + 1 )) |
---|
59 | (( DiffForcing=abs(${opa9_UserChoices_YearForcingEnd} - ${year} ))) |
---|
60 | (( ModuloForcing=${DiffForcing} % ${LengthForcing} )) |
---|
61 | if [ ${ModuloForcing} -eq 0 ] ; then |
---|
62 | (( year_forcing=${opa9_UserChoices_YearForcingEnd} )) |
---|
63 | else |
---|
64 | if [ ${year} -ge ${opa9_UserChoices_YearForcingInit} ] && [ ${year} -le ${opa9_UserChoices_YearForcingEnd} ] ; then |
---|
65 | year_forcing=${year} |
---|
66 | elif [ ${year} -lt ${opa9_UserChoices_YearForcingInit} ] ; then |
---|
67 | (( year_forcing=${opa9_UserChoices_YearForcingEnd} - ${ModuloForcing} )) |
---|
68 | else |
---|
69 | (( year_forcing=${opa9_UserChoices_YearForcingInit} + ${ModuloForcing} - 1 )) |
---|
70 | fi |
---|
71 | fi |
---|
72 | (( year_forcing_m1 = ${year_forcing} - 1)) |
---|
73 | (( year_forcing_p1 = ${year_forcing} + 1)) |
---|
74 | (( i = 0 )) |
---|
75 | while [ $i -lt ${NbFileInter} ] ; do |
---|
76 | eval file=${opa9_UserChoices_ListForcing[$i]} |
---|
77 | IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_m1}.nc ${file}_y${year_m1}.nc |
---|
78 | IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing}.nc ${file}_y${year}.nc |
---|
79 | IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_p1}.nc ${file}_y${year_p1}.nc |
---|
80 | (( i = i + 1 )) |
---|
81 | done |
---|
82 | fi |
---|
83 | |
---|
84 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
85 | # Needed by OPA namelist to compute correct file names |
---|
86 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
87 | |
---|
88 | ## Count of number of time steps from begin of OPA job |
---|
89 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 )) |
---|
90 | (( OPA_NDT = PeriodLengthInDays * OPA_NPDT_DAY )) |
---|
91 | (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1)) |
---|
92 | |
---|
93 | ## Forcing to write one restart file at the end of period |
---|
94 | OPA_NSTOCK="${OPA_NITEND}" |
---|
95 | |
---|
96 | ## Verification of number of time steps per day |
---|
97 | (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT )) |
---|
98 | (( NB_SEC_DAY = 60 * 60 * 24 )) |
---|
99 | |
---|
100 | if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ] |
---|
101 | then |
---|
102 | 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} |
---|
103 | echo " VERIFY OPA_NPDT_DAY in opa9.card " |
---|
104 | exit |
---|
105 | fi |
---|
106 | |
---|
107 | ##-- Restart configuration |
---|
108 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
109 | |
---|
110 | #echo "NO OPA RESTART" |
---|
111 | OPA_LRSTAR=.FALSE. |
---|
112 | OPA_NRSTDT=0 |
---|
113 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
114 | |
---|
115 | #echo "OPA RESTART" |
---|
116 | OPA_LRSTAR=.TRUE. |
---|
117 | OPA_NRSTDT=0 |
---|
118 | else |
---|
119 | |
---|
120 | #echo "OPA RESTART" |
---|
121 | OPA_LRSTAR=.TRUE. |
---|
122 | OPA_NRSTDT=2 |
---|
123 | fi |
---|
124 | |
---|
125 | OPA_NMSH=0 |
---|
126 | if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then |
---|
127 | OPA_NMSH=1 |
---|
128 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n" |
---|
129 | fi |
---|
130 | ## nleapy configuration |
---|
131 | case ${config_UserChoices_CalendarType} in |
---|
132 | ( leap|gregorian) OPA_NLEAPY=1 ;; |
---|
133 | ( noleap ) OPA_NLEAPY=0 ;; |
---|
134 | ( 360d ) OPA_NLEAPY=30 ;; |
---|
135 | ( * ) OPA_NLEAPY=30 ;; |
---|
136 | esac |
---|
137 | |
---|
138 | typeset -r PRECIS=8 |
---|
139 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
140 | |
---|
141 | IGCM_comp_modifyNamelist blocker namelist_cfg cn_exp ${config_UserChoices_JobName} |
---|
142 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_it000 ${OPA_NIT000} |
---|
143 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_itend ${OPA_NITEND} |
---|
144 | IGCM_comp_modifyNamelist blocker namelist_cfg ln_rstart ${OPA_LRSTAR} |
---|
145 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_stock ${OPA_NSTOCK} |
---|
146 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_rstctl ${OPA_NRSTDT} |
---|
147 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_date0 ${PeriodDateBegin} |
---|
148 | IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh ${OPA_NMSH} |
---|
149 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_leapy ${OPA_NLEAPY} |
---|
150 | |
---|
151 | IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V5D_ENABLE V1M_ENABLE V1Y_ENABLE ' |
---|
152 | IGCM_debug_Print 1 ${V1D_ENABLE} ${V5D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} |
---|
153 | |
---|
154 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1d_opa enabled ${V1D_ENABLE} |
---|
155 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 5d_opa enabled ${V5D_ENABLE} |
---|
156 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1m_opa enabled ${V1M_ENABLE} |
---|
157 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1y_opa enabled ${V1Y_ENABLE} |
---|
158 | |
---|
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_nemo.xml > domain_def.xml.tmp |
---|
164 | IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml ; |
---|
165 | esac |
---|
166 | |
---|
167 | IGCM_debug_PopStack "OCE_Update" |
---|
168 | } |
---|
169 | |
---|
170 | #----------------------------------- |
---|
171 | function 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 | |
---|