source: CONFIG/LMDZOR/branches/LMDZOR_v4/LMDZOR/COMP/lmdz.driver @ 1370

Last change on this file since 1370 was 1370, checked in by jgipsl, 13 years ago
  • Removed output lmdz.prt.x which does not exist in forced configuration
  • Removed option LMDZ_Freq_aero and LMDZ_Length_aero never used
  • Desactivated COSP and NMC output for default run. This is easy for users to activate in lmdz.card.
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 ATM_Initialize
19{
20    IGCM_debug_PushStack "ATM_Initialize"
21
22    RESOL_ATM=$( echo $RESOL | awk "-F-L" '{print $1}')
23
24    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
25
26    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' | awk "-F-" '{print $1}')
27
28    ##-- Calendar type for LMDZ
29    case ${config_UserChoices_CalendarType} in
30        leap|gregorian)
31            CalendarTypeForLmdz=earth_366d;;
32        noleap)
33            CalendarTypeForLmdz=earth_365d;;
34        360d)
35            CalendarTypeForLmdz=earth_360d;;
36        *)
37            CalendarTypeForLmdz=earth_360d
38    esac
39
40    ##- Create_etat0_limit version
41    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE
42    CREATE=${lmdz_UserChoices_CREATE}
43    echo create_etat0_limit version : ${CREATE}
44
45    ##- Default number of processor for lmdz
46    NUM_PROC_ATM=4
47    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
48        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
49    fi
50 
51    ##--Frequency purpose ....
52    ##--  Initialisation  ....
53    OK_instan=n
54    OK_journe=n
55    OK_mensuel=n
56    ok_hf=n
57    OK_les=y
58
59    case ${config_UserChoices_PeriodLength} in
60        1Y|1y|1M|1m) OK_mensuel=y ;;
61        5D|5d|1D|1d) OK_journe=y ;;
62    esac
63
64    for frequency in ${config_ATM_WriteFrequency} ; do
65        case ${frequency} in
66            5D|5d|1D|1d) OK_journe=y ;;
67        esac
68        case ${frequency} in
69            HF|hf) 
70                ok_hf=y
71                OK_instan=y
72                ;;
73        esac
74    done
75
76    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
77    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
78    eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
79
80    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
81        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
82        eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
83    fi
84
85    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
86    eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1
87    eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1
88    eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1
89    eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1
90
91    ##  Read LMDZ_NMC_monthly  LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card
92    eval LMDZ_NMC_monthly=\${lmdz_UserChoices_LMDZ_NMC_monthly} > /dev/null 2>&1
93    eval LMDZ_NMC_daily=\${lmdz_UserChoices_LMDZ_NMC_daily} > /dev/null 2>&1
94    eval LMDZ_NMC_hf=\${lmdz_UserChoices_LMDZ_NMC_hf} > /dev/null 2>&1
95
96    IGCM_debug_PopStack "ATM_Initialize"
97}
98
99#-----------------------------------------------------------------
100function ATM_Update
101{
102    IGCM_debug_PushStack "ATM_Update"
103
104    case ${config_UserChoices_PeriodLength} in
105        *Y|*y) 
106               LMDZ_ecrit_mth=30.
107               LMDZ_ecrit_ISCCP=30.
108               LMDZ_periodav=30.
109               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
110                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
111                  exit
112               fi
113               ;;
114        *)
115               LMDZ_ecrit_mth=${PeriodLengthInDays}.
116               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
117               LMDZ_periodav=${PeriodLengthInDays}.
118               ;;
119    esac
120
121    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
122    if [ ${CumulPeriod} -eq 1 ] ; then
123        RAZ_DATE=1
124    else
125        RAZ_DATE=0
126    fi
127
128
129    ## algo : For CumulPeriod=1 ;
130    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
131    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
132    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
133    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
134
135    if [ ${CumulPeriod} -eq 1 ] ; then
136        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
137            if [ ! X${LMDZ_Bands_file_name} = X] ; then
138                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
139                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
140                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"
141            fi
142        fi
143    fi
144
145    LMDZ_adjust=n
146    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
147
148    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
149    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
150
151    [ ${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 )
152
153    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
154    LMDZ_sed physiq.def phys_out_filekeys "${OK_mensuel} ${OK_journe} ${ok_hf} ${OK_instan} ${OK_les}"
155    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
156    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
157    LMDZ_sed physiq.def ok_cosp     ${LMDZ_COSP_OK}
158    LMDZ_sed physiq.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
159    LMDZ_sed physiq.def ok_journeCOSP   ${LMDZ_COSP_daily}
160    LMDZ_sed physiq.def ok_hfCOSP   ${LMDZ_COSP_hf}
161    LMDZ_sed physiq.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
162
163    ##-- GHG forcing for the current year if forcing file is availible
164    if [ -f SOLARANDVOLCANOES.txt ] ; then
165        IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
166        LMDZ_sed physiq.def solaire     ${IPCC_SOLAR}
167    fi
168    if [ -f CO2.txt ] ; then
169        IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
170        LMDZ_sed physiq.def co2_ppm     ${IPCC_CO2}
171    fi
172    if [ -f CH4.txt ] ; then
173        IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'`
174        LMDZ_sed physiq.def CH4_ppb     ${IPCC_CH4}
175    fi
176    if [ -f N2O.txt ] ; then
177        IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'`
178        LMDZ_sed physiq.def N2O_ppb     ${IPCC_N2O}
179    fi
180    if [ -f CFC11.txt ] ; then
181        IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'`
182        LMDZ_sed physiq.def CFC11_ppt   ${IPCC_CFC11}
183    fi
184    if [ -f CFC12.txt ] ; then
185        IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'`
186        LMDZ_sed physiq.def CFC12_ppt   ${IPCC_CFC12}
187    fi
188
189    ## Other specific parameters to this experience
190    if [ ! X${lmdz_UserChoices_aer_type} = X ] ; then
191        LMDZ_sed physiq.def aer_type ${lmdz_UserChoices_aer_type}
192    fi
193    if [ ! X${lmdz_UserChoices_pmagic} = X ] ; then
194        LMDZ_sed physiq.def pmagic   ${lmdz_UserChoices_pmagic}
195    fi
196
197    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
198        LMDZ_sed guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
199    fi
200
201    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
202
203    ## run.def parameters
204    LMDZ_sed run.def dayref   ${InitDay}
205    LMDZ_sed run.def anneeref ${InitYear}
206    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
207    LMDZ_sed run.def nday     ${PeriodLengthInDays}
208    LMDZ_sed run.def raz_date ${RAZ_DATE}
209    LMDZ_sed run.def periodav ${LMDZ_periodav}
210    LMDZ_sed run.def adjust   ${LMDZ_adjust}
211
212# No filtre fft in case of zoom, 280x280x39-ZAf contains zoom
213    if [ ${RESOL_ATM_3D} = "280x280x39-ZAf" ] || [ ${RESOL_ATM_3D} = "360x180x19-ZIn" ] ; then
214         LMDZ_sed run.def use_filtre_fft n
215    fi
216
217    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
218    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
219    eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1
220    if [ ${ByPass_hgardfou_teta} = y ] ; then
221        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
222        IGCM_sys_Mv gcm.def.tmp gcm.def
223        echo
224        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
225        echo
226        cat gcm.def
227        ByPass_hgardfou_teta=n
228        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
229    fi
230
231    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
232    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
233    eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1
234    if [ ${ByPass_hgardfou_mats} = y ] ; then
235        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
236        IGCM_sys_Mv gcm.def.tmp gcm.def
237        echo
238        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
239        echo
240        cat gcm.def
241        ByPass_hgardfou_mats=n
242        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
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.