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

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

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