1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function ATM_Initialize |
---|
4 | { |
---|
5 | IGCM_debug_PushStack "ATM_Initialize" |
---|
6 | |
---|
7 | RESOL_ATM=$( echo $RESOL | awk "-F-" '{print $1}') |
---|
8 | |
---|
9 | [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19 |
---|
10 | |
---|
11 | RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' ) |
---|
12 | |
---|
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 | |
---|
25 | ##- Create_etat0_limit version |
---|
26 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE |
---|
27 | CREATE=${lmdz_UserChoices_CREATE} |
---|
28 | echo create_etat0_limit version : ${CREATE} |
---|
29 | |
---|
30 | ##- Default number of processor for lmdz |
---|
31 | NUM_PROC_ATM=1 |
---|
32 | if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then |
---|
33 | NUM_PROC_ATM=${BATCH_NUM_PROC_TOT} |
---|
34 | fi |
---|
35 | |
---|
36 | ##--Frequency purpose .... |
---|
37 | ##-- Initialisation .... |
---|
38 | OK_instan=n |
---|
39 | OK_journe=n |
---|
40 | OK_mensuel=n |
---|
41 | ok_hf=n |
---|
42 | |
---|
43 | case ${config_UserChoices_PeriodLength} in |
---|
44 | 1Y|1y|1M|1m) OK_mensuel=y ;; |
---|
45 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
46 | esac |
---|
47 | |
---|
48 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
49 | case ${frequency} in |
---|
50 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
51 | esac |
---|
52 | case ${frequency} in |
---|
53 | HF|hf) ok_hf=y ;; |
---|
54 | esac |
---|
55 | done |
---|
56 | |
---|
57 | ##--Variables used by LMDZ in physiq.def -- |
---|
58 | PAT_INST=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_instan=' ) |
---|
59 | PAT_JOUR=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_journe=' ) |
---|
60 | PAT_MOIS=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'OK_mensuel=' ) |
---|
61 | PAT_HFRE=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ok_hf=' ) |
---|
62 | PAT_ecrit_mth=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ecrit_mth=' ) |
---|
63 | PAT_ecrit_ISCCP=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z} | grep 'ecrit_ISCCP=' ) |
---|
64 | ##--Variables used by LMDZ in gcm.def -- |
---|
65 | PAT_iphysiq=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iphysiq ) |
---|
66 | PAT_iperiod=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iperiod ) |
---|
67 | PAT_day_step=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep day_step ) |
---|
68 | |
---|
69 | ## Read LMDZ_NbPeriod_adjust option in ${compname}.card |
---|
70 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_NbPeriod_adjust |
---|
71 | eval LMDZ_NbPeriod_adjust=\${${compname}_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1 |
---|
72 | |
---|
73 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
74 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_Bands_file_name |
---|
75 | eval LMDZ_Bands_file_name=\${${compname}_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1 |
---|
76 | fi |
---|
77 | |
---|
78 | ##-- This could be define in lmdz.card, inside section [UserChoices] |
---|
79 | ##-- Otherwise we get the value in *.def |
---|
80 | iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' ) |
---|
81 | iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' ) |
---|
82 | # day_step : number of steps per day (multiple of iperiod) |
---|
83 | #(( day_step = 48 * iphysiq )) |
---|
84 | day_step=$( echo ${PAT_day_step} | awk -F= '{print $2}' ) |
---|
85 | |
---|
86 | IGCM_debug_PopStack "ATM_Initialize" |
---|
87 | } |
---|
88 | |
---|
89 | #----------------------------------------------------------------- |
---|
90 | function ATM_Update |
---|
91 | { |
---|
92 | IGCM_debug_PushStack "ATM_Update" |
---|
93 | |
---|
94 | case ${config_UserChoices_PeriodLength} in |
---|
95 | *Y|*y) |
---|
96 | LMDZ_ecrit_mth=30. |
---|
97 | LMDZ_ecrit_ISCCP=30. |
---|
98 | LMDZ_periodav=30. |
---|
99 | if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then |
---|
100 | echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d |
---|
101 | exit |
---|
102 | fi |
---|
103 | ;; |
---|
104 | *) |
---|
105 | LMDZ_ecrit_mth=${PeriodLengthInDays}. |
---|
106 | LMDZ_ecrit_ISCCP=${PeriodLengthInDays}. |
---|
107 | LMDZ_periodav=${PeriodLengthInDays}. |
---|
108 | ;; |
---|
109 | esac |
---|
110 | |
---|
111 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
112 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
113 | RAZ_DATE=1 |
---|
114 | else |
---|
115 | RAZ_DATE=0 |
---|
116 | fi |
---|
117 | |
---|
118 | ## algo : For CumulPeriod=1 ; |
---|
119 | ## IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix |
---|
120 | ## ELSE LMDZ_adjust=y ; save Bands file on file server ; |
---|
121 | ## For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ; |
---|
122 | ## For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ; |
---|
123 | |
---|
124 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
125 | if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then |
---|
126 | IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat |
---|
127 | 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_0 |
---|
128 | IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0" |
---|
129 | fi |
---|
130 | fi |
---|
131 | |
---|
132 | LMDZ_adjust=n |
---|
133 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y |
---|
134 | |
---|
135 | RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart |
---|
136 | [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) |
---|
137 | |
---|
138 | [ ${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 |
---|
139 | |
---|
140 | ## Mise en forme du fichier physiq.def |
---|
141 | sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/" \ |
---|
142 | -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/" \ |
---|
143 | -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/" \ |
---|
144 | -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/" \ |
---|
145 | -e "s/${PAT_ecrit_mth}/ecrit_mth=${LMDZ_ecrit_mth}/" \ |
---|
146 | -e "s/${PAT_ecrit_ISCCP}/ecrit_ISCCP=${LMDZ_ecrit_ISCCP}/" \ |
---|
147 | physiq.def > physiq.def.tmp |
---|
148 | IGCM_sys_Mv physiq.def.tmp physiq.def |
---|
149 | |
---|
150 | ## Mise en forme du fichier gcm.def |
---|
151 | sed -e "s/${PAT_day_step}/day_step=${day_step}/" \ |
---|
152 | -e "s/${PAT_iperiod}/iperiod=${iperiod}/" \ |
---|
153 | -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/" \ |
---|
154 | gcm.def > gcm.def.tmp |
---|
155 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
156 | |
---|
157 | ## Mise en forme du fichier run.def |
---|
158 | sed -e "s/_dayref_/${InitDay}/" \ |
---|
159 | -e "s/_anneeref_/${InitYear}/" \ |
---|
160 | -e "s/_calend_/${CalendarTypeForLmdz}/" \ |
---|
161 | -e "s/_nday_/${PeriodLengthInDays}/" \ |
---|
162 | -e "s/_raz_date_/${RAZ_DATE}/" \ |
---|
163 | -e "s/_periodav_/${LMDZ_periodav}/" \ |
---|
164 | -e "s/_adjust_/${LMDZ_adjust}/" \ |
---|
165 | run.def > run.def.tmp |
---|
166 | IGCM_sys_Mv run.def.tmp run.def |
---|
167 | |
---|
168 | IGCM_debug_PopStack "ATM_Update" |
---|
169 | } |
---|
170 | |
---|
171 | #----------------------------------- |
---|
172 | function ATM_Finalize |
---|
173 | { |
---|
174 | IGCM_debug_PushStack "ATM_Finalize" |
---|
175 | |
---|
176 | [ ${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} |
---|
177 | |
---|
178 | echo FINALIZE ATM ! |
---|
179 | |
---|
180 | IGCM_debug_PopStack "ATM_Finalize" |
---|
181 | } |
---|