source: CONFIG/IPSLCM/IPSLCM5/branches/IPSLCM5_WORK/EXP00/COMP/lmdz.driver @ 641

Last change on this file since 641 was 641, checked in by sdipsl, 15 years ago
  • manage iphysiq indepedantly from day_step
  • tweak time series variable
  • add area variable in time series files to ease monitoring process
File size: 6.1 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function ATM_Initialize
4{
5    IGCM_debug_PushStack "ATM_Initialize"
6
7    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' )
8
9    case ${RESOL_ATM} in
10        LMD4443)   BandsResol=44x43x19   ;;
11        LMD7245)   BandsResol=72x45x19   ;;
12        LMD5655)   BandsResol=56x55x19   ;;
13        LMD9671)   BandsResol=96x71x19   ;;
14        LMD9695)   BandsResol=96x95x19   ;;
15        LMD9696)   BandsResol=96x96x19   ;;
16        LMD14496)  BandsResol=144x96x19  ;;
17        LMD144142) BandsResol=144x142x19 ;;
18    esac
19
20    ##--Frequency purpose ....
21    ##--  Initialisation  ....
22    OK_instan=n
23    OK_journe=n
24    OK_mensuel=n
25    ok_hf=n
26
27    case ${config_UserChoices_PeriodLength} in
28        1Y|1y|1M|1m) OK_mensuel=y ;;
29        5D|5d|1D|1d) OK_journe=y ;;
30    esac
31
32    for frequency in ${config_ATM_WriteFrequency} ; do
33        case ${frequency} in
34            5D|5d|1D|1d) OK_journe=y ;;
35        esac
36        case ${frequency} in
37            HF|hf) ok_hf=y ;;
38        esac
39    done
40
41    ##--Variables used by LMDZ in physiq.def --
42    PAT_INST=$(     grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def  | grep 'OK_instan='  )
43    PAT_JOUR=$(     grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def  | grep 'OK_journe='  )
44    PAT_MOIS=$(     grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def  | grep 'OK_mensuel=' )
45    PAT_HFRE=$(     grep -v ^# ${SUBMIT_DIR}/PARAM/physiq.def  | grep 'ok_hf='      )
46    ##--Variables used by LMDZ in gcm.def --
47    PAT_iphysiq=$(  grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep iphysiq  )
48    PAT_iperiod=$(  grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep iperiod  )
49    PAT_day_step=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep day_step )
50    PAT_ecritphy=$( grep -v ^# ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | grep ecritphy )
51
52    ## Read LMDZ_adjust option in ${compname}.card --> put adjust=y and save Bands_*.dat in ${SUBMIT_DIR}/PARAM
53    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices LMDZ_adjust
54    eval LMDZ_adjust=\${${compname}_UserChoices_LMDZ_adjust} > /dev/null 2>&1
55
56    ##-- This could be define in lmdz.card, inside section [UserChoices]
57    ##-- Otherwise we get the value in *.def
58    iperiod=$( echo ${PAT_iperiod} | awk -F= '{print $2}' )
59    iphysiq=$( echo ${PAT_iphysiq} | awk -F= '{print $2}' )
60    # day_step : number of steps per day (multiple of iperiod)
61    #(( day_step = 48 * iphysiq ))
62    day_step=$( echo ${PAT_day_step} | awk -F= '{print $2}' )
63
64    #[ -f ${SUBMIT_DIR}/PARAM/Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ] && IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat .
65
66    IGCM_debug_PopStack "ATM_Initialize"
67}
68
69#-----------------------------------------------------------------
70function ATM_Update
71{
72    IGCM_debug_PushStack "ATM_Update"
73
74    ecritphy=${PeriodLengthInDays}
75
76    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
77    if [ ${CumulPeriod} -eq 1 ] ; then
78        RAZ_DATE=1
79    else
80        RAZ_DATE=0
81    fi
82
83    ## Mise en forme du fichier physiq.def
84    sed -e "s/${PAT_INST}/OK_instan=${OK_instan}/"    \
85        -e "s/${PAT_JOUR}/OK_journe=${OK_journe}/"    \
86        -e "s/${PAT_MOIS}/OK_mensuel=${OK_mensuel}/"  \
87        -e "s/${PAT_HFRE}/ok_hf=${ok_hf}/"            \
88        physiq.def > physiq.def.tmp
89    IGCM_sys_Mv physiq.def.tmp physiq.def
90
91    ## Mise en forme du fichier gcm.def
92    sed -e "s/${PAT_ecritphy}/ecritphy=${ecritphy}/"   \
93        -e "s/${PAT_day_step}/day_step=${day_step}/"   \
94        -e "s/${PAT_iperiod}/iperiod=${iperiod}/"      \
95        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/"      \
96        gcm.def > gcm.def.tmp
97    IGCM_sys_Mv gcm.def.tmp gcm.def
98
99    ## Mise en forme du fichier run.def
100    sed -e "s/_dayref_/${InitDay}/"                    \
101        -e "s/_anneeref_/${InitYear}/"                 \
102        -e "s/_nday_/${PeriodLengthInDays}/"           \
103        -e "s/_raz_date_/${RAZ_DATE}/"                 \
104        -e "s/_adjust_/${LMDZ_adjust}/"                \
105        run.def > run.def.tmp
106    IGCM_sys_Mv run.def.tmp run.def
107
108    ## Read ByPass_hgardfou_teta option in ${compname}.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
109    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta
110    eval ByPass_hgardfou_teta=\${${compname}_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1
111    if [ ${ByPass_hgardfou_teta} = y ] ; then
112        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
113        IGCM_sys_Mv gcm.def.tmp gcm.def
114        echo
115        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
116        echo
117        cat gcm.def
118        ByPass_hgardfou_teta=n
119        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
120    fi
121
122    ## Read ByPass_hgardfou_mats option in ${compname}.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
123    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats
124    eval ByPass_hgardfou_mats=\${${compname}_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1
125    if [ ${ByPass_hgardfou_mats} = y ] ; then
126        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
127        IGCM_sys_Mv gcm.def.tmp gcm.def
128        echo
129        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
130        echo
131        cat gcm.def
132        ByPass_hgardfou_mats=n
133        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/${compname}.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
134    fi
135
136    if ( ${FirstInitialize} ) ; then
137
138        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
139            if [ ${DRYRUN} -le 2 ] ; then
140                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
141                if [ ${DRYRUN} -le 1 ] ; then
142                    ./create_etat0_limit.e
143                fi
144            else
145                echo "EXECUTION of ./create_etat0_limit.e simulated"
146                echo "EXECUTION of ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
147            fi
148        fi
149
150    fi
151
152    IGCM_debug_PopStack "ATM_Update"
153}
154
155#-----------------------------------
156function ATM_Finalize
157{
158    IGCM_debug_PushStack "ATM_Finalize"
159
160    [ ${LMDZ_adjust} = y ] && IGCM_sys_Cp Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${SUBMIT_DIR}/PARAM
161
162    echo FINALIZE ATM !
163
164    IGCM_debug_PopStack "ATM_Finalize"
165}
Note: See TracBrowser for help on using the repository browser.