source: CMIP5/1pctCO2/v5.1pctCO2NP1/COMP/lmdz.driver @ 1589

Last change on this file since 1589 was 1589, checked in by lfairhead, 13 years ago

v5.1pctCO2NP1 CMIP5 IPSL simulation registration
IPSLCM5B configuration 1pctCO2 simulation

File size: 10.0 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=n
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   ## CO2 forcing for the current year
162    IPCC_CO2=`grep Annee_${year} CMIP_CO2_1850_2050.txt | awk -F= '{print $2}'`
163    echo IPCC_CO2=${IPCC_CO2}
164
165    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
166#    LMDZ_sed physiq.def OK_instan   ${OK_instan}
167#    LMDZ_sed physiq.def OK_journe   ${OK_journe}
168#    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel}
169#    LMDZ_sed physiq.def ok_hf       ${ok_hf}
170#    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
171    LMDZ_sed config.def phys_out_filekeys "${OK_mensuel} ${OK_journe} ${ok_hf} ${OK_instan} ${OK_les}"
172    LMDZ_string_sed config.def _ecrit-mth_   ${LMDZ_ecrit_mth}
173#    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
174    LMDZ_sed config.def ok_cosp     ${LMDZ_COSP_OK}
175    LMDZ_sed config.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
176    LMDZ_sed config.def ok_journeCOSP   ${LMDZ_COSP_daily}
177    LMDZ_sed config.def ok_hfCOSP   ${LMDZ_COSP_hf}
178    LMDZ_sed config.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
179    LMDZ_sed config.def co2_ppm     ${IPCC_CO2}
180
181
182    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
183
184    ## run.def parameters
185    LMDZ_sed run.def dayref   ${InitDay}
186    LMDZ_sed run.def anneeref ${InitYear}
187    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
188    LMDZ_sed run.def nday     ${PeriodLengthInDays}
189    LMDZ_sed run.def raz_date ${RAZ_DATE}
190    LMDZ_sed run.def periodav ${LMDZ_periodav}
191    LMDZ_sed run.def adjust   ${LMDZ_adjust}
192
193# No filtre fft in case of zoom, 280x280x39-ZAf contains zoom
194    if [ ${RESOL_ATM_3D} = "280x280x39-ZAf" ] || [ ${RESOL_ATM_3D} = "360x180x19-ZIn" ] ; then
195         LMDZ_sed run.def use_filtre_fft n
196    fi
197
198    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
199    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
200    ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
201    if [ ${ByPass_hgardfou_teta} = y ] ; then
202        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
203        IGCM_sys_Mv gcm.def.tmp gcm.def
204        echo
205        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
206        echo
207        cat gcm.def
208        ByPass_hgardfou_teta=n
209        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
210    fi
211
212    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
213    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
214    ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
215    if [ ${ByPass_hgardfou_mats} = y ] ; then
216        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
217        IGCM_sys_Mv gcm.def.tmp gcm.def
218        echo
219        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
220        echo
221        cat gcm.def
222        ByPass_hgardfou_mats=n
223        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
224    fi
225
226    if ( ${FirstInitialize} ) ; then
227
228        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
229            if [ ${DRYRUN} -le 2 ] ; then
230                ##-- suppression of ozone file construction --
231                cp physiq.def physiq.def.save
232                LMDZ_sed physiq.def read_climoz 0
233                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
234                if [ ${DRYRUN} -le 1 ] ; then
235                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
236                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
237                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
238                fi
239                IGCM_sys_Mv physiq.def.save physiq.def
240            else
241                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
242                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
243            fi
244        fi
245
246    fi
247
248    IGCM_debug_PopStack "ATM_Update"
249}
250
251#-----------------------------------
252function ATM_Finalize
253{
254    IGCM_debug_PushStack "ATM_Finalize"
255
256    [ ${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}
257
258    echo FINALIZE ATM !
259
260    IGCM_debug_PopStack "ATM_Finalize"
261}
Note: See TracBrowser for help on using the repository browser.