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

Last change on this file since 765 was 765, checked in by sdipsl, 15 years ago
  • Some evolution for orchidee.driver and orchidee.def
  • Very likely that many more will come
File size: 6.4 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function ATM_Initialize
4{
5    IGCM_debug_PushStack "ATM_Initialize"
6
7    RESOL_ATM=$( echo $RESOL | awk "-F-" '{print $1}')
8
9    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
10
11    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
12
13    ##-- Calendar type for LMDZ
14    case ${config_UserChoices_CalendarType} in
15        leap|gregorian)
16            CalendarTypeForLmdz=earth_366d;;
17        noleap)
18            CalendarTypeForLmdz=earth_365d;;
19        360d)
20            CalendarTypeForLmdz=earth_360d;;
21        *)
22            CalendarTypeForLmdz=earth_360d
23    esac
24
25    ##- Create_etat0_limit version
26    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE
27    CREATE=${lmdz_UserChoices_CREATE}
28    echo create_etat0_limit version : ${CREATE}
29
30    ##- Default number of processor for lmdz
31    NUM_PROC_ATM=1
32    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
33        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
34    fi
35 
36    ##--Frequency purpose ....
37    ##--  Initialisation  ....
38    OK_instan=n
39    OK_journe=n
40    OK_mensuel=n
41    ok_hf=n
42
43    case ${config_UserChoices_PeriodLength} in
44        1Y|1y|1M|1m) OK_mensuel=y ;;
45        5D|5d|1D|1d) OK_journe=y ;;
46    esac
47
48    for frequency in ${config_ATM_WriteFrequency} ; do
49        case ${frequency} in
50            5D|5d|1D|1d) OK_journe=y ;;
51        esac
52        case ${frequency} in
53            HF|hf) ok_hf=y ;;
54        esac
55    done
56
57    ##--Variables used by LMDZ in physiq.def --
58    PAT_INST=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_instan='   )
59    PAT_JOUR=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_journe='   )
60    PAT_MOIS=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'OK_mensuel='  )
61    PAT_HFRE=$(        grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ok_hf='       )
62    PAT_ecrit_mth=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ecrit_mth='   )
63    PAT_ecrit_ISCCP=$( grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def_L${RESOL_ATM_Z}  | grep 'ecrit_ISCCP=' )
64    ##--Variables used by LMDZ in gcm.def --
65    PAT_iphysiq=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iphysiq  )
66    PAT_iperiod=$(   grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep iperiod  )
67    PAT_day_step=$(  grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM_3D} | grep day_step )
68
69    ## Read LMDZ_NbPeriod_adjust option in ${compname}.card
70    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_NbPeriod_adjust
71    eval LMDZ_NbPeriod_adjust=\${${compname}_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
72   
73    ## algo : CumulPeriod=1 ; LMDZ_adjust=y ; save Bands file on file server ;
74    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Fetch Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
75    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Fetch Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust) ; Use Bands ;
76
77    ##-- This could be define in lmdz.card, inside section [UserChoices]
78    ##-- Otherwise we get the value in *.def
79    iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' )
80    iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' )
81    # day_step : number of steps per day (multiple of iperiod)
82    #(( day_step = 48 * iphysiq ))
83    day_step=$( echo ${PAT_day_step} | awk -F= '{print $2}' )
84
85    IGCM_debug_PopStack "ATM_Initialize"
86}
87
88#-----------------------------------------------------------------
89function ATM_Update
90{
91    IGCM_debug_PushStack "ATM_Update"
92
93    case ${config_UserChoices_PeriodLength} in
94        *Y|*y) 
95               LMDZ_ecrit_mth=30.
96               LMDZ_ecrit_ISCCP=30.
97               LMDZ_periodav=30.
98               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
99                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
100                  exit
101               fi
102               ;;
103        *)
104               LMDZ_ecrit_mth=${PeriodLengthInDays}.
105               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
106               LMDZ_periodav=${PeriodLengthInDays}.
107               ;;
108    esac
109
110    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
111    if [ ${CumulPeriod} -eq 1 ] ; then
112        RAZ_DATE=1
113    else
114        RAZ_DATE=0
115    fi
116
117    LMDZ_adjust=n
118    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
119
120    RefPeriod=${LMDZ_NbPeriod_adjust}
121    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 ))
122
123    [ ${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
124
125    ## Mise en forme du fichier physiq.def
126    sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/"                 \
127        -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/"                 \
128        -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/"               \
129        -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/"                         \
130        -e "s/${PAT_ecrit_mth}/ecrit_mth=${LMDZ_ecrit_mth}/"       \
131        -e "s/${PAT_ecrit_ISCCP}/ecrit_ISCCP=${LMDZ_ecrit_ISCCP}/" \
132        physiq.def > physiq.def.tmp
133    IGCM_sys_Mv physiq.def.tmp physiq.def
134
135    ## Mise en forme du fichier gcm.def
136    sed -e "s/${PAT_day_step}/day_step=${day_step}/"    \
137        -e "s/${PAT_iperiod}/iperiod=${iperiod}/"       \
138        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/"       \
139        gcm.def > gcm.def.tmp
140    IGCM_sys_Mv gcm.def.tmp gcm.def
141
142    ## Mise en forme du fichier run.def
143    sed -e "s/_dayref_/${InitDay}/"                    \
144        -e "s/_anneeref_/${InitYear}/"                 \
145        -e "s/_calend_/${CalendarTypeForLmdz}/"        \
146        -e "s/_nday_/${PeriodLengthInDays}/"           \
147        -e "s/_raz_date_/${RAZ_DATE}/"                 \
148        -e "s/_periodav_/${LMDZ_periodav}/"            \
149        -e "s/_adjust_/${LMDZ_adjust}/"                \
150        run.def > run.def.tmp
151    IGCM_sys_Mv run.def.tmp run.def
152
153    IGCM_debug_PopStack "ATM_Update"
154}
155
156#-----------------------------------
157function ATM_Finalize
158{
159    IGCM_debug_PushStack "ATM_Finalize"
160
161    [ ${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}
162
163    echo FINALIZE ATM !
164
165    IGCM_debug_PopStack "ATM_Finalize"
166}
Note: See TracBrowser for help on using the repository browser.