source: CONFIG/IPSLCM/IPSLCM5A/piControl/COMP/lmdz.driver @ 1001

Last change on this file since 1001 was 1001, checked in by mafoipsl, 14 years ago

Add COSP files processing in historical and piControl.

File size: 9.2 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 ATM_Initialize
17{
18    IGCM_debug_PushStack "ATM_Initialize"
19
20    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}')
21
22    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
23
24    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
25
26    ##-- Calendar type for LMDZ
27    case ${config_UserChoices_CalendarType} in
28        leap|gregorian)
29            CalendarTypeForLmdz=earth_366d;;
30        noleap)
31            CalendarTypeForLmdz=earth_365d;;
32        360d)
33            CalendarTypeForLmdz=earth_360d;;
34        *)
35            CalendarTypeForLmdz=earth_360d
36    esac
37
38    ##--Frequency purpose ....
39    ##--  Initialisation  ....
40    OK_instan=n
41    OK_journe=n
42    OK_mensuel=n
43    ok_hf=n
44
45    case ${config_UserChoices_PeriodLength} in
46        1Y|1y|1M|1m) OK_mensuel=y ;;
47        5D|5d|1D|1d) OK_journe=y ;;
48    esac
49
50    for frequency in ${config_ATM_WriteFrequency} ; do
51        case ${frequency} in
52            5D|5d|1D|1d) OK_journe=y ;;
53        esac
54        case ${frequency} in
55            HF|hf) ok_hf=y ;;
56        esac
57    done
58
59    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
60    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
61    eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
62
63    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
64        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
65        eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
66    fi
67
68    ##  Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card
69    eval LMDZ_Freq_aero=\${lmdz_UserChoices_LMDZ_Freq_aero} > /dev/null 2>&1
70    eval LMDZ_Length_aero=\${lmdz_UserChoices_LMDZ_Length_aero} > /dev/null 2>&1
71
72    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
73    eval LMDZ_COSP_OK=\${lmdz_UserChoices_LMDZ_COSP_OK} > /dev/null 2>&1
74    eval LMDZ_COSP_monthly=\${lmdz_UserChoices_LMDZ_COSP_monthly} > /dev/null 2>&1
75    eval LMDZ_COSP_daily=\${lmdz_UserChoices_LMDZ_COSP_daily} > /dev/null 2>&1
76    eval LMDZ_COSP_hf=\${lmdz_UserChoices_LMDZ_COSP_hf} > /dev/null 2>&1
77
78    IGCM_debug_PopStack "ATM_Initialize"
79}
80
81#-----------------------------------------------------------------
82function ATM_Update
83{
84    IGCM_debug_PushStack "ATM_Update"
85
86    case ${config_UserChoices_PeriodLength} in
87        *Y|*y) 
88               LMDZ_ecrit_mth=30.
89               LMDZ_ecrit_ISCCP=30.
90               LMDZ_periodav=30.
91               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
92                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
93                  exit
94               fi
95               ;;
96        *)
97               LMDZ_ecrit_mth=${PeriodLengthInDays}.
98               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
99               LMDZ_periodav=${PeriodLengthInDays}.
100               ;;
101    esac
102
103    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
104    if [ ${CumulPeriod} -eq 1 ] ; then
105        RAZ_DATE=1
106    else
107        RAZ_DATE=0
108    fi
109
110    ## To have more variables in output files for aerosols. Parameters are set in lmdz.card
111    if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then
112       if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then
113          lev_histmth=4
114       else
115          lev_histmth=2   
116       fi
117    else
118       lev_histmth=2
119    fi   
120
121    ## algo : For CumulPeriod=1 ;
122    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
123    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
124    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
125    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
126
127    if [ ${CumulPeriod} -eq 1 ] ; then
128        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
129            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
130            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
131            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"
132        fi
133    fi
134
135    LMDZ_adjust=n
136    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
137
138    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
139    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
140
141    [ ${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 )
142
143    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
144    LMDZ_sed physiq.def OK_instan   ${OK_instan}
145    LMDZ_sed physiq.def OK_journe   ${OK_journe}
146    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel}
147    LMDZ_sed physiq.def lev_histmth ${lev_histmth}
148    LMDZ_sed physiq.def ok_hf       ${ok_hf}
149    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
150    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
151    LMDZ_sed physiq.def ok_cosp     ${LMDZ_COSP_OK}
152    LMDZ_sed physiq.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
153    LMDZ_sed physiq.def ok_journeCOSP   ${LMDZ_COSP_daily}
154    LMDZ_sed physiq.def ok_hfCOSP   ${LMDZ_COSP_hf}
155
156    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
157
158    ## run.def parameters
159    LMDZ_sed run.def dayref   ${InitDay}
160    LMDZ_sed run.def anneeref ${InitYear}
161    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
162    LMDZ_sed run.def nday     ${PeriodLengthInDays}
163    LMDZ_sed run.def raz_date ${RAZ_DATE}
164    LMDZ_sed run.def periodav ${LMDZ_periodav}
165    LMDZ_sed run.def adjust   ${LMDZ_adjust}
166
167    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
168    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
169    eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1
170    if [ ${ByPass_hgardfou_teta} = y ] ; then
171        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
172        IGCM_sys_Mv gcm.def.tmp gcm.def
173        echo
174        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
175        echo
176        cat gcm.def
177        ByPass_hgardfou_teta=n
178        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
179    fi
180
181    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
182    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
183    eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1
184    if [ ${ByPass_hgardfou_mats} = y ] ; then
185        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
186        IGCM_sys_Mv gcm.def.tmp gcm.def
187        echo
188        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
189        echo
190        cat gcm.def
191        ByPass_hgardfou_mats=n
192        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
193    fi
194
195    if ( ${FirstInitialize} ) ; then
196
197        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
198            if [ ${DRYRUN} -le 2 ] ; then
199                ##-- suppression of ozone file construction --
200                cp physiq.def physiq.def.save
201                LMDZ_sed physiq.def read_climoz 0
202                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
203                if [ ${DRYRUN} -le 1 ] ; then
204                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
205                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
206                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
207                fi
208                IGCM_sys_Mv physiq.def.save physiq.def
209            else
210                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
211                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
212            fi
213        fi
214
215    fi
216
217    IGCM_debug_PopStack "ATM_Update"
218}
219
220#-----------------------------------
221function ATM_Finalize
222{
223    IGCM_debug_PushStack "ATM_Finalize"
224
225    [ ${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}
226
227    echo FINALIZE ATM !
228
229    IGCM_debug_PopStack "ATM_Finalize"
230}
Note: See TracBrowser for help on using the repository browser.