[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 ) |
---|
| 39 | (( OPA_NPDT_JOUR = 86400 / OPA_RDT )) |
---|
| 40 | (( OPA_RDT_SBC = OPA_RDT * OPA_NN_FSBC )) |
---|
[2267] | 41 | |
---|
[583] | 42 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 43 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
| 44 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
| 45 | |
---|
[2379] | 46 | IGCM_debug_Print 1 " " |
---|
[2540] | 47 | IGCM_debug_Print 1 "OPA_RDT ${OPA_RDT}" |
---|
| 48 | IGCM_debug_Print 1 "OPA_NN_FSBC ${OPA_NN_FSBC}" |
---|
| 49 | IGCM_debug_Print 1 "OPA_RDT_SBC ${OPA_RDT_SBC}" |
---|
| 50 | IGCM_debug_Print 1 "OPA_NPDT_JOUR ${OPA_NPDT_JOUR}" |
---|
| 51 | IGCM_debug_Print 1 "DaysSinceJC ${DaysSinceJC}" |
---|
| 52 | |
---|
| 53 | ## Check that nn_fsbc is correct compare to coupling frequency |
---|
| 54 | FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400} |
---|
[2267] | 55 | |
---|
[2540] | 56 | ## This informations are used for diaptr, trends and diagap files |
---|
| 57 | ## only the first frequency is used for this files |
---|
| 58 | |
---|
| 59 | IGCM_debug_Print 1 "FreqCoupling ${FreqCoupling}" |
---|
| 60 | IGCM_debug_Print 1 "OPA_NN_FSBC ${OPA_NN_FSBC}" |
---|
| 61 | IGCM_debug_Print 1 "OPA_RDT ${OPA_RDT}" |
---|
| 62 | IGCM_debug_Print 1 "OPA_RDT_SBC ${OPA_RDT_SBC}" |
---|
| 63 | |
---|
| 64 | if [[ ${OPA_RDT_SBC} -gt ${FreqCoupling} ]] ; then |
---|
| 65 | IGCM_debug_Exit "OPA_RDT_SBC=${OPA_RDT_SBC} is greater than FreqCoupling=${FreqCoupling}" |
---|
| 66 | IGCM_debug_Verif_Exit |
---|
| 67 | fi |
---|
| 68 | |
---|
[583] | 69 | IGCM_debug_PopStack "OCE_Initialize" |
---|
[2379] | 70 | |
---|
[583] | 71 | } |
---|
| 72 | |
---|
| 73 | #----------------------------------------------------------------- |
---|
| 74 | function OCE_Update |
---|
| 75 | { |
---|
| 76 | IGCM_debug_PushStack "OCE_Update" |
---|
[2540] | 77 | |
---|
[777] | 78 | ##--Write Frequency for iomput |
---|
| 79 | ## Differents frequencies are allowed for grid_[TUVW] and icemod files |
---|
| 80 | |
---|
| 81 | V1D_ENABLE=".FALSE." |
---|
| 82 | V1M_ENABLE=".FALSE." |
---|
| 83 | V1Y_ENABLE=".FALSE." |
---|
| 84 | |
---|
| 85 | for frequency in ${config_OCE_WriteFrequency} ; do |
---|
| 86 | case ${frequency} in |
---|
[2540] | 87 | ( 1D|1d ) V1D_ENABLE=".TRUE." ;; |
---|
| 88 | ( 1M|1m ) V1M_ENABLE=".TRUE." ;; |
---|
| 89 | ( *[yY] ) V1Y_ENABLE=".TRUE." ;; |
---|
[777] | 90 | esac |
---|
| 91 | done |
---|
| 92 | |
---|
[1021] | 93 | ##-- Output level : 3 for more 1D variables |
---|
| 94 | eval opa9_OUTPUT_LEVEL=\${opa9_UserChoices_OUTPUT_LEVEL} > /dev/null 2>&1 |
---|
| 95 | OUTPUT_LEVEL=${opa9_OUTPUT_LEVEL} |
---|
| 96 | |
---|
[583] | 97 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 98 | # Needed by OPA namelist to compute correct file names |
---|
| 99 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
| 100 | |
---|
| 101 | ##-- Number of time steps updated : the first, the last and the number of time steps |
---|
[2540] | 102 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_JOUR + 1 )) |
---|
| 103 | (( OPA_NPDT = PeriodLengthInDays * OPA_NPDT_JOUR )) |
---|
| 104 | (( OPA_NITEND = OPA_NIT000 + OPA_NPDT - 1)) |
---|
[583] | 105 | |
---|
| 106 | ##-- We force one restart file at the end of the trunk |
---|
[2540] | 107 | OPA_NSTOCK="${OPA_NITEND}" |
---|
[583] | 108 | |
---|
| 109 | ##-- Restart configuration |
---|
| 110 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
[2540] | 111 | OPA_LRSTAR=.FALSE. |
---|
| 112 | OPA_NRSTDT=0 |
---|
| 113 | # Put OPA_NMSH=0 when OPA running in parallel mode |
---|
| 114 | OPA_NMSH=1 |
---|
[583] | 115 | #echo "NO OPA RESTART" |
---|
| 116 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
[2540] | 117 | OPA_LRSTAR=.TRUE. |
---|
| 118 | OPA_NRSTDT=0 |
---|
| 119 | OPA_NMSH=1 |
---|
[583] | 120 | #echo "OPA RESTART" |
---|
| 121 | else |
---|
[2540] | 122 | OPA_LRSTAR=.TRUE. |
---|
| 123 | OPA_NRSTDT=2 |
---|
| 124 | OPA_NMSH=0 |
---|
[583] | 125 | #echo "OPA RESTART" |
---|
| 126 | fi |
---|
| 127 | |
---|
[819] | 128 | ##-- Meshmask option |
---|
[902] | 129 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask |
---|
[819] | 130 | |
---|
| 131 | if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then |
---|
[2540] | 132 | OPA_NMSH=1 |
---|
[902] | 133 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n" |
---|
[819] | 134 | fi |
---|
| 135 | |
---|
[583] | 136 | # nleapy configuration |
---|
| 137 | case ${config_UserChoices_CalendarType} in |
---|
[2540] | 138 | ( leap|gregorian) OPA_NLEAPY=1 ;; |
---|
| 139 | ( noleap ) OPA_NLEAPY=0 ;; |
---|
| 140 | ( 360d ) OPA_NLEAPY=30 ;; |
---|
| 141 | ( * ) OPA_NLEAPY=30 ;; |
---|
[583] | 142 | esac |
---|
| 143 | |
---|
| 144 | typeset -r PRECIS=8 |
---|
[2540] | 145 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
[583] | 146 | |
---|
[2540] | 147 | IGCM_comp_modifyNamelist blocker namelist_cfg cn_exp ${config_UserChoices_JobName} |
---|
| 148 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_it000 ${OPA_NIT000} |
---|
| 149 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_itend ${OPA_NITEND} |
---|
| 150 | IGCM_comp_modifyNamelist blocker namelist_cfg ln_rstart ${OPA_LRSTAR} |
---|
| 151 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_stock ${OPA_NSTOCK} |
---|
| 152 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_rstctl ${OPA_NRSTDT} |
---|
| 153 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_date0 ${PeriodDateBegin} |
---|
| 154 | IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh ${OPA_NMSH} |
---|
[2625] | 155 | IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_rnf_depth_file ${OPA_NMSH} |
---|
[2540] | 156 | IGCM_comp_modifyNamelist blocker namelist_cfg nn_leapy ${OPA_NLEAPY} |
---|
| 157 | |
---|
| 158 | # Update iodef.xml |
---|
[583] | 159 | |
---|
[2379] | 160 | IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V1M_ENABLE V1Y_ENABLE OUTPUT_LEVEL' |
---|
| 161 | IGCM_debug_Print 1 ${V1D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE} ${OUTPUT_LEVEL} |
---|
[1021] | 162 | |
---|
[2768] | 163 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1d enabled ${V1D_ENABLE} |
---|
| 164 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1m enabled ${V1M_ENABLE} |
---|
| 165 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo.xml 1y enabled ${V1Y_ENABLE} |
---|
[2540] | 166 | |
---|
[1436] | 167 | # vargas/titane/MPP and switch from 1 proc to 5 procs. We need to suppres restartopa the second month, if restartopa_0000 exist |
---|
| 168 | # same thing for restart_trc and restart_ice_in |
---|
| 169 | |
---|
| 170 | for restartfilenemo in restartopa restart_trc restart_ice_in ; do |
---|
| 171 | [ -f ${restartfilenemo}.nc ] && [ -f ${restartfilenemo}_0000.nc ] && IGCM_sys_Rm -f ${restartfilenemo}.nc |
---|
| 172 | done |
---|
| 173 | |
---|
[2270] | 174 | # Add include of nemo context in iodef.xml |
---|
| 175 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
| 176 | # <context id="nemo" src="./context_nemo.xml"/> |
---|
| 177 | echo '<context id="nemo" src="./context_nemo.xml"/>' > add.tmp |
---|
| 178 | cp iodef.xml iodef.xml.tmp |
---|
| 179 | sed -e "/COMPONENT CONTEXT/r add.tmp" \ |
---|
| 180 | iodef.xml.tmp > iodef.xml |
---|
| 181 | rm iodef.xml.tmp add.tmp |
---|
| 182 | |
---|
[583] | 183 | IGCM_debug_PopStack "OCE_Update" |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | #----------------------------------- |
---|
| 187 | function OCE_Finalize |
---|
| 188 | { |
---|
| 189 | IGCM_debug_PushStack "OCE_Finalize" |
---|
| 190 | |
---|
[2379] | 191 | IGCM_debug_Print 1 FINALIZE OCE !!! |
---|
[583] | 192 | |
---|
| 193 | IGCM_debug_PopStack "OCE_Finalize" |
---|
| 194 | } |
---|