source: CONFIG/IPSLCM/IPSLCM5B/historical/COMP/lmdz.driver @ 4850

Last change on this file since 4850 was 1803, checked in by lfairhead, 12 years ago

Update of piControl and historical experiments for IPSLCM5B configuration
(Files are those used for the CMIP5 exercise)

File size: 10.8 KB
Line 
1# $Id$
2#
3#!/bin/ksh
4#-----------------------------------------------------------------
5function LMDZ_sed
6{
7    IGCM_debug_PushStack "LMDZ_sed"
8
9    sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp
10    RET=$?
11    echo "LMDZ_sed : ${1} ${2} ${3}"
12    \mv ${1}.tmp ${1}
13
14    IGCM_debug_PopStack "LMDZ_sed"
15    return $RET
16}
17
18function LMDZ_string_sed
19{
20    IGCM_debug_PushStack "LMDZ_string_sed"
21
22    sed -e "s/${2}/${3}/" ${1} > ${1}.tmp
23    RET=$?
24    echo "LMDZ_sed : ${1} ${2} ${3}"
25    \mv ${1}.tmp ${1}
26
27    IGCM_debug_PopStack "LMDZ_string_sed"
28    return $RET
29}
30
31function ATM_Initialize
32{
33    IGCM_debug_PushStack "ATM_Initialize"
34
35    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}')
36
37    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
38
39    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
40
41    ##-- Calendar type for LMDZ
42    case ${config_UserChoices_CalendarType} in
43        leap|gregorian)
44            CalendarTypeForLmdz=earth_366d;;
45        noleap)
46            CalendarTypeForLmdz=earth_365d;;
47        360d)
48            CalendarTypeForLmdz=earth_360d;;
49        *)
50            CalendarTypeForLmdz=earth_360d
51    esac
52
53    ##--Frequency purpose ....
54    ##--  Initialisation  ....
55    OK_instan=n
56    OK_journe=n
57    OK_mensuel=n
58    ok_hf=n
59    OK_les=y
60
61    case ${config_UserChoices_PeriodLength} in
62        1Y|1y|1M|1m) OK_mensuel=y ;;
63        5D|5d|1D|1d) OK_journe=y ;;
64    esac
65
66    for frequency in ${config_ATM_WriteFrequency} ; do
67        case ${frequency} in
68            5D|5d|1D|1d) OK_journe=y ;;
69        esac
70        case ${frequency} in
71            HF|hf) 
72                ok_hf=y
73                OK_instan=y
74                ;;
75        esac
76    done
77
78    ## Read LMDZPhysics option in lmdz.card
79    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Physics
80    LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
81
82    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
83    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
84    LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust}
85
86    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
87        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
88        LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name}
89    fi
90
91    ##  Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card
92    LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero}
93    LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero}
94
95    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
96    LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK}
97    LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly}
98    LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily}
99    LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf}
100
101    ##  Read LMDZ_NMC_monthly  LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card
102    LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly}
103    LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily}
104    LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf}
105
106    IGCM_debug_PopStack "ATM_Initialize"
107}
108
109#-----------------------------------------------------------------
110function ATM_Update
111{
112    IGCM_debug_PushStack "ATM_Update"
113
114    case ${config_UserChoices_PeriodLength} in
115        *Y|*y) 
116#               LMDZ_ecrit_mth=30.
117               LMDZ_ecrit_mth=1mth
118               LMDZ_ecrit_ISCCP=30.
119               LMDZ_periodav=30.
120               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
121                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
122                  exit
123               fi
124               ;;
125        *)
126               LMDZ_ecrit_mth="${PeriodLengthInDays}""day"
127               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
128               LMDZ_periodav=${PeriodLengthInDays}.
129               ;;
130    esac
131
132    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
133    if [ ${CumulPeriod} -eq 1 ] ; then
134        RAZ_DATE=1
135    else
136        RAZ_DATE=0
137    fi
138
139    ## algo : For CumulPeriod=1 ;
140    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
141    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
142    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
143    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
144
145    if [ ${CumulPeriod} -eq 1 ] ; then
146        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
147            IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
148            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
149            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"
150        fi
151    fi
152
153    LMDZ_adjust=n
154    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
155
156    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
157    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
158
159    [ ${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 ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat )
160
161    ##-- GHG forcing for the current year
162    IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES_1610_2008.txt | awk -F= '{print $2}'`
163    IPCC_CO2=`grep Annee_${year} CO2_1765_2005.txt | awk -F= '{print $2}'`
164    IPCC_CH4=`grep Annee_${year} CH4_1765_2005.txt | awk -F= '{print $2}'`
165    IPCC_N2O=`grep Annee_${year} N2O_1765_2005.txt | awk -F= '{print $2}'`
166    IPCC_CFC11=`grep Annee_${year} CFC11_1765_2005.txt | awk -F= '{print $2}'`
167    IPCC_CFC12=`grep Annee_${year} CFC12_1765_2005.txt | awk -F= '{print $2}'`
168
169    ##-- For historical daily cosp must be output during 1979-2005 period
170    [ ${year} -ge 1979 ] && LMDZ_COSP_daily=y
171
172    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
173#    LMDZ_sed physiq.def OK_instan   ${OK_instan}
174#    LMDZ_sed physiq.def OK_journe   ${OK_journe}
175#    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel}
176#    LMDZ_sed physiq.def ok_hf       ${ok_hf}
177#    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
178    LMDZ_sed config.def phys_out_filekeys "${OK_mensuel} ${OK_journe} ${ok_hf} ${OK_instan} ${OK_les}"
179    LMDZ_string_sed config.def _ecrit-mth_   ${LMDZ_ecrit_mth}
180#    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
181    LMDZ_sed config.def ok_cosp     ${LMDZ_COSP_OK}
182    LMDZ_sed config.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
183    LMDZ_sed config.def ok_journeCOSP   ${LMDZ_COSP_daily}
184    LMDZ_sed config.def ok_hfCOSP   ${LMDZ_COSP_hf}
185    LMDZ_sed config.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
186    LMDZ_sed config.def solaire     ${IPCC_SOLAR}
187    LMDZ_sed config.def co2_ppm     ${IPCC_CO2}
188    LMDZ_sed config.def CH4_ppb     ${IPCC_CH4}
189    LMDZ_sed config.def N2O_ppb     ${IPCC_N2O}
190    LMDZ_sed config.def CFC11_ppt   ${IPCC_CFC11}
191    LMDZ_sed config.def CFC12_ppt   ${IPCC_CFC12}
192
193    LMDZ_string_sed config.def _ecrit-mth_   ${LMDZ_ecrit_mth}
194    LMDZ_sed config.def ecrit_mth ${LMDZ_ecrit_ISCCP}
195
196    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
197
198    ## run.def parameters
199    LMDZ_sed run.def dayref   ${InitDay}
200    LMDZ_sed run.def anneeref ${InitYear}
201    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
202    LMDZ_sed run.def nday     ${PeriodLengthInDays}
203    LMDZ_sed run.def raz_date ${RAZ_DATE}
204    LMDZ_sed run.def periodav ${LMDZ_periodav}
205    LMDZ_sed run.def adjust   ${LMDZ_adjust}
206
207# No filtre fft in case of zoom, 280x280x39-ZAf contains zoom
208    if [ ${RESOL_ATM_3D} = "280x280x39-ZAf" ] || [ ${RESOL_ATM_3D} = "360x180x19-ZIn" ] ; then
209         LMDZ_sed run.def use_filtre_fft n
210    fi
211
212    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
213    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
214    ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
215    if [ ${ByPass_hgardfou_teta} = y ] ; then
216        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
217        IGCM_sys_Mv gcm.def.tmp gcm.def
218        echo
219        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
220        echo
221        cat gcm.def
222        ByPass_hgardfou_teta=n
223        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
224    fi
225
226    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
227    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
228    ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
229    if [ ${ByPass_hgardfou_mats} = y ] ; then
230        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
231        IGCM_sys_Mv gcm.def.tmp gcm.def
232        echo
233        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
234        echo
235        cat gcm.def
236        ByPass_hgardfou_mats=n
237        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
238    fi
239
240    if ( ${FirstInitialize} ) ; then
241
242        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
243            if [ ${DRYRUN} -le 2 ] ; then
244                ##-- suppression of ozone file construction --
245                cp physiq.def physiq.def.save
246                LMDZ_sed physiq.def read_climoz 0
247                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
248                if [ ${DRYRUN} -le 1 ] ; then
249                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
250                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
251                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
252                fi
253                IGCM_sys_Mv physiq.def.save physiq.def
254            else
255                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
256                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
257            fi
258        fi
259
260    fi
261
262    IGCM_debug_PopStack "ATM_Update"
263}
264
265#-----------------------------------
266function ATM_Finalize
267{
268    IGCM_debug_PushStack "ATM_Finalize"
269
270    [ ${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}
271
272    echo FINALIZE ATM !
273
274    IGCM_debug_PopStack "ATM_Finalize"
275}
Note: See TracBrowser for help on using the repository browser.