source: CONFIG/LMDZORINCA/trunk/EXP_NMHC_AER/COMP/lmdz.driver @ 861

Last change on this file since 861 was 861, checked in by acosce, 15 years ago

ACo : add change for files Bands

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