source: CONFIG/LMDZINCA/branches/LMDZINCA_v4_0/EXP_GES/COMP/lmdz.driver @ 1299

Last change on this file since 1299 was 1299, checked in by acosce, 13 years ago

ACo : add chmod on BandsResol? for running on titane

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