[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------------------------------------- |
---|
| 3 | function ATM_Initialize |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "ATM_Initialize" |
---|
| 6 | |
---|
[671] | 7 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}') |
---|
[396] | 8 | |
---|
[659] | 9 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
[396] | 10 | |
---|
[659] | 11 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
[649] | 12 | |
---|
[697] | 13 | ##-- Calendar type for LMDZ |
---|
| 14 | case ${config_UserChoices_CalendarType} in |
---|
| 15 | leap|gregorian) |
---|
| 16 | CalendarTypeForLmdz=earth_366d;; |
---|
| 17 | noleap) |
---|
| 18 | CalendarTypeForLmdz=earth_365d;; |
---|
| 19 | 360d) |
---|
| 20 | CalendarTypeForLmdz=earth_360d;; |
---|
| 21 | *) |
---|
| 22 | CalendarTypeForLmdz=earth_360d |
---|
| 23 | esac |
---|
| 24 | |
---|
[396] | 25 | ##--Frequency purpose .... |
---|
| 26 | ##-- Initialisation .... |
---|
| 27 | OK_instan=n |
---|
| 28 | OK_journe=n |
---|
| 29 | OK_mensuel=n |
---|
| 30 | ok_hf=n |
---|
| 31 | |
---|
| 32 | case ${config_UserChoices_PeriodLength} in |
---|
| 33 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
| 34 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 35 | esac |
---|
| 36 | |
---|
| 37 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
| 38 | case ${frequency} in |
---|
| 39 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
| 40 | esac |
---|
| 41 | case ${frequency} in |
---|
| 42 | HF|hf) ok_hf=y ;; |
---|
| 43 | esac |
---|
| 44 | done |
---|
| 45 | |
---|
| 46 | ##--Variables used by LMDZ in physiq.def -- |
---|
[697] | 47 | PAT_INST=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_instan=' ) |
---|
| 48 | PAT_JOUR=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_journe=' ) |
---|
| 49 | PAT_MOIS=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_mensuel=' ) |
---|
| 50 | PAT_HFRE=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ok_hf=' ) |
---|
| 51 | PAT_ecrit_mth=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ecrit_mth=' ) |
---|
| 52 | PAT_ecrit_ISCCP=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ecrit_ISCCP=' ) |
---|
[396] | 53 | ##--Variables used by LMDZ in gcm.def -- |
---|
[666] | 54 | PAT_iphysiq=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iphysiq ) |
---|
| 55 | PAT_iperiod=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iperiod ) |
---|
| 56 | PAT_day_step=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep day_step ) |
---|
[396] | 57 | |
---|
[744] | 58 | ## Read LMDZ_NbPeriod_adjust option in ${compname}.card |
---|
| 59 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_NbPeriod_adjust |
---|
| 60 | eval LMDZ_NbPeriod_adjust=\${${compname}_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
| 61 | |
---|
| 62 | ## algo : CumulPeriod=1 ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 63 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Fetch Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
| 64 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Fetch Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust) ; Use Bands ; |
---|
[396] | 65 | |
---|
| 66 | ##-- This could be define in lmdz.card, inside section [UserChoices] |
---|
| 67 | ##-- Otherwise we get the value in *.def |
---|
| 68 | iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' ) |
---|
| 69 | iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' ) |
---|
| 70 | # day_step : number of steps per day (multiple of iperiod) |
---|
[641] | 71 | #(( day_step = 48 * iphysiq )) |
---|
| 72 | day_step=$( echo ${PAT_day_step} | awk -F= '{print $2}' ) |
---|
[396] | 73 | |
---|
| 74 | IGCM_debug_PopStack "ATM_Initialize" |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | #----------------------------------------------------------------- |
---|
| 78 | function ATM_Update |
---|
| 79 | { |
---|
| 80 | IGCM_debug_PushStack "ATM_Update" |
---|
| 81 | |
---|
[750] | 82 | case ${config_UserChoices_PeriodLength} in |
---|
| 83 | *Y|*y) |
---|
| 84 | LMDZ_ecrit_mth=30. |
---|
| 85 | LMDZ_ecrit_ISCCP=30. |
---|
| 86 | LMDZ_periodav=30. |
---|
[766] | 87 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
[750] | 88 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
| 89 | exit |
---|
| 90 | fi |
---|
| 91 | ;; |
---|
| 92 | *) |
---|
| 93 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
| 94 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
| 95 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
| 96 | ;; |
---|
| 97 | esac |
---|
[396] | 98 | |
---|
| 99 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
| 100 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 101 | RAZ_DATE=1 |
---|
| 102 | else |
---|
| 103 | RAZ_DATE=0 |
---|
| 104 | fi |
---|
| 105 | |
---|
[744] | 106 | LMDZ_adjust=n |
---|
| 107 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
| 108 | |
---|
| 109 | RefPeriod=${LMDZ_NbPeriod_adjust} |
---|
| 110 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
| 111 | |
---|
| 112 | [ ${CumulPeriod} -gt 1 ] && IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
| 113 | |
---|
[396] | 114 | ## Mise en forme du fichier physiq.def |
---|
[697] | 115 | sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/" \ |
---|
| 116 | -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/" \ |
---|
| 117 | -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/" \ |
---|
| 118 | -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/" \ |
---|
| 119 | -e "s/${PAT_ecrit_mth}/ecrit_mth=${LMDZ_ecrit_mth}/" \ |
---|
| 120 | -e "s/${PAT_ecrit_ISCCP}/ecrit_ISCCP=${LMDZ_ecrit_ISCCP}/" \ |
---|
[396] | 121 | physiq.def > physiq.def.tmp |
---|
| 122 | IGCM_sys_Mv physiq.def.tmp physiq.def |
---|
| 123 | |
---|
| 124 | ## Mise en forme du fichier gcm.def |
---|
[666] | 125 | sed -e "s/${PAT_day_step}/day_step=${day_step}/" \ |
---|
| 126 | -e "s/${PAT_iperiod}/iperiod=${iperiod}/" \ |
---|
| 127 | -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/" \ |
---|
[396] | 128 | gcm.def > gcm.def.tmp |
---|
| 129 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 130 | |
---|
| 131 | ## Mise en forme du fichier run.def |
---|
| 132 | sed -e "s/_dayref_/${InitDay}/" \ |
---|
| 133 | -e "s/_anneeref_/${InitYear}/" \ |
---|
[697] | 134 | -e "s/_calend_/${CalendarTypeForLmdz}/" \ |
---|
[396] | 135 | -e "s/_nday_/${PeriodLengthInDays}/" \ |
---|
| 136 | -e "s/_raz_date_/${RAZ_DATE}/" \ |
---|
[697] | 137 | -e "s/_periodav_/${LMDZ_periodav}/" \ |
---|
[396] | 138 | -e "s/_adjust_/${LMDZ_adjust}/" \ |
---|
| 139 | run.def > run.def.tmp |
---|
| 140 | IGCM_sys_Mv run.def.tmp run.def |
---|
| 141 | |
---|
| 142 | ## Read ByPass_hgardfou_teta option in ${compname}.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
| 143 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta |
---|
| 144 | eval ByPass_hgardfou_teta=\${${compname}_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
| 145 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
| 146 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
| 147 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 148 | echo |
---|
| 149 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
| 150 | echo |
---|
| 151 | cat gcm.def |
---|
| 152 | ByPass_hgardfou_teta=n |
---|
| 153 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
| 154 | fi |
---|
| 155 | |
---|
| 156 | ## Read ByPass_hgardfou_mats option in ${compname}.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
| 157 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats |
---|
| 158 | eval ByPass_hgardfou_mats=\${${compname}_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
| 159 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
| 160 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
| 161 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
| 162 | echo |
---|
| 163 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
| 164 | echo |
---|
| 165 | cat gcm.def |
---|
| 166 | ByPass_hgardfou_mats=n |
---|
| 167 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
| 168 | fi |
---|
| 169 | |
---|
| 170 | if ( ${FirstInitialize} ) ; then |
---|
| 171 | |
---|
| 172 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
| 173 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 174 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
| 175 | if [ ${DRYRUN} -le 1 ] ; then |
---|
| 176 | ./create_etat0_limit.e |
---|
| 177 | fi |
---|
| 178 | else |
---|
| 179 | echo "EXECUTION of ./create_etat0_limit.e simulated" |
---|
| 180 | echo "EXECUTION of ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
| 181 | fi |
---|
| 182 | fi |
---|
| 183 | |
---|
| 184 | fi |
---|
| 185 | |
---|
| 186 | IGCM_debug_PopStack "ATM_Update" |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | #----------------------------------- |
---|
| 190 | function ATM_Finalize |
---|
| 191 | { |
---|
| 192 | IGCM_debug_PushStack "ATM_Finalize" |
---|
| 193 | |
---|
[744] | 194 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
[396] | 195 | |
---|
| 196 | echo FINALIZE ATM ! |
---|
| 197 | |
---|
| 198 | IGCM_debug_PopStack "ATM_Finalize" |
---|
| 199 | } |
---|