source: CONFIG/trunk/LMDZ4OR_v2/LMDZOR/COMP/lmdz.driver @ 197

Last change on this file since 197 was 197, checked in by mmaipsl, 15 years ago

First import of LMDZ4OR_v2 model.

File size: 4.2 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function ATM_Initialize
4{
5    IGCM_debug_PushStack "ATM_Initialize"
6
7#D- create_etat0_limit version : CLIM_EL or AMIP_EL
8    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE
9    CREATE=${lmdz_UserChoices_CREATE}
10    echo create_etat0_limit version : ${CREATE}
11
12#D- Default number of processor for lmdz
13    NUM_PROC_ATM=1
14#D- Number of processors used for lmdz and oasis coupler computed from PBS variable
15    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
16        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
17    fi
18    echo BATCH_NUM_PROC_TOT=${BATCH_NUM_PROC_TOT}
19    echo NUM_PROC_ATM=${NUM_PROC_ATM}
20
21    RESOL_ATM=${RESOL}
22
23    case ${RESOL_ATM} in
24        LMD7245)   BandsResol=72x45x19   ;;
25        LMD9671)   BandsResol=96x71x19   ;;
26        LMD14496)  BandsResol=144x96x19  ;;
27        LMD144142) BandsResol=144x142x19 ;;
28    esac
29
30    ##--Frequency purpose ....
31    ##--  Initialisation  ....
32    OK_instan=n
33    ##--
34    OK_journe=n
35    OK_mensuel=n
36
37    case ${config_UserChoices_PeriodLength} in
38        1Y|1y|1M|1m) OK_mensuel=y ;;
39        5D|5d|1D|1d) OK_journe=y ;;
40    esac
41
42    for frequency in ${config_ATM_WriteFrequency} ; do
43        case ${frequency} in
44            5D|5d|1D|1d) OK_journe=y ;;
45        esac
46    done
47
48    ##--Variables used by LMDZ --
49    PAT_INST=$(     grep 'OK_instan'   ${SUBMIT_DIR}/PARAM/physiq.def )
50    PAT_JOUR=$(     grep 'OK_journe'   ${SUBMIT_DIR}/PARAM/physiq.def )
51    PAT_MOIS=$(     grep 'OK_mensuel'  ${SUBMIT_DIR}/PARAM/physiq.def )
52
53    PAT_iphysiq=$(  grep 'iphysiq'     ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} )
54    PAT_iperiod=$(  grep 'iperiod'     ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | tail -1)
55    PAT_day_step=$( grep 'day_step'    ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} )
56    PAT_ecritphy=$( grep 'ecritphy'    ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} )
57
58    ##-- This could be define in lmdz.card, inside section [UserChoices]
59    ##-- Otherwise we get the value in *.def
60    iperiod=$(grep iperiod ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | awk -F= '{print $2}' | tail -1)
61    iphysiq=$(grep iphysiq ${SUBMIT_DIR}/PARAM/gcm.def_${RESOL_ATM} | awk -F= '{print $2}')
62    # day_step : number of steps per day (multiple of iperiod)
63    (( day_step = 48 * iphysiq ))
64
65    IGCM_debug_PopStack "ATM_Initialize"
66}
67
68#-----------------------------------------------------------------
69function ATM_Update
70{
71    IGCM_debug_PushStack "ATM_Update"
72
73# Another solution to make start.nc/startphy.nc/limit.nc for a CLIM run :
74# if ( ${FirstInitialize} ) ; then
75
76#    if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
77#       if [ ${DRYRUN} -le 2 ] ; then
78#            IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
79#          if [ ${DRYRUN} -le 1 ] ; then
80#            ./create_etat0_limit.e
81#          fi
82#       else
83#          echo "EXECUTION of ./create_etat0_limit.e simulated"
84#          echo "EXECUTION of ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
85#       fi
86#    fi
87
88# fi
89
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    ## Mise en forme du fichier physiq.def
101    sed -e "s/OK_instan=.*/OK_instan=${OK_instan}/"   \
102        -e "s/OK_journe=.*/OK_journe=${OK_journe}/"   \
103        -e "s/OK_mensuel=.*/OK_mensuel=${OK_mensuel}/" \
104        physiq.def > physiq.def.tmp
105    IGCM_sys_Mv physiq.def.tmp physiq.def
106
107    ## Mise en forme du fichier gcm.def
108    sed  -e "s/${PAT_ecritphy}/ecritphy=${ecritphy}/" \
109        -e "s/${PAT_day_step}/day_step=${day_step}/" \
110        -e "s/${PAT_iperiod}/iperiod=${iperiod}/" \
111        -e "s/${PAT_iphysiq}/iphysiq=${iphysiq}/" \
112        gcm.def > gcm.def.tmp
113    IGCM_sys_Mv gcm.def.tmp gcm.def
114
115    ## Mise en forme du fichier run.def
116    sed -e "s/_dayref_/${InitDay}/" \
117        -e "s/_anneeref_/${InitYear}/" \
118        -e "s/_nday_/${PeriodLengthInDays}/" \
119        -e "s/_raz_date_/${RAZ_DATE}/" \
120        run.def > run.def.tmp
121    IGCM_sys_Mv run.def.tmp run.def
122
123    IGCM_debug_PopStack "ATM_Update"
124}
125
126#-----------------------------------
127function ATM_Finalize
128{
129    IGCM_debug_PushStack "ATM_Finalize"
130
131    IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
132
133    echo FINALIZE ATM !
134
135    IGCM_debug_PopStack "ATM_Finalize"
136}
Note: See TracBrowser for help on using the repository browser.