source: CONFIG/LMDZORINCA/tags/LMDZORINCA_v2/EXP_LOI/COMP/lmdz.driver @ 1647

Last change on this file since 1647 was 1647, checked in by acosce, 10 years ago

Correct a bug in LMDZORINCA config
(forget to read LMDZ_Physiq variable in lmdz.card)

  • Property svn:executable set to *
File size: 6.0 KB
Line 
1#- $Id: lmdz.driver 841 2009-12-08 09:48:13Z acosce $
2#!/bin/ksh
3
4#-----------------------------------------------------------------
5function LMDZ_sed
6{
7    IGCM_debug_PushStack "LMDZ_sed"
8
9    sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp
10    RET=$?
11    echo "LMDZ_sed : ${1} ${2} ${3}"
12    \mv ${1}.tmp ${1}
13
14    IGCM_debug_PopStack "LMDZ_sed"
15    return $RET
16}
17
18#-----------------------------------------------------------------
19
20function ATM_Initialize
21{
22    IGCM_debug_PushStack "ATM_Initialize"
23
24    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' )
25
26    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
27
28    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' | awk "-F-" '{print $1}')
29
30
31    ##-- Calendar type for LMDZ
32    case ${config_UserChoices_CalendarType} in
33        leap|gregorian)
34            CalendarTypeForLmdz=earth_366d;;
35        noleap)
36            CalendarTypeForLmdz=earth_365d;;
37        360d)
38            CalendarTypeForLmdz=earth_360d;;
39        *)
40            CalendarTypeForLmdz=earth_360d
41    esac
42
43
44   ##- LMDZ physics version
45   ##  Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics)
46   if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then
47       LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
48   else
49       LMDZ_Physics=AP
50   fi
51   echo LMDZ physics version : ${LMDZ_Physics}
52
53
54    ##- Default number of processor for lmdz
55    NUM_PROC_ATM=1
56    if [ X"${BATCH_NUM_PROC_TOT}" != X ] ; then
57        NUM_PROC_ATM=${BATCH_NUM_PROC_TOT}
58    fi
59
60
61    ##-- Output frequency purpose ....
62    ##--  Initialisation  ....
63    ok_mensuel=y
64    ok_journe=n
65    ok_hf=n
66    ok_hf3h=n
67    ok_hf3hm=n
68    ok_stn=n
69
70
71
72    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
73    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
74    eval LMDZ_NbPeriod_adjust=\${lmdz_UserChoices_LMDZ_NbPeriod_adjust} > /dev/null 2>&1
75
76    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
77        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
78        eval LMDZ_Bands_file_name=\${lmdz_UserChoices_LMDZ_Bands_file_name} > /dev/null 2>&1
79    fi
80
81
82    IGCM_debug_PopStack "ATM_Initialize"
83}
84
85#-----------------------------------------------------------------
86function ATM_Update
87{
88    IGCM_debug_PushStack "ATM_Update"
89
90    ecritphy=${PeriodLengthInDays}
91    LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
92    LMDZ_periodav=${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
101
102    ## algo : For CumulPeriod=1 ;
103    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
104    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
105    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
106    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
107
108    if [ ${CumulPeriod} -eq 1 ] ; then
109        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
110            if [ ! X${LMDZ_Bands_file_name} = X] ; then
111               IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
112               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
113               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"
114               IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
115            fi
116        fi
117    fi
118
119    LMDZ_adjust=n
120    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
121
122    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
123    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
124
125    [ ${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 )
126
127    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z}
128    #  columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : 
129    #                                            histmth       histday        histhf    histfh3h   histhf3hm   histstn
130    LMDZ_sed physiq.def phys_out_filekeys       "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}"
131    LMDZ_sed physiq.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
132
133    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
134        LMDZ_sed guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
135    fi
136
137    ## run.def parameters
138    LMDZ_sed run.def dayref   ${InitDay}
139    LMDZ_sed run.def anneeref ${InitYear}
140    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
141    LMDZ_sed run.def nday     ${PeriodLengthInDays}
142    LMDZ_sed run.def raz_date ${RAZ_DATE}
143    LMDZ_sed run.def periodav ${LMDZ_periodav}
144    LMDZ_sed run.def adjust   ${LMDZ_adjust}
145
146    ## Other specific parameters to this experience
147    if [ ! X${lmdz_UserChoices_aer_type} = X ] ; then
148        LMDZ_sed physiq.def aer_type ${lmdz_UserChoices_aer_type}
149    fi
150    if [ ! X${lmdz_UserChoices_pmagic} = X ] ; then
151        LMDZ_sed physiq.def pmagic   ${lmdz_UserChoices_pmagic}
152    fi
153
154    IGCM_debug_PopStack "ATM_Update"
155}
156
157#-----------------------------------
158function ATM_Finalize
159{
160    IGCM_debug_PushStack "ATM_Finalize"
161
162    [ ${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}
163    echo FINALIZE ATM !
164
165    IGCM_debug_PopStack "ATM_Finalize"
166}
Note: See TracBrowser for help on using the repository browser.