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