source: CONFIG/LMDZORINCA/branches/LMDZORINCA3_39/EXP_GES/COMP/lmdz.driver @ 1555

Last change on this file since 1555 was 1555, checked in by acosce, 11 years ago

Correction for BandsResol? in driver for LMDZORINCA

  • Property svn:executable set to *
File size: 5.6 KB
Line 
1#- $Id: lmdz.driver 841 2009-12-08 09:48:13Z acosce $
2#!/bin/ksh
3
4#-----------------------------------------------------------------
5function ATM_Initialize
6{
7    IGCM_debug_PushStack "ATM_Initialize"
8
9    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' )
10    case ${RESOL_ATM} in
11        LMD9695-L39)   BandsResol=96x95x39   ;;
12    esac
13
14
15    ##-- Calendar type for LMDZ
16    case ${config_UserChoices_CalendarType} in
17        leap|gregorian)
18            CalendarTypeForLmdz=earth_366d;;
19        noleap)
20            CalendarTypeForLmdz=earth_365d;;
21        360d)
22            CalendarTypeForLmdz=earth_360d;;
23        *)
24            CalendarTypeForLmdz=earth_360d
25    esac
26
27    ##- Default number of processor for lmdz
28    NUM_PROC_ATM=1
29    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
30        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
31    fi
32
33    ##--Frequency purpose ....
34    ##--  Initialisation  ....
35    OK_instan=n
36    ##--
37    OK_journe=n
38    OK_mensuel=y
39
40    case ${config_UserChoices_PeriodLength} in
41        1Y|1y|1M|1m) OK_mensuel=y ;;
42        5D|5d|1D|1d) OK_journe=n ;;
43    esac
44
45    for frequency in ${config_ATM_WriteFrequency} ; do
46        case ${frequency} in
47            5D|5d|1D|1d) OK_journe=n ;;
48        esac
49    done
50
51    ##--Variables used by LMDZ --
52    PAT_INST=$(     grep 'OK_instan'   ${SUBMIT_DIR}/PARAM/physiq.def )
53    PAT_JOUR=$(     grep 'OK_journe'   ${SUBMIT_DIR}/PARAM/physiq.def )
54    PAT_MOIS=$(     grep 'OK_mensuel'  ${SUBMIT_DIR}/PARAM/physiq.def )
55
56    PAT_iphysiq=$(  grep 'iphysiq'     ${SUBMIT_DIR}/PARAM/gcm.def )
57    PAT_iperiod=$(  grep 'iperiod'     ${SUBMIT_DIR}/PARAM/gcm.def | tail -1)
58    PAT_day_step=$( grep 'day_step'    ${SUBMIT_DIR}/PARAM/gcm.def )
59    PAT_ecritphy=$( grep 'ecritphy'    ${SUBMIT_DIR}/PARAM/gcm.def )
60
61
62    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
63    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
64    eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
65
66    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
67        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
68        eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
69    fi
70
71
72    ##-- This could be define in lmdz.card, inside section [UserChoices]
73    ##-- Otherwise we get the value in *.def
74    iperiod=$(grep iperiod ${SUBMIT_DIR}/PARAM/gcm.def | awk -F= '{print $2}' | tail -1)
75    iphysiq=$(grep iphysiq ${SUBMIT_DIR}/PARAM/gcm.def | awk -F= '{print $2}')
76    # day_step : number of steps per day (multiple of iperiod)
77    (( day_step = 48 * iphysiq ))
78
79    IGCM_debug_PopStack "ATM_Initialize"
80}
81
82#-----------------------------------------------------------------
83function ATM_Update
84{
85    IGCM_debug_PushStack "ATM_Update"
86
87    ecritphy=${PeriodLengthInDays}
88
89    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
90    if [ ${CumulPeriod} -eq 1 ] ; then
91        RAZ_DATE=1
92    else
93        RAZ_DATE=0
94    fi
95
96    if [ ${CumulPeriod} -eq 1 ] ; then
97        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
98            IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat
99            IGCM_sys_Put_Out Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_0
100            IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_0"
101            IGCM_sys_Chmod u+w Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat
102        fi
103    fi
104
105    LMDZ_adjust=n
106    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
107
108    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
109    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
110
111    [ ${CumulPeriod} -gt 1 ] && ( IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat; IGCM_sys_Chmod u+w Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat )
112
113    ## Mise en forme du fichier physiq.def
114    sed -e "s/OK_instan=.*/OK_instan=${OK_instan}/"     \
115        -e "s/OK_journe=.*/OK_journe=${OK_journe}/"     \
116        -e "s/OK_mensuel=.*/OK_mensuel=${OK_mensuel}/"  \
117        physiq.def > physiq.def.tmp
118    IGCM_sys_Mv physiq.def.tmp physiq.def
119
120    ## Mise en forme du fichier gcm.def
121    sed  -e "s/${PAT_ecritphy}/ecritphy=${ecritphy}/"   \
122        -e "s/${PAT_day_step}/day_step=${day_step}/"    \
123        -e "s/${PAT_iperiod}/iperiod=${iperiod}/"       \
124        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/"       \
125        gcm.def > gcm.def.tmp
126    IGCM_sys_Mv gcm.def.tmp gcm.def
127
128    greg_dat=$( IGCM_date_ConvertFormatToGregorian $PeriodDateBegin ) 
129    jul_dat=$( IGCM_date_ConvertGregorianDateToJulian $greg_dat )
130    nbjour=$( expr \( $jul_dat \% 1000 \) ) 
131    yractu=$( expr $greg_dat / 10000  )
132    echo  "dayref = " $nbjour  "year actu = " $yractu
133
134    ## Mise en forme du fichier run.def
135    sed -e "s/_dayref_/${nbjour}/"                      \
136        -e "s/_anneeref_/${yractu}/"                    \
137        -e "s/_calend_/${CalendarTypeForLmdz}/"         \
138        -e "s/_nday_/${PeriodLengthInDays}/"            \
139        -e "s/_raz_date_/${RAZ_DATE}/"                  \
140        -e "s/_adjust_/${LMDZ_adjust}/"                 \
141        run.def > run.def.tmp
142    IGCM_sys_Mv run.def.tmp run.def
143
144    IGCM_debug_PopStack "ATM_Update"
145}
146
147#-----------------------------------
148function ATM_Finalize
149{
150    IGCM_debug_PushStack "ATM_Finalize"
151
152    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${BandsResol}_${NUM_PROC_ATM}prc.dat_${CumulPeriod}
153    echo FINALIZE ATM !
154
155    IGCM_debug_PopStack "ATM_Finalize"
156}
Note: See TracBrowser for help on using the repository browser.