source: CONFIG/IPSLCM/IPSLCM5B/piControl/COMP/lmdz.driver @ 4444

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