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

Last change on this file since 756 was 756, checked in by aclsce, 15 years ago

Corrected a bad "if" condition.

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