1 | #- $Id$ |
---|
2 | #!/bin/ksh |
---|
3 | |
---|
4 | #----------------------------------------------------------------- |
---|
5 | function ATM_Initialize |
---|
6 | { |
---|
7 | IGCM_debug_PushStack "ATM_Initialize" |
---|
8 | |
---|
9 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' ) |
---|
10 | case ${RESOL_ATM} in |
---|
11 | LMD7245) BandsResol=72x45x19 ;; |
---|
12 | LMD9671) BandsResol=96x71x19 ;; |
---|
13 | LMD9672) BandsResol=96x72x19 ;; |
---|
14 | LMD9695) BandsResol=96x95x19 ;; |
---|
15 | LMD14496) BandsResol=144x96x19 ;; |
---|
16 | LMD144142) BandsResol=144x142x19 ;; |
---|
17 | esac |
---|
18 | |
---|
19 | |
---|
20 | ##-- Calendar type for LMDZ |
---|
21 | case ${config_UserChoices_CalendarType} in |
---|
22 | leap|gregorian) |
---|
23 | CalendarTypeForLmdz=earth_366d;; |
---|
24 | noleap) |
---|
25 | CalendarTypeForLmdz=earth_365d;; |
---|
26 | 360d) |
---|
27 | CalendarTypeForLmdz=earth_360d;; |
---|
28 | *) |
---|
29 | CalendarTypeForLmdz=earth_360d |
---|
30 | esac |
---|
31 | |
---|
32 | ##- Default number of processor for lmdz |
---|
33 | NUM_PROC_ATM=1 |
---|
34 | if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then |
---|
35 | NUM_PROC_ATM=${BATCH_NUM_PROC_TOT} |
---|
36 | fi |
---|
37 | |
---|
38 | ##--Frequency purpose .... |
---|
39 | ##-- Initialisation .... |
---|
40 | OK_instan=n |
---|
41 | ##-- |
---|
42 | OK_journe=n |
---|
43 | OK_mensuel=y |
---|
44 | |
---|
45 | case ${config_UserChoices_PeriodLength} in |
---|
46 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
47 | 5D|5d|1D|1d) OK_journe=n ;; |
---|
48 | esac |
---|
49 | |
---|
50 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
51 | case ${frequency} in |
---|
52 | 5D|5d|1D|1d) OK_journe=n ;; |
---|
53 | esac |
---|
54 | done |
---|
55 | |
---|
56 | ##--Variables used by LMDZ -- |
---|
57 | PAT_INST=$( grep 'OK_instan' ${SUBMIT_DIR}/PARAM/physiq.def ) |
---|
58 | PAT_JOUR=$( grep 'OK_journe' ${SUBMIT_DIR}/PARAM/physiq.def ) |
---|
59 | PAT_MOIS=$( grep 'OK_mensuel' ${SUBMIT_DIR}/PARAM/physiq.def ) |
---|
60 | |
---|
61 | PAT_iphysiq=$( grep 'iphysiq' ${SUBMIT_DIR}/PARAM/gcm.def ) |
---|
62 | PAT_iperiod=$( grep 'iperiod' ${SUBMIT_DIR}/PARAM/gcm.def | tail -1) |
---|
63 | PAT_day_step=$( grep 'day_step' ${SUBMIT_DIR}/PARAM/gcm.def ) |
---|
64 | PAT_ecritphy=$( grep 'ecritphy' ${SUBMIT_DIR}/PARAM/gcm.def ) |
---|
65 | |
---|
66 | |
---|
67 | ## Read LMDZ_NbPeriod_adjust option in lmdz.card |
---|
68 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust |
---|
69 | eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
70 | |
---|
71 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
72 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name |
---|
73 | eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
74 | fi |
---|
75 | |
---|
76 | |
---|
77 | ##-- This could be define in lmdz.card, inside section [UserChoices] |
---|
78 | ##-- Otherwise we get the value in *.def |
---|
79 | iperiod=$(grep iperiod ${SUBMIT_DIR}/PARAM/gcm.def | awk -F= '{print $2}' | tail -1) |
---|
80 | iphysiq=$(grep iphysiq ${SUBMIT_DIR}/PARAM/gcm.def | awk -F= '{print $2}') |
---|
81 | # day_step : number of steps per day (multiple of iperiod) |
---|
82 | (( day_step = 48 * iphysiq )) |
---|
83 | |
---|
84 | IGCM_debug_PopStack "ATM_Initialize" |
---|
85 | } |
---|
86 | |
---|
87 | #----------------------------------------------------------------- |
---|
88 | function ATM_Update |
---|
89 | { |
---|
90 | IGCM_debug_PushStack "ATM_Update" |
---|
91 | |
---|
92 | ecritphy=${PeriodLengthInDays} |
---|
93 | |
---|
94 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
95 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
96 | RAZ_DATE=1 |
---|
97 | else |
---|
98 | RAZ_DATE=0 |
---|
99 | fi |
---|
100 | |
---|
101 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
102 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
103 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat |
---|
104 | IGCM_sys_Put_Out Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_0 |
---|
105 | IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_0" |
---|
106 | fi |
---|
107 | fi |
---|
108 | |
---|
109 | LMDZ_adjust=n |
---|
110 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
111 | |
---|
112 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
113 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
114 | |
---|
115 | [ ${CumulPeriod} -gt 1 ] && IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat |
---|
116 | |
---|
117 | ## Mise en forme du fichier physiq.def |
---|
118 | sed -e "s/OK_instan=.*/OK_instan=${OK_instan}/" \ |
---|
119 | -e "s/OK_journe=.*/OK_journe=${OK_journe}/" \ |
---|
120 | -e "s/OK_mensuel=.*/OK_mensuel=${OK_mensuel}/" \ |
---|
121 | physiq.def > physiq.def.tmp |
---|
122 | IGCM_sys_Mv physiq.def.tmp physiq.def |
---|
123 | |
---|
124 | ## Mise en forme du fichier gcm.def |
---|
125 | sed -e "s/${PAT_ecritphy}/ecritphy=${ecritphy}/" \ |
---|
126 | -e "s/${PAT_day_step}/day_step=${day_step}/" \ |
---|
127 | -e "s/${PAT_iperiod}/iperiod=${iperiod}/" \ |
---|
128 | -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/" \ |
---|
129 | gcm.def > gcm.def.tmp |
---|
130 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
131 | |
---|
132 | greg_dat=$( IGCM_date_ConvertFormatToGregorian $PeriodDateBegin ) |
---|
133 | jul_dat=$( IGCM_date_ConvertGregorianDateToJulian $greg_dat ) |
---|
134 | nbjour=$( expr \( $jul_dat \% 1000 \) ) |
---|
135 | yractu=$( expr $greg_dat / 10000 ) |
---|
136 | echo "dayref = " $nbjour "year actu = " $yractu |
---|
137 | |
---|
138 | ## Mise en forme du fichier run.def |
---|
139 | sed -e "s/_dayref_/${nbjour}/" \ |
---|
140 | -e "s/_anneeref_/${yractu}/" \ |
---|
141 | -e "s/_calend_/${CalendarTypeForLmdz}/" \ |
---|
142 | -e "s/_nday_/${PeriodLengthInDays}/" \ |
---|
143 | -e "s/_raz_date_/${RAZ_DATE}/" \ |
---|
144 | -e "s/_adjust_/${LMDZ_adjust}/" \ |
---|
145 | run.def > run.def.tmp |
---|
146 | IGCM_sys_Mv run.def.tmp run.def |
---|
147 | |
---|
148 | IGCM_debug_PopStack "ATM_Update" |
---|
149 | } |
---|
150 | |
---|
151 | #----------------------------------- |
---|
152 | function ATM_Finalize |
---|
153 | { |
---|
154 | IGCM_debug_PushStack "ATM_Finalize" |
---|
155 | |
---|
156 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_${CumulPeriod} |
---|
157 | echo FINALIZE ATM ! |
---|
158 | |
---|
159 | IGCM_debug_PopStack "ATM_Finalize" |
---|
160 | } |
---|