[2639] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function OCE_Initialize |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "OCE_Initialize" |
---|
| 6 | |
---|
[3203] | 7 | RESOL_OCE=${config_UserChoices_ExpType%%_*} |
---|
[3854] | 8 | exptype=${config_UserChoices_ExpType##*/} |
---|
[2639] | 9 | |
---|
[3203] | 10 | IGCM_debug_Print 1 " " |
---|
| 11 | IGCM_debug_Print 1 "RESOL_OCE : ${RESOL_OCE}" |
---|
[3854] | 12 | IGCM_debug_Print 1 "FORCING : ${exptype}" |
---|
| 13 | IGCM_debug_Print 1 "EXPERIMENT TYPE : ${opa9_UserChoices_forcing}" |
---|
[3203] | 14 | |
---|
[2639] | 15 | # Local function to find namelists parameters |
---|
| 16 | supergrep () { |
---|
| 17 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
| 18 | } |
---|
| 19 | |
---|
[3854] | 20 | OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}/namelist_${opa9_UserChoices_forcing}_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' ) |
---|
[2639] | 21 | |
---|
| 22 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 23 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
| 24 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
| 25 | |
---|
[2875] | 26 | (( OPA_NPDT_DAY = 86400 / OPA_RDT )) |
---|
[2871] | 27 | (( OPA_NPDT_YEAR = OPA_NPDT_DAY * 365 )) |
---|
[2647] | 28 | |
---|
[2875] | 29 | IGCM_debug_Print 1 " " |
---|
| 30 | IGCM_debug_Print 1 "OPA_RDT ${OPA_RDT}" |
---|
| 31 | IGCM_debug_Print 1 "OPA_NPDT_DAY ${OPA_NPDT_DAY}" |
---|
| 32 | IGCM_debug_Print 1 "OPA_NPDT_YEAR ${OPA_NPDT_YEAR}" |
---|
[2639] | 33 | |
---|
[3854] | 34 | |
---|
[2639] | 35 | IGCM_debug_PopStack "OCE_Initialize" |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | #----------------------------------------------------------------- |
---|
| 39 | function OCE_Update |
---|
[2815] | 40 | { |
---|
[2639] | 41 | IGCM_debug_PushStack "OCE_Update" |
---|
| 42 | |
---|
[3096] | 43 | |
---|
[3408] | 44 | V1D_ENABLE=".FALSE." |
---|
| 45 | V5D_ENABLE=".FALSE." |
---|
| 46 | V1M_ENABLE=".FALSE." |
---|
| 47 | V1Y_ENABLE=".FALSE." |
---|
| 48 | |
---|
| 49 | for frequency in ${config_OCE_WriteFrequency} ; do |
---|
| 50 | case ${frequency} in |
---|
| 51 | ( 1D|1d ) V1D_ENABLE=".TRUE." ;; |
---|
| 52 | ( 5D|5d ) V5D_ENABLE=".TRUE." ;; |
---|
| 53 | ( 1M|1m ) V1M_ENABLE=".TRUE." ;; |
---|
| 54 | ( *[yY] ) V1Y_ENABLE=".TRUE." ;; |
---|
| 55 | esac |
---|
| 56 | done |
---|
| 57 | |
---|
[3854] | 58 | if [ "${exptype}" = "ia" ] ; then |
---|
[3096] | 59 | NbFileInter=${#opa9_UserChoices_ListForcing[*]} |
---|
[3408] | 60 | (( LengthForcing=${opa9_UserChoices_YearForcingEnd} - ${opa9_UserChoices_YearForcingInit} + 1 )) |
---|
| 61 | (( DiffForcing=abs(${opa9_UserChoices_YearForcingEnd} - ${year} ))) |
---|
| 62 | (( ModuloForcing=${DiffForcing} % ${LengthForcing} )) |
---|
| 63 | if [ ${ModuloForcing} -eq 0 ] ; then |
---|
| 64 | (( year_forcing=${opa9_UserChoices_YearForcingEnd} )) |
---|
[3096] | 65 | else |
---|
[3408] | 66 | if [ ${year} -ge ${opa9_UserChoices_YearForcingInit} ] && [ ${year} -le ${opa9_UserChoices_YearForcingEnd} ] ; then |
---|
| 67 | year_forcing=${year} |
---|
| 68 | elif [ ${year} -lt ${opa9_UserChoices_YearForcingInit} ] ; then |
---|
| 69 | (( year_forcing=${opa9_UserChoices_YearForcingEnd} - ${ModuloForcing} )) |
---|
| 70 | else |
---|
| 71 | (( year_forcing=${opa9_UserChoices_YearForcingInit} + ${ModuloForcing} - 1 )) |
---|
| 72 | fi |
---|
[3096] | 73 | fi |
---|
| 74 | (( year_forcing_m1 = ${year_forcing} - 1)) |
---|
| 75 | (( year_forcing_p1 = ${year_forcing} + 1)) |
---|
| 76 | (( i = 0 )) |
---|
[3961] | 77 | while [ $i -lt ${NbFileInter} ] ; do |
---|
| 78 | eval file=${opa9_UserChoices_ListForcing[$i]} |
---|
[4800] | 79 | cp ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_m1}.nc ${file}_y${year_m1}.nc |
---|
| 80 | cp ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing}.nc ${file}_y${year}.nc |
---|
| 81 | cp ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_p1}.nc ${file}_y${year_p1}.nc |
---|
[3961] | 82 | (( i = i + 1 )) |
---|
| 83 | done |
---|
| 84 | |
---|
[3096] | 85 | fi |
---|
| 86 | |
---|
[2815] | 87 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 88 | # Needed by OPA namelist to compute correct file names |
---|
| 89 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
[2639] | 90 | |
---|
[2815] | 91 | ## Count of number of time steps from begin of OPA job |
---|
[2875] | 92 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 )) |
---|
| 93 | (( OPA_NDT = PeriodLengthInDays * OPA_NPDT_DAY )) |
---|
[2815] | 94 | (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1)) |
---|
| 95 | |
---|
| 96 | ## Forcing to write one restart file at the end of period |
---|
| 97 | OPA_NSTOCK="${OPA_NITEND}" |
---|
| 98 | |
---|
| 99 | ## Verification of number of time steps per day |
---|
[2875] | 100 | (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT )) |
---|
[2815] | 101 | (( NB_SEC_DAY = 60 * 60 * 24 )) |
---|
| 102 | |
---|
| 103 | if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ] |
---|
| 104 | then |
---|
[2875] | 105 | 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} |
---|
| 106 | echo " VERIFY OPA_NPDT_DAY in opa9.card " |
---|
[2815] | 107 | exit |
---|
| 108 | fi |
---|
| 109 | |
---|
[3854] | 110 | ##-- Restart configuration |
---|
[2639] | 111 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
[3854] | 112 | OPA_LRSTAR=.FALSE. |
---|
| 113 | OPA_NRSTDT=0 |
---|
| 114 | #echo "NO OPA RESTART" |
---|
[2639] | 115 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
[3854] | 116 | OPA_LRSTAR=.TRUE. |
---|
| 117 | OPA_NRSTDT=0 |
---|
| 118 | #echo "OPA RESTART" |
---|
[2639] | 119 | else |
---|
[3854] | 120 | OPA_LRSTAR=.TRUE. |
---|
| 121 | OPA_NRSTDT=2 |
---|
| 122 | #echo "OPA RESTART" |
---|
| 123 | fi |
---|
[2639] | 124 | |
---|
[2815] | 125 | |
---|
[3124] | 126 | OPA_NMSH=0 |
---|
| 127 | if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then |
---|
| 128 | OPA_NMSH=1 |
---|
[6013] | 129 | export opa9_UserChoices_mesh_mask=n |
---|
[3124] | 130 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n" |
---|
| 131 | fi |
---|
[3854] | 132 | |
---|
[3124] | 133 | ## nleapy configuration |
---|
| 134 | case ${config_UserChoices_CalendarType} in |
---|
| 135 | ( leap|gregorian) OPA_NLEAPY=1 ;; |
---|
| 136 | ( noleap ) OPA_NLEAPY=0 ;; |
---|
| 137 | ( 360d ) OPA_NLEAPY=30 ;; |
---|
| 138 | ( * ) OPA_NLEAPY=30 ;; |
---|
| 139 | esac |
---|
[2639] | 140 | |
---|
[3854] | 141 | |
---|
[3124] | 142 | typeset -r PRECIS=8 |
---|
| 143 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
[2639] | 144 | |
---|
[4009] | 145 | |
---|
[2815] | 146 | IGCM_comp_modifyNamelist blocker namelist_cfg cn_exp ${config_UserChoices_JobName} |
---|
| 147 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_it000 ${OPA_NIT000} |
---|
| 148 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_itend ${OPA_NITEND} |
---|
| 149 | IGCM_comp_modifyNamelist blocker namelist_cfg ln_rstart ${OPA_LRSTAR} |
---|
[4009] | 150 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_stock ${OPA_NSTOCK} |
---|
[2815] | 151 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_rstctl ${OPA_NRSTDT} |
---|
[4009] | 152 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_date0 ${PeriodDateBegin} |
---|
[2815] | 153 | IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh ${OPA_NMSH} |
---|
| 154 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_leapy ${OPA_NLEAPY} |
---|
| 155 | |
---|
[4009] | 156 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
| 157 | OPA_LQSR_RGB=.FALSE. |
---|
| 158 | OPA_LQSR_BIO=.TRUE. |
---|
[4198] | 159 | else |
---|
| 160 | OPA_LQSR_RGB=DEFAULT |
---|
| 161 | OPA_LQSR_BIO=DEFAULT |
---|
[4009] | 162 | fi |
---|
[4198] | 163 | IGCM_comp_modifyNamelist blocker namelist_cfg ln_qsr_rgb ${OPA_LQSR_RGB} |
---|
| 164 | IGCM_comp_modifyNamelist blocker namelist_cfg ln_qsr_bio ${OPA_LQSR_BIO} |
---|
[4009] | 165 | |
---|
[3408] | 166 | IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V5D_ENABLE V1M_ENABLE V1Y_ENABLE ' |
---|
| 167 | IGCM_debug_Print 1 ${V1D_ENABLE} ${V5D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} |
---|
| 168 | |
---|
[3512] | 169 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1d_opa enabled ${V1D_ENABLE} |
---|
| 170 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 5d_opa enabled ${V5D_ENABLE} |
---|
| 171 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1m_opa enabled ${V1M_ENABLE} |
---|
| 172 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1y_opa enabled ${V1Y_ENABLE} |
---|
[3408] | 173 | |
---|
[3854] | 174 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1d_opa output_level ${opa9_UserChoices_OutputLevel} |
---|
| 175 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 5d_opa output_level ${opa9_UserChoices_OutputLevel} |
---|
| 176 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1m_opa output_level ${opa9_UserChoices_OutputLevel} |
---|
| 177 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-opa.xml 1y_opa output_level ${opa9_UserChoices_OutputLevel} |
---|
| 178 | |
---|
| 179 | IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear} |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | #Long Name as global attribute (if LongName is not empty) |
---|
| 183 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
| 184 | listfile=$(ls file_def_nemo*.xml) |
---|
| 185 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
| 186 | for file in ${listfile} |
---|
| 187 | do |
---|
| 188 | cp ${file} ${file}.tmp |
---|
| 189 | sed -e "/<file id/r add.tmp" \ |
---|
| 190 | ${file}.tmp > ${file} |
---|
| 191 | rm ${file}.tmp |
---|
| 192 | done |
---|
| 193 | rm add.tmp |
---|
| 194 | fi |
---|
| 195 | |
---|
[3203] | 196 | # update domain_def.xml file |
---|
| 197 | case ${RESOL_OCE} in |
---|
| 198 | ( *ORCA025* ) |
---|
[3210] | 199 | 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 |
---|
| 200 | IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml ; |
---|
[3203] | 201 | esac |
---|
| 202 | |
---|
[2848] | 203 | IGCM_debug_PopStack "OCE_Update" |
---|
[2814] | 204 | } |
---|
[2639] | 205 | |
---|
| 206 | #----------------------------------- |
---|
| 207 | function OCE_Finalize |
---|
| 208 | { |
---|
| 209 | IGCM_debug_PushStack "OCE_Finalize" |
---|
| 210 | |
---|
| 211 | if [ -f date.file ] ; then |
---|
| 212 | # Prefix use in opa.card AND in lim2.card : |
---|
| 213 | DATE_OPA=$( cat date.file | \ |
---|
| 214 | sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" ) |
---|
| 215 | ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 ) |
---|
| 216 | MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA} |
---|
| 217 | SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA} |
---|
| 218 | fi |
---|
| 219 | |
---|
| 220 | echo FINALIZE OCE !!! |
---|
| 221 | |
---|
| 222 | IGCM_debug_PopStack "OCE_Finalize" |
---|
| 223 | } |
---|
| 224 | |
---|