[583] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function OCE_Initialize |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "OCE_Initialize" |
---|
| 6 | |
---|
| 7 | JOB_NAME=${config_UserChoices_JobName} |
---|
| 8 | RESOL_OCE=$( echo $RESOL | awk "-Fx" '{print $1}' ) |
---|
| 9 | |
---|
| 10 | ORCA_NPDT_JOUR=${opa9_UserChoices_OPA_NPDT_JOURS:=15} |
---|
| 11 | |
---|
[653] | 12 | # Local function to find namelists parameters |
---|
| 13 | supergrep () { |
---|
| 14 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
| 15 | } |
---|
| 16 | |
---|
[583] | 17 | ##--Variables used by OPA -- |
---|
| 18 | |
---|
| 19 | # cexper experience name for vairmer format |
---|
| 20 | # ln_rstart boolean term for restart (true or false) |
---|
| 21 | # nrstdt control of the time step (0, 1 or 2) |
---|
| 22 | # nit000 number of the first time step |
---|
| 23 | # nitend number of the last time step |
---|
| 24 | # ndate0 initial calendar date aammjj |
---|
| 25 | # nleapy Leap year calendar (1) or not (0), or 360 days calendar (30) |
---|
| 26 | # nstock frequency of restart file |
---|
| 27 | # nwrite frequency of OUTPUT file |
---|
| 28 | # nmsh =1 create a mesh file (coordinates, scale factors, masks) |
---|
| 29 | # nwrihf frequency of HF OUTPUT file |
---|
| 30 | # rdt time step in seconds (coming from namelist) |
---|
| 31 | # nf_ptr_wri frequency of zonal means and transport output |
---|
| 32 | |
---|
[653] | 33 | PAT_CEXPER=$( supergrep cexper ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 34 | PAT_NIT000=$( supergrep nit000 ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 35 | PAT_NITEND=$( supergrep nitend ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 36 | PAT_NWRITE=$( supergrep nwrite ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 37 | PAT_NF_PTR=$( supergrep nf_ptr_wri ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 38 | PAT_RESTAR=$( supergrep ln_rstart ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 39 | PAT_NSTOCK=$( supergrep nstock ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 40 | PAT_NRSTAR=$( supergrep nrstdt ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 41 | PAT_NDATE0=$( supergrep ndate0 ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 42 | PAT_NLEAPY=$( supergrep nleapy ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
| 43 | PAT_NMSH=$( supergrep nmsh ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
[583] | 44 | |
---|
[653] | 45 | ORCA_RDT=$( supergrep rdt ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rdt *=//' | sed 's/\. *//' ) |
---|
| 46 | |
---|
[583] | 47 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 48 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
| 49 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
| 50 | |
---|
| 51 | IGCM_debug_PopStack "OCE_Initialize" |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | #----------------------------------------------------------------- |
---|
| 55 | function OCE_Update |
---|
| 56 | { |
---|
| 57 | IGCM_debug_PushStack "OCE_Update" |
---|
| 58 | |
---|
| 59 | NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w ) |
---|
| 60 | |
---|
| 61 | ##--Write Frequency Purpose .... |
---|
| 62 | frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' ) |
---|
| 63 | factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" ) |
---|
| 64 | case ${frequency} in |
---|
| 65 | 1Y|1y) |
---|
| 66 | (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear ${year} ) )) ; |
---|
| 67 | PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ; |
---|
| 68 | R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ; |
---|
| 69 | R_OUT_ICE_NWRITE=${R_OUT_ICE_O_Y} ; |
---|
| 70 | WF1=${factor}Y ;; |
---|
| 71 | 1M|1m) |
---|
| 72 | (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ; |
---|
| 73 | PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ; |
---|
| 74 | R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ; |
---|
| 75 | R_OUT_ICE_NWRITE=${R_OUT_ICE_O_M} ; |
---|
| 76 | WF1=${factor}M ;; |
---|
| 77 | *D|*d) |
---|
| 78 | (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor )) ; |
---|
| 79 | PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ; |
---|
| 80 | R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ; |
---|
| 81 | R_OUT_ICE_NWRITE=${R_OUT_ICE_O_D} ; |
---|
| 82 | WF1=${factor}D ;; |
---|
| 83 | *) |
---|
| 84 | (( ORCA_NWRITE = 0 )) ;; |
---|
| 85 | esac |
---|
| 86 | |
---|
| 87 | ##--Write Frequency Purpose .... concerning the second opa file type. |
---|
| 88 | if [ ${NbFreq} -eq 2 ] ; then |
---|
| 89 | frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $2}' ) |
---|
| 90 | factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" ) |
---|
| 91 | case ${frequency} in |
---|
| 92 | *Y|*y) |
---|
| 93 | (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear ${year} ) )) ; |
---|
| 94 | PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}y ; |
---|
| 95 | R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_Y} ; |
---|
| 96 | WF2=${factor}Y ;; |
---|
| 97 | *M|*m) |
---|
| 98 | (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ; |
---|
| 99 | PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}m ; |
---|
| 100 | R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_M} ; |
---|
| 101 | WF2=${factor}M ;; |
---|
| 102 | *D|*d) |
---|
| 103 | (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor )) ; |
---|
| 104 | PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}d ; |
---|
| 105 | R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_D} ; |
---|
| 106 | WF2=${factor}D ;; |
---|
| 107 | *) |
---|
| 108 | (( ORCA_NWRIHF = 0 )) ;; |
---|
| 109 | esac |
---|
| 110 | else |
---|
| 111 | ORCA_NWRIHF=0 |
---|
| 112 | fi |
---|
| 113 | |
---|
| 114 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 115 | # Needed by OPA namelist to compute correct file names |
---|
| 116 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
| 117 | |
---|
| 118 | ##-- Number of time steps updated : the first, the last and the number of time steps |
---|
| 119 | (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 )) |
---|
| 120 | (( ORCA_NPDT = PeriodLengthInDays * ORCA_NPDT_JOUR )) |
---|
| 121 | (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1)) |
---|
| 122 | |
---|
| 123 | ##-- We force one restart file at the end of the trunk |
---|
| 124 | ORCA_NSTOCK="${ORCA_NITEND}" |
---|
| 125 | |
---|
| 126 | ##-- Let verify the number of time steps per day |
---|
| 127 | (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT )) |
---|
| 128 | (( NB_SEC_JOUR = 60 * 60 * 24 )) |
---|
| 129 | |
---|
[653] | 130 | if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ] ; then |
---|
[583] | 131 | echo " VERIFY ORCA_NPDT_JOUR in opa9.card " |
---|
| 132 | exit |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | ##-- Restart configuration |
---|
| 136 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
| 137 | ORCA_LRSTAR=.FALSE. |
---|
| 138 | ORCA_NRSTDT=0 |
---|
| 139 | # Put ORCA_NMSH=0 when OPA running in parallel mode |
---|
| 140 | ORCA_NMSH=1 |
---|
| 141 | #echo "NO OPA RESTART" |
---|
| 142 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
| 143 | ORCA_LRSTAR=.TRUE. |
---|
| 144 | ORCA_NRSTDT=0 |
---|
| 145 | ORCA_NMSH=0 |
---|
| 146 | #echo "OPA RESTART" |
---|
| 147 | else |
---|
| 148 | ORCA_LRSTAR=.TRUE. |
---|
| 149 | ORCA_NRSTDT=2 |
---|
| 150 | ORCA_NMSH=0 |
---|
| 151 | #echo "OPA RESTART" |
---|
| 152 | fi |
---|
| 153 | |
---|
| 154 | # nleapy configuration |
---|
| 155 | case ${config_UserChoices_CalendarType} in |
---|
[653] | 156 | leap) |
---|
| 157 | ORCA_NLEAPY=1;; |
---|
| 158 | noleap) |
---|
| 159 | ORCA_NLEAPY=0;; |
---|
| 160 | 360d) |
---|
| 161 | ORCA_NLEAPY=30;; |
---|
| 162 | *) |
---|
| 163 | ORCA_NLEAPY=30 |
---|
[583] | 164 | esac |
---|
| 165 | |
---|
| 166 | typeset -r PRECIS=8 |
---|
| 167 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | sed -e "s/${PAT_CEXPER}/ cexper=\"${config_UserChoices_JobName}\"/" \ |
---|
| 171 | -e "s/${PAT_NIT000}/ nit000=${ORCA_NIT000}/" \ |
---|
| 172 | -e "s/${PAT_NITEND}/ nitend=${ORCA_NITEND}/" \ |
---|
| 173 | -e "s/${PAT_NWRITE}/ nwrite=${ORCA_NWRITE}/" \ |
---|
| 174 | -e "s/${PAT_RESTAR}/ ln_rstart=${ORCA_LRSTAR}/" \ |
---|
| 175 | -e "s/${PAT_NPRG}/ nprg=${ORCA_NWRITE}/" \ |
---|
| 176 | -e "s/${PAT_NF_PTR}/ nf_ptr_wri=${ORCA_NWRITE}/" \ |
---|
| 177 | -e "s/${PAT_NSTOCK}/ nstock=${ORCA_NSTOCK}/" \ |
---|
| 178 | -e "s/${PAT_NRSTAR}/ nrstdt=${ORCA_NRSTDT}/" \ |
---|
| 179 | -e "s/${PAT_NDATE0}/ ndate0=${PeriodDateBegin}/" \ |
---|
| 180 | -e "s%${PAT_NLEAPY}% nleapy=${ORCA_NLEAPY}%" \ |
---|
| 181 | -e "s/${PAT_NMSH}/ nmsh=${ORCA_NMSH}/" \ |
---|
| 182 | namelist > namelist.tmp |
---|
| 183 | |
---|
| 184 | IGCM_sys_Mv namelist.tmp namelist |
---|
| 185 | |
---|
| 186 | echo 'Variables automatically updated in ORCA namelist' |
---|
| 187 | grep AUTO namelist |
---|
| 188 | |
---|
| 189 | IGCM_debug_PopStack "OCE_Update" |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | #----------------------------------- |
---|
| 193 | function OCE_Finalize |
---|
| 194 | { |
---|
| 195 | IGCM_debug_PushStack "OCE_Finalize" |
---|
| 196 | |
---|
| 197 | if [ -f date.file ] ; then |
---|
| 198 | # Prefix use in opa9.card AND in lim2.card : |
---|
| 199 | DATE_OPA=$( cat date.file | \ |
---|
| 200 | sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" ) |
---|
| 201 | MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA} |
---|
| 202 | SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA} |
---|
| 203 | fi |
---|
| 204 | |
---|
| 205 | echo FINALIZE OCE !!! |
---|
| 206 | |
---|
| 207 | IGCM_debug_PopStack "OCE_Finalize" |
---|
| 208 | } |
---|