source: CONFIG/IPSLCM/IPSLCM5B/EXP00/COMP/lmdz.driver @ 3708

Last change on this file since 3708 was 1220, checked in by lfairhead, 14 years ago

Modifications needed to take advantage of the split in physiq.def in LMDZ.
The old physiq.def is split in 2: a shorter physiq.def that only includes
parameters and constants needed by the parametrizations and a config.def that
includes information related to the configuration one wishes to run (e.g. orbital
parameters, gaz constants, aerosols, etc...). The output.def is also taken into account

Warning: work in progress. Probably still needs some testing. Tested on brodie for the moment

File size: 9.4 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function LMDZ_sed
4{
5    IGCM_debug_PushStack "LMDZ_sed"
6
7    sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp
8    RET=$?
9    echo "LMDZ_sed : ${1} ${2} ${3}"
10    \mv ${1}.tmp ${1}
11
12    IGCM_debug_PopStack "LMDZ_sed"
13    return $RET
14}
15
16function LMDZ_string_sed
17{
18    IGCM_debug_PushStack "LMDZ_string_sed"
19
20    sed -e "s/${2}/${3}/" ${1} > ${1}.tmp
21    RET=$?
22    echo "LMDZ_sed : ${1} ${2} ${3}"
23    \mv ${1}.tmp ${1}
24
25    IGCM_debug_PopStack "LMDZ_string_sed"
26    return $RET
27}
28
29function ATM_Initialize
30{
31    IGCM_debug_PushStack "ATM_Initialize"
32
33    set -vx
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
60    case ${config_UserChoices_PeriodLength} in
61        1Y|1y|1M|1m) OK_mensuel=y ;;
62        5D|5d|1D|1d) OK_journe=y ;;
63    esac
64
65    for frequency in ${config_ATM_WriteFrequency} ; do
66        case ${frequency} in
67            5D|5d|1D|1d) OK_journe=y ;;
68        esac
69        case ${frequency} in
70            HF|hf) ok_hf=y ;;
71        esac
72    done
73
74    ## Read LMDZPhysics option in lmdz.card
75    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Physics
76    LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
77
78    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
79    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
80    LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust}
81
82    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
83        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
84        LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name}
85    fi
86
87    ##  Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card
88    LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero}
89    LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero}
90
91    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
92    LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK}
93    LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly}
94    LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily}
95    LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf}
96
97    ##  Read LMDZ_NMC_monthly  LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card
98    LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly}
99    LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily}
100    LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf}
101
102    IGCM_debug_PopStack "ATM_Initialize"
103}
104
105#-----------------------------------------------------------------
106function ATM_Update
107{
108    IGCM_debug_PushStack "ATM_Update"
109
110    case ${config_UserChoices_PeriodLength} in
111        *Y|*y) 
112#               LMDZ_ecrit_mth=30.
113               LMDZ_ecrit_mth=1mth
114               LMDZ_ecrit_ISCCP=30.
115               LMDZ_periodav=30.
116               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
117                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
118                  exit
119               fi
120               ;;
121        *)
122               LMDZ_ecrit_mth="${PeriodLengthInDays}""day"
123               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
124               LMDZ_periodav=${PeriodLengthInDays}.
125               ;;
126    esac
127
128    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
129    if [ ${CumulPeriod} -eq 1 ] ; then
130        RAZ_DATE=1
131    else
132        RAZ_DATE=0
133    fi
134
135    ## algo : For CumulPeriod=1 ;
136    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
137    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
138    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
139    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
140
141    if [ ${CumulPeriod} -eq 1 ] ; then
142        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
143            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
144            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
145            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"
146        fi
147    fi
148
149    LMDZ_adjust=n
150    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
151
152    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
153    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
154
155    [ ${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 )
156
157    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
158    LMDZ_sed physiq.def OK_instan   ${OK_instan}
159    LMDZ_sed physiq.def OK_journe   ${OK_journe}
160    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel}
161    LMDZ_sed physiq.def ok_hf       ${ok_hf}
162#    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
163    LMDZ_string_sed config.def _ecrit-mth_   ${LMDZ_ecrit_mth}
164    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
165    LMDZ_sed physiq.def ok_cosp     ${LMDZ_COSP_OK}
166    LMDZ_sed physiq.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
167    LMDZ_sed physiq.def ok_journeCOSP   ${LMDZ_COSP_daily}
168    LMDZ_sed physiq.def ok_hfCOSP   ${LMDZ_COSP_hf}
169    LMDZ_sed physiq.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
170
171    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
172
173    ## run.def parameters
174    LMDZ_sed run.def dayref   ${InitDay}
175    LMDZ_sed run.def anneeref ${InitYear}
176    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
177    LMDZ_sed run.def nday     ${PeriodLengthInDays}
178    LMDZ_sed run.def raz_date ${RAZ_DATE}
179    LMDZ_sed run.def periodav ${LMDZ_periodav}
180    LMDZ_sed run.def adjust   ${LMDZ_adjust}
181
182    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
183    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
184    ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
185    if [ ${ByPass_hgardfou_teta} = y ] ; then
186        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
187        IGCM_sys_Mv gcm.def.tmp gcm.def
188        echo
189        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
190        echo
191        cat gcm.def
192        ByPass_hgardfou_teta=n
193        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
194    fi
195
196    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
197    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
198    ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
199    if [ ${ByPass_hgardfou_mats} = y ] ; then
200        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
201        IGCM_sys_Mv gcm.def.tmp gcm.def
202        echo
203        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
204        echo
205        cat gcm.def
206        ByPass_hgardfou_mats=n
207        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
208    fi
209
210    if ( ${FirstInitialize} ) ; then
211
212        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
213            if [ ${DRYRUN} -le 2 ] ; then
214                ##-- suppression of ozone file construction --
215                cp physiq.def physiq.def.save
216                LMDZ_sed physiq.def read_climoz 0
217                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
218                if [ ${DRYRUN} -le 1 ] ; then
219                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
220                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
221                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
222                fi
223                IGCM_sys_Mv physiq.def.save physiq.def
224            else
225                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
226                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
227            fi
228        fi
229
230    fi
231
232    IGCM_debug_PopStack "ATM_Update"
233}
234
235#-----------------------------------
236function ATM_Finalize
237{
238    IGCM_debug_PushStack "ATM_Finalize"
239
240    [ ${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}
241
242    echo FINALIZE ATM !
243
244    IGCM_debug_PopStack "ATM_Finalize"
245}
Note: See TracBrowser for help on using the repository browser.