source: CONFIG/IPSLCM/IPSLCM5/branches/IPSLCM5_v2/EXP00/COMP/lmdz.driver @ 911

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

Use LMDZ_sed for sed commands to echo the sed.

File size: 8.0 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function LMDZ_sed
4{
5    IGCM_debug_PushStack "LMDZ_sed"
6
7    sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp
8    RET=$?
9    echo "LMDZ_sed : ${1} ${2} ${3}"
10    \mv ${1}.tmp ${1}
11
12    IGCM_debug_PopStack "LMDZ_sed"
13    return $RET
14}
15
16function ATM_Initialize
17{
18    IGCM_debug_PushStack "ATM_Initialize"
19
20    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}')
21
22    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
23
24    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
25
26    ##-- Calendar type for LMDZ
27    case ${config_UserChoices_CalendarType} in
28        leap|gregorian)
29            CalendarTypeForLmdz=earth_366d;;
30        noleap)
31            CalendarTypeForLmdz=earth_365d;;
32        360d)
33            CalendarTypeForLmdz=earth_360d;;
34        *)
35            CalendarTypeForLmdz=earth_360d
36    esac
37
38    ##--Frequency purpose ....
39    ##--  Initialisation  ....
40    OK_instan=n
41    OK_journe=n
42    OK_mensuel=n
43    ok_hf=n
44
45    case ${config_UserChoices_PeriodLength} in
46        1Y|1y|1M|1m) OK_mensuel=y ;;
47        5D|5d|1D|1d) OK_journe=y ;;
48    esac
49
50    for frequency in ${config_ATM_WriteFrequency} ; do
51        case ${frequency} in
52            5D|5d|1D|1d) OK_journe=y ;;
53        esac
54        case ${frequency} in
55            HF|hf) ok_hf=y ;;
56        esac
57    done
58
59    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
60    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
61    eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
62
63    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
64        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
65        eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
66    fi
67
68    IGCM_debug_PopStack "ATM_Initialize"
69}
70
71#-----------------------------------------------------------------
72function ATM_Update
73{
74    IGCM_debug_PushStack "ATM_Update"
75
76    case ${config_UserChoices_PeriodLength} in
77        *Y|*y) 
78               LMDZ_ecrit_mth=30.
79               LMDZ_ecrit_ISCCP=30.
80               LMDZ_periodav=30.
81               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
82                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
83                  exit
84               fi
85               ;;
86        *)
87               LMDZ_ecrit_mth=${PeriodLengthInDays}.
88               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
89               LMDZ_periodav=${PeriodLengthInDays}.
90               ;;
91    esac
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    ## algo : For CumulPeriod=1 ;
101    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
102    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
103    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
104    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
105
106    if [ ${CumulPeriod} -eq 1 ] ; then
107        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
108            IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
109            IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0
110            IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0"
111        fi
112    fi
113
114    LMDZ_adjust=n
115    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
116
117    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
118    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
119
120    [ ${CumulPeriod} -gt 1 ] && ( IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat )
121
122    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
123    LMDZ_sed physiq.def OK_instan   ${OK_instan}
124    LMDZ_sed physiq.def OK_journe   ${OK_journe}
125    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel}
126    LMDZ_sed physiq.def ok_hf       ${ok_hf}
127    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth}
128    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
129
130    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified
131
132    ## run.def parameters
133    LMDZ_sed run.def dayref   ${InitDay}
134    LMDZ_sed run.def anneeref ${InitYear}
135    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
136    LMDZ_sed run.def nday     ${PeriodLengthInDays}
137    LMDZ_sed run.def raz_date ${RAZ_DATE}
138    LMDZ_sed run.def periodav ${LMDZ_periodav}
139    LMDZ_sed run.def adjust   ${LMDZ_adjust}
140
141    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
142    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
143    eval ByPass_hgardfou_teta=\${lmdz_UserChoices_ByPass_hgardfou_teta} > /dev/null 2>&1
144    if [ ${ByPass_hgardfou_teta} = y ] ; then
145        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
146        IGCM_sys_Mv gcm.def.tmp gcm.def
147        echo
148        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
149        echo
150        cat gcm.def
151        ByPass_hgardfou_teta=n
152        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
153    fi
154
155    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
156    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
157    eval ByPass_hgardfou_mats=\${lmdz_UserChoices_ByPass_hgardfou_mats} > /dev/null 2>&1
158    if [ ${ByPass_hgardfou_mats} = y ] ; then
159        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
160        IGCM_sys_Mv gcm.def.tmp gcm.def
161        echo
162        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
163        echo
164        cat gcm.def
165        ByPass_hgardfou_mats=n
166        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
167    fi
168
169    if ( ${FirstInitialize} ) ; then
170
171        if ( [ "${config_Restarts_OverRule}" = "n" ] && [ "${config_ATM_Restart}" = "n" ] ); then
172            if [ ${DRYRUN} -le 2 ] ; then
173                ##-- suppression of ozone file construction --
174                cp physiq.def physiq.def.save
175                LMDZ_sed physiq.def read_climoz 0
176                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
177                if [ ${DRYRUN} -le 1 ] ; then
178                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
179                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
180                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
181                fi
182                IGCM_sys_Mv physiq.def.save physiq.def
183            else
184                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
185                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
186            fi
187        fi
188
189    fi
190
191    IGCM_debug_PopStack "ATM_Update"
192}
193
194#-----------------------------------
195function ATM_Finalize
196{
197    IGCM_debug_PushStack "ATM_Finalize"
198
199    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod}
200
201    echo FINALIZE ATM !
202
203    IGCM_debug_PopStack "ATM_Finalize"
204}
Note: See TracBrowser for help on using the repository browser.