source: CONFIG/LMDZ/branches/LMDZ4/LMDZ/COMP/lmdz.driver @ 745

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

Delete all Bands files in PARAM-AR4 directory. Add in lmdz.driver everything concerning Bands. Add in lmdz.card(_Interannuel) LMDZ_NbPeriod_adjust parameter.

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