source: CONFIG/LMDZOR/branches/LMDZ4OR_v3/LMDZOR/COMP/lmdz.driver @ 885

Last change on this file since 885 was 882, checked in by aclsce, 14 years ago

Modified LMDZ4OR_v3 configuration to fit with IPSLCM5_v2 coupled
configuration.
Now, LMDZ4OR_work is the working configuration using trunk of LMDZ and
LMDZ4OR_v2 fits with IPSLCM4_v2 coupled configuration.
Modifications :

  • compilation of LMD9695-L39 resolution by default
  • modified *.card, *.driver and *.def to fit with IPSLCM5_v2
  • added SBG component (like IPSLCM5_v2)
  • added POST directory
File size: 8.8 KB
Line 
1# $Id$
2#
3#!/bin/ksh
4#-----------------------------------------------------------------
5function ATM_Initialize
6{
7    IGCM_debug_PushStack "ATM_Initialize"
8
9    RESOL_ATM=$( echo $RESOL | awk "-F-" '{print $1}')
10
11    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
12
13    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
14
15    ##-- Calendar type for LMDZ
16    case ${config_UserChoices_CalendarType} in
17        leap|gregorian)
18            CalendarTypeForLmdz=earth_366d;;
19        noleap)
20            CalendarTypeForLmdz=earth_365d;;
21        360d)
22            CalendarTypeForLmdz=earth_360d;;
23        *)
24            CalendarTypeForLmdz=earth_360d
25    esac
26
27    ##- Create_etat0_limit version
28    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE
29    CREATE=${lmdz_UserChoices_CREATE}
30    echo create_etat0_limit version : ${CREATE}
31
32    ##- Default number of processor for lmdz
33    NUM_PROC_ATM=1
34    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
35        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
36    fi
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    ##--Variables used by LMDZ in physiq.def --
60    PAT_INST=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_instan='   )
61    PAT_JOUR=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_journe='   )
62    PAT_MOIS=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_mensuel='  )
63    PAT_HFRE=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ok_hf='       )
64    PAT_ecrit_mth=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ecrit_mth='   )
65    PAT_ecrit_ISCCP=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ecrit_ISCCP=' )
66
67    ##--Variables used by LMDZ in gcm.def --
68    PAT_iphysiq=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iphysiq  )
69    PAT_iperiod=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iperiod  )
70    PAT_day_step=$(  grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep day_step )
71
72    ## Read LMDZ_NbPeriod_adjust option in ${compname}.card
73    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_NbPeriod_adjust
74    eval LMDZ_NbPeriod_adjust=\${${compname}_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
75
76    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
77        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_Bands_file_name
78        eval LMDZ_Bands_file_name=\${${compname}_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
79    fi
80
81    ##-- This could be define in lmdz.card, inside section [UserChoices]
82    ##-- Otherwise we get the value in *.def
83    iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' )
84    iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' )
85    # day_step : number of steps per day (multiple of iperiod)
86    #(( day_step = 48 * iphysiq ))
87    day_step=$( echo ${PAT_day_step} | awk -F= '{print $2}' )
88
89    IGCM_debug_PopStack "ATM_Initialize"
90}
91
92#-----------------------------------------------------------------
93function ATM_Update
94{
95    IGCM_debug_PushStack "ATM_Update"
96
97    case ${config_UserChoices_PeriodLength} in
98        *Y|*y) 
99               LMDZ_ecrit_mth=30.
100               LMDZ_ecrit_ISCCP=30.
101               LMDZ_periodav=30.
102               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
103                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
104                  exit
105               fi
106               ;;
107        *)
108               LMDZ_ecrit_mth=${PeriodLengthInDays}.
109               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
110               LMDZ_periodav=${PeriodLengthInDays}.
111               ;;
112    esac
113
114    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
115    if [ ${CumulPeriod} -eq 1 ] ; then
116        RAZ_DATE=1
117    else
118        RAZ_DATE=0
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
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
142
143    ## Mise en forme du fichier physiq.def
144    sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/"                 \
145        -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/"                 \
146        -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/"               \
147        -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/"                         \
148        -e "s/${PAT_ecrit_mth}/ecrit_mth=${LMDZ_ecrit_mth}/"       \
149        -e "s/${PAT_ecrit_ISCCP}/ecrit_ISCCP=${LMDZ_ecrit_ISCCP}/" \
150        physiq.def > physiq.def.tmp
151    IGCM_sys_Mv physiq.def.tmp physiq.def
152
153    ## Mise en forme du fichier gcm.def
154    sed -e "s/${PAT_day_step}/day_step=${day_step}/"    \
155        -e "s/${PAT_iperiod}/iperiod=${iperiod}/"       \
156        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/"       \
157        gcm.def > gcm.def.tmp
158    IGCM_sys_Mv gcm.def.tmp gcm.def
159
160    ## Mise en forme du fichier run.def
161    sed -e "s/_dayref_/${InitDay}/"                    \
162        -e "s/_anneeref_/${InitYear}/"                 \
163        -e "s/_calend_/${CalendarTypeForLmdz}/"        \
164        -e "s/_nday_/${PeriodLengthInDays}/"           \
165        -e "s/_raz_date_/${RAZ_DATE}/"                 \
166        -e "s/_periodav_/${LMDZ_periodav}/"            \
167        -e "s/_adjust_/${LMDZ_adjust}/"                \
168        run.def > run.def.tmp
169    IGCM_sys_Mv run.def.tmp run.def
170
171    ## Read ByPass_hgardfou_teta option in ${compname}.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
172    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta
173    eval ByPass_hgardfou_teta=\${${compname}_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1
174    if [ ${ByPass_hgardfou_teta} = y ] ; then
175        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
176        IGCM_sys_Mv gcm.def.tmp gcm.def
177        echo
178        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
179        echo
180        cat gcm.def
181        ByPass_hgardfou_teta=n
182        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
183    fi
184
185    ## Read ByPass_hgardfou_mats option in ${compname}.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
186    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats
187    eval ByPass_hgardfou_mats=\${${compname}_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1
188    if [ ${ByPass_hgardfou_mats} = y ] ; then
189        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
190        IGCM_sys_Mv gcm.def.tmp gcm.def
191        echo
192        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
193        echo
194        cat gcm.def
195        ByPass_hgardfou_mats=n
196        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
197    fi
198
199    IGCM_debug_PopStack "ATM_Update"
200}
201
202#-----------------------------------
203function ATM_Finalize
204{
205    IGCM_debug_PushStack "ATM_Finalize"
206
207    [ ${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}
208
209    echo FINALIZE ATM !
210
211    IGCM_debug_PopStack "ATM_Finalize"
212}
Note: See TracBrowser for help on using the repository browser.