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

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

MAF : debug of number of vertical levels parametrisation.

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