source: LMDZ5/branches/LMDZ5V2.0-dev/libf/dyn3d/infotrac.F90 @ 3492

Last change on this file since 3492 was 1454, checked in by Laurent Fairhead, 14 years ago

Merge of LMDZ5V1.0-dev branch r1453 into LMDZ5 trunk r1434


Fusion entre la version r1453 de la branche de développement LMDZ5V1.0-dev
et le tronc LMDZ5 (r1434)

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