1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function ATM_Initialize |
---|
4 | { |
---|
5 | IGCM_debug_PushStack "ATM_Initialize" |
---|
6 | |
---|
7 | RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' ) |
---|
8 | |
---|
9 | case ${RESOL_ATM} in |
---|
10 | LMD4443) BandsResol=44x43x19 ;; |
---|
11 | LMD7245) BandsResol=72x45x19 ;; |
---|
12 | LMD9671) BandsResol=96x71x19 ;; |
---|
13 | LMD9695) BandsResol=96x95x19 ;; |
---|
14 | LMD14496) BandsResol=144x96x19 ;; |
---|
15 | LMD144142) BandsResol=144x142x19 ;; |
---|
16 | esac |
---|
17 | |
---|
18 | ##--Frequency purpose .... |
---|
19 | ##-- Initialisation .... |
---|
20 | OK_instan=n |
---|
21 | OK_journe=n |
---|
22 | OK_mensuel=n |
---|
23 | ok_hf=n |
---|
24 | |
---|
25 | case ${config_UserChoices_PeriodLength} in |
---|
26 | *Y|*y|*M|*m) OK_mensuel=y ;; |
---|
27 | *D|*d) OK_journe=y ;; |
---|
28 | esac |
---|
29 | |
---|
30 | for frequency in ${config_ATM_WriteFrequency} ; do |
---|
31 | case ${frequency} in |
---|
32 | 5D|5d|1D|1d) OK_journe=y ;; |
---|
33 | esac |
---|
34 | case ${frequency} in |
---|
35 | HF|hf) ok_hf=y ;; |
---|
36 | esac |
---|
37 | done |
---|
38 | |
---|
39 | ##--Variables used by LMDZ in physiq.def -- |
---|
40 | PAT_INST=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def | grep 'OK_instan' ) |
---|
41 | PAT_JOUR=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def | grep 'OK_journe' ) |
---|
42 | PAT_MOIS=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def | grep 'OK_mensuel' ) |
---|
43 | PAT_HFRE=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def | grep 'ok_hf' ) |
---|
44 | ##--Variables used by LMDZ in gcm.def -- |
---|
45 | PAT_iphysiq=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep iphysiq ) |
---|
46 | PAT_iperiod=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep iperiod ) |
---|
47 | PAT_day_step=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep day_step ) |
---|
48 | PAT_ecritphy=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep ecritphy ) |
---|
49 | |
---|
50 | ## Read LMDZ_adjust option in ${compname}.card --> put adjust=y and save Bands_*.dat in ${SUBMIT_DIR}/PARAM |
---|
51 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_adjust |
---|
52 | eval LMDZ_adjust=\${${compname}_UserChoices_LMDZ_adjust} > /dev/null 2>&1 |
---|
53 | |
---|
54 | ##-- This could be define in lmdz.card, inside section [UserChoices] |
---|
55 | ##-- Otherwise we get the value in *.def |
---|
56 | iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' ) |
---|
57 | iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' ) |
---|
58 | # day_step : number of steps per day (multiple of iperiod) |
---|
59 | (( day_step = 48 * iphysiq )) |
---|
60 | |
---|
61 | #[ -f ${SUBMIT_DIR}/PARAM/Bands_${BandsResol}_7prc.dat ] && IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/Bands_${BandsResol}_7prc.dat . |
---|
62 | |
---|
63 | IGCM_debug_PopStack "ATM_Initialize" |
---|
64 | } |
---|
65 | |
---|
66 | #----------------------------------------------------------------- |
---|
67 | function ATM_Update |
---|
68 | { |
---|
69 | IGCM_debug_PushStack "ATM_Update" |
---|
70 | |
---|
71 | ecritphy=${PeriodLengthInDays} |
---|
72 | |
---|
73 | ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def |
---|
74 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
75 | RAZ_DATE=1 |
---|
76 | else |
---|
77 | RAZ_DATE=0 |
---|
78 | fi |
---|
79 | |
---|
80 | ## Mise en forme du fichier physiq.def |
---|
81 | sed -e "s/OK_instan=.*/OK_instan=${OK_instan}/" \ |
---|
82 | -e "s/OK_journe=.*/OK_journe=${OK_journe}/" \ |
---|
83 | -e "s/OK_mensuel=.*/OK_mensuel=${OK_mensuel}/" \ |
---|
84 | -e "s/ok_hf=.*/ok_hf=${ok_hf}/" \ |
---|
85 | physiq.def > physiq.def.tmp |
---|
86 | IGCM_sys_Mv physiq.def.tmp physiq.def |
---|
87 | |
---|
88 | ## Mise en forme du fichier gcm.def |
---|
89 | sed -e "s/${PAT_ecritphy}/ecritphy=${ecritphy}/" \ |
---|
90 | -e "s/${PAT_day_step}/day_step=${day_step}/" \ |
---|
91 | -e "s/${PAT_iperiod}/iperiod=${iperiod}/" \ |
---|
92 | -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/" \ |
---|
93 | gcm.def > gcm.def.tmp |
---|
94 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
95 | |
---|
96 | ## Mise en forme du fichier run.def |
---|
97 | sed -e "s/_dayref_/${InitDay}/" \ |
---|
98 | -e "s/_anneeref_/${InitYear}/" \ |
---|
99 | -e "s/_nday_/${PeriodLengthInDays}/" \ |
---|
100 | -e "s/_raz_date_/${RAZ_DATE}/" \ |
---|
101 | -e "s/_adjust_/${LMDZ_adjust}/" \ |
---|
102 | run.def > run.def.tmp |
---|
103 | IGCM_sys_Mv run.def.tmp run.def |
---|
104 | |
---|
105 | ## Read ByPass_hgardfou_teta option in ${compname}.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ] |
---|
106 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta |
---|
107 | eval ByPass_hgardfou_teta=\${${compname}_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1 |
---|
108 | if [ ${ByPass_hgardfou_teta} = y ] ; then |
---|
109 | awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp |
---|
110 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
111 | echo |
---|
112 | IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def" |
---|
113 | echo |
---|
114 | cat gcm.def |
---|
115 | ByPass_hgardfou_teta=n |
---|
116 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}" |
---|
117 | fi |
---|
118 | |
---|
119 | ## Read ByPass_hgardfou_mats option in ${compname}.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ] |
---|
120 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats |
---|
121 | eval ByPass_hgardfou_mats=\${${compname}_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1 |
---|
122 | if [ ${ByPass_hgardfou_mats} = y ] ; then |
---|
123 | sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp |
---|
124 | IGCM_sys_Mv gcm.def.tmp gcm.def |
---|
125 | echo |
---|
126 | IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def" |
---|
127 | echo |
---|
128 | cat gcm.def |
---|
129 | ByPass_hgardfou_mats=n |
---|
130 | IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}" |
---|
131 | fi |
---|
132 | |
---|
133 | if ( ${FirstInitialize} ) ; then |
---|
134 | |
---|
135 | if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then |
---|
136 | if [ ${DRYRUN} -le 2 ] ; then |
---|
137 | IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/. |
---|
138 | if [ ${DRYRUN} -le 1 ] ; then |
---|
139 | ./create_etat0_limit.e |
---|
140 | fi |
---|
141 | else |
---|
142 | echo "EXECUTION of ./create_etat0_limit.e simulated" |
---|
143 | echo "EXECUTION of ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack |
---|
144 | fi |
---|
145 | fi |
---|
146 | |
---|
147 | fi |
---|
148 | |
---|
149 | IGCM_debug_PopStack "ATM_Update" |
---|
150 | } |
---|
151 | |
---|
152 | #----------------------------------- |
---|
153 | function ATM_Finalize |
---|
154 | { |
---|
155 | IGCM_debug_PushStack "ATM_Finalize" |
---|
156 | |
---|
157 | [ ${LMDZ_adjust} = y ] && IGCM_sys_Cp Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM |
---|
158 | |
---|
159 | echo FINALIZE ATM ! |
---|
160 | |
---|
161 | IGCM_debug_PopStack "ATM_Finalize" |
---|
162 | } |
---|