[2639] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function OCE_Initialize |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "OCE_Initialize" |
---|
| 6 | |
---|
[3203] | 7 | RESOL_OCE=${config_UserChoices_ExpType%%_*} |
---|
| 8 | EXPTYPE=${config_UserChoices_ExpType##*/} |
---|
[2639] | 9 | |
---|
[3203] | 10 | IGCM_debug_Print 1 " " |
---|
| 11 | IGCM_debug_Print 1 "RESOL_OCE : ${RESOL_OCE}" |
---|
| 12 | IGCM_debug_Print 1 "EXPERIMENT TYPE : ${EXPTYPE}" |
---|
| 13 | |
---|
[2639] | 14 | # Local function to find namelists parameters |
---|
| 15 | supergrep () { |
---|
| 16 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
| 17 | } |
---|
| 18 | |
---|
[2663] | 19 | OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}${EXPTYPE}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' ) |
---|
[2639] | 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 | |
---|
[2875] | 25 | (( OPA_NPDT_DAY = 86400 / OPA_RDT )) |
---|
[2871] | 26 | (( OPA_NPDT_YEAR = OPA_NPDT_DAY * 365 )) |
---|
[2647] | 27 | |
---|
[2875] | 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}" |
---|
[2639] | 32 | |
---|
| 33 | IGCM_debug_PopStack "OCE_Initialize" |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | #----------------------------------------------------------------- |
---|
| 37 | function OCE_Update |
---|
[2815] | 38 | { |
---|
[2639] | 39 | IGCM_debug_PushStack "OCE_Update" |
---|
| 40 | |
---|
[3096] | 41 | |
---|
[3408] | 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 | |
---|
[3096] | 56 | if [ "${EXPTYPE}" = "ia" ] ; then |
---|
| 57 | NbFileInter=${#opa9_UserChoices_ListForcing[*]} |
---|
[3408] | 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} )) |
---|
[3096] | 63 | else |
---|
[3408] | 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 |
---|
[3096] | 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]} |
---|
[3408] | 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 |
---|
[3096] | 80 | (( i = i + 1 )) |
---|
| 81 | done |
---|
| 82 | fi |
---|
| 83 | |
---|
[2815] | 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 )) |
---|
[2639] | 87 | |
---|
[2815] | 88 | ## Count of number of time steps from begin of OPA job |
---|
[2875] | 89 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 )) |
---|
| 90 | (( OPA_NDT = PeriodLengthInDays * OPA_NPDT_DAY )) |
---|
[2815] | 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 |
---|
[2875] | 97 | (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT )) |
---|
[2815] | 98 | (( NB_SEC_DAY = 60 * 60 * 24 )) |
---|
| 99 | |
---|
| 100 | if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ] |
---|
| 101 | then |
---|
[2875] | 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 " |
---|
[2815] | 104 | exit |
---|
| 105 | fi |
---|
| 106 | |
---|
[2639] | 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. |
---|
[2718] | 117 | OPA_NRSTDT=0 |
---|
[2639] | 118 | else |
---|
| 119 | |
---|
| 120 | #echo "OPA RESTART" |
---|
| 121 | OPA_LRSTAR=.TRUE. |
---|
| 122 | OPA_NRSTDT=2 |
---|
| 123 | fi |
---|
[2815] | 124 | |
---|
[3124] | 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 |
---|
[2639] | 137 | |
---|
[3124] | 138 | typeset -r PRECIS=8 |
---|
| 139 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
[2639] | 140 | |
---|
[2815] | 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 | |
---|
[3408] | 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 | |
---|
[3512] | 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} |
---|
[3408] | 158 | |
---|
| 159 | |
---|
[3203] | 160 | # update domain_def.xml file |
---|
| 161 | case ${RESOL_OCE} in |
---|
| 162 | ( *ORCA025* ) |
---|
[3210] | 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 ; |
---|
[3203] | 165 | esac |
---|
| 166 | |
---|
[2848] | 167 | IGCM_debug_PopStack "OCE_Update" |
---|
[2814] | 168 | } |
---|
[2639] | 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 | |
---|