source: LMDZ5/trunk/libf/dyn3dpar/infotrac.F90 @ 1565

Last change on this file since 1565 was 1565, checked in by jghattas, 13 years ago

Added interface with chemestry model REPROBUS :

  • Compile LMDZ together with Reprobus code (dependecies in both directions) and cpp key REPROBUS :

./makelmdz_fcm -ext_src my_path_to_reprobus -cpp REPROBUS ...

  • For running, add type_trac=repr in run.def.

/Marion Marchand, JG

File size: 13.3 KB
Line 
1! $Id$
2!
3MODULE infotrac
4
5! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
6  INTEGER, SAVE :: nqtot
7
8! nbtr : number of tracers not including higher order of moment or water vapor or liquid
9!        number of tracers used in the physics
10  INTEGER, SAVE :: nbtr
11
12! Name variables
13  CHARACTER(len=20), ALLOCATABLE, DIMENSION(:), SAVE :: tname ! tracer short name for restart and diagnostics
14  CHARACTER(len=23), ALLOCATABLE, DIMENSION(:), SAVE :: ttext ! tracer long name for diagnostics
15
16! iadv  : index of trasport schema for each tracer
17  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: iadv
18
19! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the
20!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code.
21  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
22
23! conv_flg(it)=0 : convection desactivated for tracer number it
24  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: conv_flg
25! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it
26  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: pbl_flg
27
28  CHARACTER(len=4),SAVE :: type_trac
29 
30CONTAINS
31
32  SUBROUTINE infotrac_init
33    USE control_mod
34#ifdef REPROBUS
35    USE CHEM_REP, ONLY : Init_chem_rep_trac
36#endif
37    IMPLICIT NONE
38!=======================================================================
39!
40!   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
41!   -------
42!   Modif special traceur F.Forget 05/94
43!   Modif M-A Filiberti 02/02 lecture de traceur.def
44!
45!   Objet:
46!   ------
47!   GCM LMD nouvelle grille
48!
49!=======================================================================
50!   ... modification de l'integration de q ( 26/04/94 ) ....
51!-----------------------------------------------------------------------
52! Declarations
53
54    INCLUDE "dimensions.h"
55    INCLUDE "iniprint.h"
56
57! Local variables
58    INTEGER, ALLOCATABLE, DIMENSION(:) :: hadv  ! index of horizontal trasport schema
59    INTEGER, ALLOCATABLE, DIMENSION(:) :: vadv  ! index of vertical trasport schema
60
61    CHARACTER(len=15), ALLOCATABLE, DIMENSION(:) :: tnom_0  ! tracer short name
62    CHARACTER(len=8), ALLOCATABLE, DIMENSION(:) :: tracnam ! name from INCA
63    CHARACTER(len=3), DIMENSION(30) :: descrq
64    CHARACTER(len=1), DIMENSION(3)  :: txts
65    CHARACTER(len=2), DIMENSION(9)  :: txtp
66    CHARACTER(len=23)               :: str1,str2
67 
68    INTEGER :: nqtrue  ! number of tracers read from tracer.def, without higer order of moment
69    INTEGER :: iq, new_iq, iiq, jq, ierr
70
71    character(len=*),parameter :: modname="infotrac_init"
72!-----------------------------------------------------------------------
73! Initialization :
74!
75    txts=(/'x','y','z'/)
76    txtp=(/'x ','y ','z ','xx','xy','xz','yy','yz','zz'/)
77
78    descrq(14)='VLH'
79    descrq(10)='VL1'
80    descrq(11)='VLP'
81    descrq(12)='FH1'
82    descrq(13)='FH2'
83    descrq(16)='PPM'
84    descrq(17)='PPS'
85    descrq(18)='PPP'
86    descrq(20)='SLP'
87    descrq(30)='PRA'
88   
89
90    ! Coherence test between parameter type_trac and config_inca
91    IF (type_trac=='inca') THEN
92       WRITE(lunout,*) 'You have choosen to couple with INCA chemestry model : type_trac=', &
93            type_trac,' config_inca=',config_inca
94       IF (config_inca/='aero' .AND. config_inca/='chem') THEN
95          WRITE(lunout,*) 'Incoherence between type_trac and config_inca. Model stops. Modify run.def'
96          CALL abort_gcm('infotrac_init','Incoherence between type_trac and config_inca',1)
97       END IF
98    ELSE IF (type_trac=='repr') THEN
99       WRITE(lunout,*) 'You have choosen to couple with REPROBUS chemestry model : type_trac=', type_trac
100    ELSE IF (type_trac == 'lmdz') THEN
101       WRITE(lunout,*) 'Tracers are treated in LMDZ only : type_trac=', type_trac
102    ELSE
103       WRITE(lunout,*) 'type_trac=',type_trac,' not possible. Model stops'
104       CALL abort_gcm('infotrac_init','bad parameter',1)
105    END IF
106
107
108    ! Test if config_inca is other then none for run without INCA
109    IF (type_trac/='inca' .AND. config_inca/='none') THEN
110       WRITE(lunout,*) 'config_inca will now be changed to none as you do not couple with INCA model'
111       config_inca='none'
112    END IF
113
114
115!-----------------------------------------------------------------------
116!
117! 1) Get the true number of tracers + water vapor/liquid
118!    Here true tracers (nqtrue) means declared tracers (only first order)
119!
120!-----------------------------------------------------------------------
121    IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
122       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
123       IF(ierr.EQ.0) THEN
124          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
125          READ(90,*) nqtrue
126       ELSE
127          WRITE(lunout,*) trim(modname),': Problem in opening traceur.def'
128          WRITE(lunout,*) trim(modname),': WARNING using defaut values'
129          if (planet_type=='earth') then
130            nqtrue=4 ! Default value for Earth
131          else
132            nqtrue=1 ! Default value for other planets
133          endif
134       END IF
135       if ( planet_type=='earth') then
136         ! For Earth, water vapour & liquid tracers are not in the physics
137         nbtr=nqtrue-2
138       else
139         ! Other planets (for now); we have the same number of tracers
140         ! in the dynamics than in the physics
141         nbtr=nqtrue
142       endif
143    ELSE ! type_trac=inca
144       ! nbtr has been read from INCA by init_const_lmdz() in gcm.F
145       nqtrue=nbtr+2
146    END IF
147
148    IF ((planet_type=="earth").and.(nqtrue < 2)) THEN
149       WRITE(lunout,*) trim(modname),': nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
150       CALL abort_gcm('infotrac_init','Not enough tracers',1)
151    END IF
152   
153! Transfert number of tracers to Reprobus
154    IF (type_trac == 'repr') THEN
155#ifdef REPROBUS
156       CALL Init_chem_rep_trac(nbtr)
157#endif
158    END IF
159       
160!
161! Allocate variables depending on nqtrue and nbtr
162!
163    ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue))
164    ALLOCATE(conv_flg(nbtr), pbl_flg(nbtr), tracnam(nbtr))
165    conv_flg(:) = 1 ! convection activated for all tracers
166    pbl_flg(:)  = 1 ! boundary layer activated for all tracers
167
168!-----------------------------------------------------------------------
169! 2)     Choix  des schemas d'advection pour l'eau et les traceurs
170!
171!     iadv = 1    schema  transport type "humidite specifique LMD"
172!     iadv = 2    schema   amont
173!     iadv = 14   schema  Van-leer + humidite specifique
174!                            Modif F.Codron
175!     iadv = 10   schema  Van-leer (retenu pour l'eau vapeur et liquide)
176!     iadv = 11   schema  Van-Leer pour hadv et version PPM (Monotone) pour vadv
177!     iadv = 12   schema  Frederic Hourdin I
178!     iadv = 13   schema  Frederic Hourdin II
179!     iadv = 16   schema  PPM Monotone(Collela & Woodward 1984)
180!     iadv = 17   schema  PPM Semi Monotone (overshoots autorisés)
181!     iadv = 18   schema  PPM Positif Defini (overshoots undershoots autorisés)
182!     iadv = 20   schema  Slopes
183!     iadv = 30   schema  Prather
184!
185!        Dans le tableau q(ij,l,iq) : iq = 1  pour l'eau vapeur
186!                                     iq = 2  pour l'eau liquide
187!       Et eventuellement             iq = 3,nqtot pour les autres traceurs
188!
189!        iadv(1): choix pour l'eau vap. et  iadv(2) : choix pour l'eau liq.
190!------------------------------------------------------------------------
191!
192!    Get choice of advection schema from file tracer.def or from INCA
193!---------------------------------------------------------------------
194    IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
195       IF(ierr.EQ.0) THEN
196          ! Continue to read tracer.def
197          DO iq=1,nqtrue
198             READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
199          END DO
200          CLOSE(90) 
201       ELSE ! Without tracer.def, set default values
202         if (planet_type=="earth") then
203          ! for Earth, default is to have 4 tracers
204          hadv(1) = 14
205          vadv(1) = 14
206          tnom_0(1) = 'H2Ov'
207          hadv(2) = 10
208          vadv(2) = 10
209          tnom_0(2) = 'H2Ol'
210          hadv(3) = 10
211          vadv(3) = 10
212          tnom_0(3) = 'RN'
213          hadv(4) = 10
214          vadv(4) = 10
215          tnom_0(4) = 'PB'
216         else ! default for other planets
217          hadv(1) = 10
218          vadv(1) = 10
219          tnom_0(1) = 'dummy'
220         endif ! of if (planet_type=="earth")
221       END IF
222       
223       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
224       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
225       DO iq=1,nqtrue
226          WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
227       END DO
228
229    ELSE  ! type_trac=inca : config_inca='aero' ou 'chem'
230! le module de chimie fournit les noms des traceurs
231! et les schemas d'advection associes.
232     
233#ifdef INCA
234       CALL init_transport( &
235            hadv, &
236            vadv, &
237            conv_flg, &
238            pbl_flg,  &
239            tracnam)
240#endif
241       tnom_0(1)='H2Ov'
242       tnom_0(2)='H2Ol'
243
244       DO iq =3,nqtrue
245          tnom_0(iq)=tracnam(iq-2)
246       END DO
247
248    END IF ! type_trac
249
250!-----------------------------------------------------------------------
251!
252! 3) Verify if advection schema 20 or 30 choosen
253!    Calculate total number of tracers needed: nqtot
254!    Allocate variables depending on total number of tracers
255!-----------------------------------------------------------------------
256    new_iq=0
257    DO iq=1,nqtrue
258       ! Add tracers for certain advection schema
259       IF (hadv(iq)<20 .AND. vadv(iq)<20 ) THEN
260          new_iq=new_iq+1  ! no tracers added
261       ELSE IF (hadv(iq)==20 .AND. vadv(iq)==20 ) THEN
262          new_iq=new_iq+4  ! 3 tracers added
263       ELSE IF (hadv(iq)==30 .AND. vadv(iq)==30 ) THEN
264          new_iq=new_iq+10 ! 9 tracers added
265       ELSE
266          WRITE(lunout,*) trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
267          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 1',1)
268       END IF
269    END DO
270   
271    IF (new_iq /= nqtrue) THEN
272       ! The choice of advection schema imposes more tracers
273       ! Assigne total number of tracers
274       nqtot = new_iq
275
276       WRITE(lunout,*) trim(modname),': The choice of advection schema for one or more tracers'
277       WRITE(lunout,*) 'makes it necessary to add tracers'
278       WRITE(lunout,*) trim(modname)//': ',nqtrue,' is the number of true tracers'
279       WRITE(lunout,*) trim(modname)//': ',nqtot, ' is the total number of tracers needed'
280
281    ELSE
282       ! The true number of tracers is also the total number
283       nqtot = nqtrue
284    END IF
285
286!
287! Allocate variables with total number of tracers, nqtot
288!
289    ALLOCATE(tname(nqtot), ttext(nqtot))
290    ALLOCATE(iadv(nqtot), niadv(nqtot))
291
292!-----------------------------------------------------------------------
293!
294! 4) Determine iadv, long and short name
295!
296!-----------------------------------------------------------------------
297    new_iq=0
298    DO iq=1,nqtrue
299       new_iq=new_iq+1
300
301       ! Verify choice of advection schema
302       IF (hadv(iq)==vadv(iq)) THEN
303          iadv(new_iq)=hadv(iq)
304       ELSE IF (hadv(iq)==10 .AND. vadv(iq)==16) THEN
305          iadv(new_iq)=11
306       ELSE
307          WRITE(lunout,*)trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
308
309          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 2',1)
310       END IF
311     
312       str1=tnom_0(iq)
313       tname(new_iq)= tnom_0(iq)
314       IF (iadv(new_iq)==0) THEN
315          ttext(new_iq)=trim(str1)
316       ELSE
317          ttext(new_iq)=trim(tnom_0(iq))//descrq(iadv(new_iq))
318       END IF
319
320       ! schemas tenant compte des moments d'ordre superieur
321       str2=ttext(new_iq)
322       IF (iadv(new_iq)==20) THEN
323          DO jq=1,3
324             new_iq=new_iq+1
325             iadv(new_iq)=-20
326             ttext(new_iq)=trim(str2)//txts(jq)
327             tname(new_iq)=trim(str1)//txts(jq)
328          END DO
329       ELSE IF (iadv(new_iq)==30) THEN
330          DO jq=1,9
331             new_iq=new_iq+1
332             iadv(new_iq)=-30
333             ttext(new_iq)=trim(str2)//txtp(jq)
334             tname(new_iq)=trim(str1)//txtp(jq)
335          END DO
336       END IF
337    END DO
338
339!
340! Find vector keeping the correspodence between true and total tracers
341!
342    niadv(:)=0
343    iiq=0
344    DO iq=1,nqtot
345       IF(iadv(iq).GE.0) THEN
346          ! True tracer
347          iiq=iiq+1
348          niadv(iiq)=iq
349       ENDIF
350    END DO
351
352
353    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
354    WRITE(lunout,*) trim(modname),': iadv  niadv tname  ttext :'
355    DO iq=1,nqtot
356       WRITE(lunout,*) iadv(iq),niadv(iq),&
357       ' ',trim(tname(iq)),' ',trim(ttext(iq))
358    END DO
359
360!
361! Test for advection schema.
362! This version of LMDZ only garantees iadv=10 and iadv=14 (14 only for water vapour) .
363!
364    DO iq=1,nqtot
365       IF (iadv(iq)/=10 .AND. iadv(iq)/=14 .AND. iadv(iq)/=0) THEN
366          WRITE(lunout,*)trim(modname),' STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
367          CALL abort_gcm('infotrac_init','In this version only iadv=10 and iadv=14 is tested!',1)
368       ELSE IF (iadv(iq)==14 .AND. iq/=1) THEN
369          WRITE(lunout,*)trim(modname),'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
370          CALL abort_gcm('infotrac_init','In this version iadv=14 is only permitted for water vapour!',1)
371       END IF
372    END DO
373
374!-----------------------------------------------------------------------
375! Finalize :
376!
377    DEALLOCATE(tnom_0, hadv, vadv)
378    DEALLOCATE(tracnam)
379
380  END SUBROUTINE infotrac_init
381
382END MODULE infotrac
Note: See TracBrowser for help on using the repository browser.