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