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

Last change on this file since 746 was 746, checked in by mafoipsl, 15 years ago

Delete all Bands files in PARAM directories. Add in lmdz.driver everything concerning Bands. Add in lmdz.card LMDZ_NbPeriod_adjust parameter.

File size: 5.2 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    ecrit_mth=${PeriodLengthInDays}.
83
84    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
85    if [ ${CumulPeriod} -eq 1 ] ; then
86        RAZ_DATE=1
87    else
88        RAZ_DATE=0
89    fi
90
91    LMDZ_adjust=n
92    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
93
94    RefPeriod=${LMDZ_NbPeriod_adjust}
95    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 ))
96
97    [ ${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
98
99    ## Mise en forme du fichier physiq.def
100    sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/"      \
101        -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/"      \
102        -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/"    \
103        -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/"              \
104        -e "s/${PAT_ecrit_mth}/ecrit_mth=${ecrit_mth}/" \
105        physiq.def > physiq.def.tmp
106    IGCM_sys_Mv physiq.def.tmp physiq.def
107
108    ## Mise en forme du fichier gcm.def
109    sed -e "s/${PAT_day_step}/day_step=${day_step}/"    \
110        -e "s/${PAT_iperiod}/iperiod=${iperiod}/"       \
111        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/"       \
112        gcm.def > gcm.def.tmp
113    IGCM_sys_Mv gcm.def.tmp gcm.def
114
115    ## Mise en forme du fichier run.def
116    sed -e "s/_dayref_/${InitDay}/"                    \
117        -e "s/_anneeref_/${InitYear}/"                 \
118        -e "s/_nday_/${PeriodLengthInDays}/"           \
119        -e "s/_raz_date_/${RAZ_DATE}/"                 \
120        -e "s/_adjust_/${LMDZ_adjust}/"                \
121        run.def > run.def.tmp
122    IGCM_sys_Mv run.def.tmp run.def
123
124    IGCM_debug_PopStack "ATM_Update"
125}
126
127#-----------------------------------
128function ATM_Finalize
129{
130    IGCM_debug_PushStack "ATM_Finalize"
131
132    [ ${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}
133
134    echo FINALIZE ATM !
135
136    IGCM_debug_PopStack "ATM_Finalize"
137}
Note: See TracBrowser for help on using the repository browser.