[5267] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #----------------------------------- |
---|
| 4 | function MBG_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "MBG_Initialize" |
---|
| 7 | |
---|
| 8 | JOB_NAME=${config_UserChoices_JobName} |
---|
| 9 | OPA_NDT_DAY=${pisces_UserChoices_OPA_NDT_DAY:=4} |
---|
| 10 | |
---|
| 11 | # Local function to find namelists parameters |
---|
| 12 | supergrep () { |
---|
| 13 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | ##--Variables used by OPA -- |
---|
| 17 | |
---|
| 18 | # cexper experience name for vairmer format |
---|
| 19 | # nit000 number of the first time step |
---|
| 20 | # nitend number of the last time step |
---|
| 21 | # nleapy leap year calendar (0/1) (30 for 360d) |
---|
| 22 | # nwrite frequency of OUTPUT file |
---|
| 23 | # ln_rstart boolean term for restart (true or false) |
---|
| 24 | # nstock frequency of restart file |
---|
| 25 | # ndate0 initial calendar date aammjj |
---|
| 26 | # rdt time step in seconds (coming from namelist) |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | PAT_CEXPER=$( supergrep cn_exp ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 30 | PAT_NIT000=$( supergrep nn_it000 ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 31 | PAT_NITEND=$( supergrep nn_itend ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 32 | PAT_NLEAPY=$( supergrep nn_leapy ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 33 | PAT_NSTOCK=$( supergrep nn_stock ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 34 | PAT_NDATE0=$( supergrep nn_date0 ${SUBMIT_DIR}/PARAM/namelist ) |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/namelist | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' ) |
---|
| 38 | |
---|
| 39 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 40 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
| 41 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
| 42 | |
---|
| 43 | ##--Variables used by MBG -- |
---|
| 44 | |
---|
| 45 | # lrsttr boolean term for tracer model restart (true or false) |
---|
| 46 | # nrsttr control of the time step (0, 1 or 2) |
---|
| 47 | |
---|
| 48 | ##--Variables used by PISCES -- |
---|
| 49 | |
---|
| 50 | PAT_TOP_LRSTTR=$( supergrep ln_rsttr ${SUBMIT_DIR}/PARAM/namelist_top ) |
---|
| 51 | PAT_TOP_NRSTTR=$( supergrep nn_rsttr ${SUBMIT_DIR}/PARAM/namelist_top ) |
---|
| 52 | PAT_PIS_LRIVER=$( supergrep ln_river ${SUBMIT_DIR}/PARAM/namelist_pisces ) |
---|
| 53 | |
---|
| 54 | ##--Variables used for XMLIO_SERVER configuration file |
---|
| 55 | |
---|
| 56 | # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server |
---|
| 57 | |
---|
| 58 | PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def ) |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | IGCM_debug_PopStack "MBG_Initialize" |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | #----------------------------------- |
---|
| 65 | function MBG_Update |
---|
| 66 | { |
---|
| 67 | IGCM_debug_PushStack "MBG_Update" |
---|
| 68 | |
---|
| 69 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
| 70 | # Needed by OPA namelist to compute correct file names |
---|
| 71 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
| 72 | |
---|
| 73 | ## Count of number of time steps from begin of OPA job |
---|
| 74 | (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NDT_DAY + 1 )) |
---|
| 75 | (( OPA_NDT = PeriodLengthInDays * OPA_NDT_DAY )) |
---|
| 76 | (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1)) |
---|
| 77 | |
---|
| 78 | ## Forcing to write one restart file at the end of period |
---|
| 79 | OPA_NSTOCK="${OPA_NITEND}" |
---|
| 80 | |
---|
| 81 | ## Verification of number of time steps per day |
---|
| 82 | (( NB_SEC_DAY_MODEL = OPA_NDT_DAY * OPA_RDT )) |
---|
| 83 | (( NB_SEC_DAY = 60 * 60 * 24 )) |
---|
| 84 | |
---|
| 85 | if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ] |
---|
| 86 | then |
---|
| 87 | echo " VERIFY OPA_NDT_DAY in pisces.card " |
---|
| 88 | exit |
---|
| 89 | fi |
---|
| 90 | |
---|
| 91 | ## nleapy configuration |
---|
| 92 | case ${config_UserChoices_CalendarType} in |
---|
| 93 | leap) |
---|
| 94 | OPA_NLEAPY=1;; |
---|
| 95 | noleap) |
---|
| 96 | OPA_NLEAPY=0;; |
---|
| 97 | 360d) |
---|
| 98 | OPA_NLEAPY=30;; |
---|
| 99 | esac |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | typeset -r PRECIS=8 |
---|
| 103 | NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) |
---|
| 104 | |
---|
| 105 | sed -e "s%${PAT_CEXPER}% cn_exp=\"${config_UserChoices_JobName}\"%" \ |
---|
| 106 | -e "s%${PAT_NIT000}% nn_it000=${OPA_NIT000}%" \ |
---|
| 107 | -e "s%${PAT_NITEND}% nn_itend=${OPA_NITEND}%" \ |
---|
| 108 | -e "s%${PAT_NSTOCK}% nn_stock=${OPA_NSTOCK}%" \ |
---|
| 109 | -e "s%${PAT_NDATE0}% nn_date0=${PeriodDateBegin}%" \ |
---|
| 110 | -e "s%${PAT_NLEAPY}% nn_leapy=${OPA_NLEAPY}%" \ |
---|
| 111 | namelist > namelist.tmp |
---|
| 112 | |
---|
| 113 | IGCM_sys_Mv namelist.tmp namelist |
---|
| 114 | |
---|
| 115 | ##--Write Frequency Purpose |
---|
| 116 | Nbfreq=$( echo ${config_MBG_WriteFrequency} | wc -w ) |
---|
| 117 | typeset -Z1 i=1 |
---|
| 118 | while [ $i -le ${Nbfreq} ]; do |
---|
| 119 | topfrequency=$( echo ${config_MBG_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' ) |
---|
| 120 | topfactor=$( echo ${topfrequency} | sed -e "s/[yYmMdD]//" ) |
---|
| 121 | case ${topfrequency} in |
---|
| 122 | *Y|*y) |
---|
| 123 | eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}y_${DatesPeriod} ; |
---|
| 124 | eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_Y} ; |
---|
| 125 | eval WFT${i}=${topfactor}Y ;; |
---|
| 126 | *M|*m) |
---|
| 127 | eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}m_${DatesPeriod} ; |
---|
| 128 | eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_M} ; |
---|
| 129 | eval WFT${i}=${topfactor}M ;; |
---|
| 130 | *D|*d) |
---|
| 131 | eval PREFIX_WFT${i}=${config_UserChoices_JobName}_${topfactor}d_${DatesPeriod} ; |
---|
| 132 | eval R_OUT_MBG_WFT${i}=${R_OUT_MBG_O_D} ; |
---|
| 133 | eval WFT${i}=${topfactor}D ;; |
---|
| 134 | *) |
---|
| 135 | esac |
---|
| 136 | let i=$i+1 |
---|
| 137 | done |
---|
| 138 | |
---|
| 139 | ##-- Restart configuration |
---|
| 140 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
| 141 | |
---|
| 142 | #echo "NO RESTART FOR TOP" |
---|
| 143 | TOP_LRSTTR=.FALSE. |
---|
| 144 | TOP_NRSTTR=0 |
---|
| 145 | |
---|
| 146 | PISCES_LRIVER=.FALSE. |
---|
| 147 | |
---|
| 148 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
| 149 | |
---|
| 150 | #echo "RESTART TOP" |
---|
| 151 | TOP_LRSTTR=.TRUE. |
---|
| 152 | TOP_NRSTTR=0 |
---|
| 153 | |
---|
| 154 | PISCES_LRIVER=.TRUE. |
---|
| 155 | |
---|
| 156 | else |
---|
| 157 | |
---|
| 158 | #echo "RESTART TOP" |
---|
| 159 | TOP_LRSTTR=.TRUE. |
---|
| 160 | TOP_NRSTTR=2 |
---|
| 161 | |
---|
| 162 | PISCES_LRIVER=.TRUE. |
---|
| 163 | |
---|
| 164 | fi |
---|
| 165 | |
---|
| 166 | # on force les sorties PISCES comme les sorties OPA |
---|
| 167 | |
---|
| 168 | sed -e "s%${PAT_TOP_LRSTTR}% ln_rsttr=${TOP_LRSTTR}%" \ |
---|
| 169 | -e "s%${PAT_TOP_NRSTTR}% nn_rsttr=${TOP_NRSTTR}%" \ |
---|
| 170 | namelist_top > namelist_top.tmp |
---|
| 171 | |
---|
| 172 | IGCM_sys_Mv namelist_top.tmp namelist_top |
---|
| 173 | |
---|
| 174 | sed -e "s%${PAT_PIS_LRIVER}% ln_river=${PISCES_LRIVER}%" \ |
---|
| 175 | namelist_pisces > namelist_pisces.tmp |
---|
| 176 | |
---|
| 177 | IGCM_sys_Mv namelist_pisces.tmp namelist_pisces |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | IGCM_debug_PopStack "MBG_Update" |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | #----------------------------------- |
---|
| 184 | function MBG_Finalize |
---|
| 185 | { |
---|
| 186 | IGCM_debug_PushStack "MBG_Finalize" |
---|
| 187 | |
---|
| 188 | echo FINALIZE MBG !!! |
---|
| 189 | |
---|
| 190 | IGCM_debug_PopStack "MBG_Finalize" |
---|
| 191 | } |
---|
| 192 | |
---|