source: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/config/ppsrc/dyn3d_common/infotrac.f90 @ 224

Last change on this file since 224 was 224, checked in by ymipsl, 10 years ago
File size: 15.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
35
36
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, ierr2, ierr3
70   
71    character(len=80) :: line ! to store a line of text
72 
73    character(len=*),parameter :: modname="infotrac_init"
74!-----------------------------------------------------------------------
75! Initialization :
76!
77    txts=(/'x','y','z'/)
78    txtp=(/'x ','y ','z ','xx','xy','xz','yy','yz','zz'/)
79
80    descrq(14)='VLH'
81    descrq(10)='VL1'
82    descrq(11)='VLP'
83    descrq(12)='FH1'
84    descrq(13)='FH2'
85    descrq(16)='PPM'
86    descrq(17)='PPS'
87    descrq(18)='PPP'
88    descrq(20)='SLP'
89    descrq(30)='PRA'
90   
91    IF (planet_type=='earth') THEN
92     ! Coherence test between parameter type_trac, config_inca and preprocessing keys
93     IF (type_trac=='inca') THEN
94       WRITE(lunout,*) 'You have choosen to couple with INCA chemestry model : type_trac=', &
95            type_trac,' config_inca=',config_inca
96       IF (config_inca/='aero' .AND. config_inca/='chem') THEN
97          WRITE(lunout,*) 'Incoherence between type_trac and config_inca. Model stops. Modify run.def'
98          CALL abort_gcm('infotrac_init','Incoherence between type_trac and config_inca',1)
99       END IF
100
101       WRITE(lunout,*) 'To run this option you must add cpp key INCA and compile with INCA code'
102       CALL abort_gcm('infotrac_init','You must compile with cpp key INCA',1)
103
104     ELSE IF (type_trac=='repr') THEN
105       WRITE(lunout,*) 'You have choosen to couple with REPROBUS chemestry model : type_trac=', type_trac
106
107       WRITE(lunout,*) 'To run this option you must add cpp key REPROBUS and compile with REPRPBUS code'
108       CALL abort_gcm('infotrac_init','You must compile with cpp key REPROBUS',1)
109
110     ELSE IF (type_trac == 'lmdz') THEN
111       WRITE(lunout,*) 'Tracers are treated in LMDZ only : type_trac=', type_trac
112     ELSE
113       WRITE(lunout,*) 'type_trac=',type_trac,' not possible. Model stops'
114       CALL abort_gcm('infotrac_init','bad parameter',1)
115     END IF
116
117     ! Test if config_inca is other then none for run without INCA
118     IF (type_trac/='inca' .AND. config_inca/='none') THEN
119       WRITE(lunout,*) 'config_inca will now be changed to none as you do not couple with INCA model'
120       config_inca='none'
121     END IF
122    ELSE
123     type_trac='plnt'  ! planets... May want to dissociate between each later.
124    ENDIF ! of IF (planet_type=='earth')
125
126!-----------------------------------------------------------------------
127!
128! 1) Get the true number of tracers + water vapor/liquid
129!    Here true tracers (nqtrue) means declared tracers (only first order)
130!
131!-----------------------------------------------------------------------
132    IF (planet_type=='earth') THEN
133     IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
134       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
135       IF(ierr.EQ.0) THEN
136          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
137          READ(90,*) nqtrue
138       ELSE
139          WRITE(lunout,*) trim(modname),': Problem in opening traceur.def'
140          WRITE(lunout,*) trim(modname),': WARNING using defaut values'
141          nqtrue=4 ! Defaut value
142       END IF
143       ! For Earth, water vapour & liquid tracers are not in the physics
144       nbtr=nqtrue-2
145     ELSE ! type_trac=inca
146       ! nbtr has been read from INCA by init_cont_lmdz() in gcm.F
147       nqtrue=nbtr+2
148     END IF
149
150     IF (nqtrue < 2) THEN
151       WRITE(lunout,*) trim(modname),': nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
152       CALL abort_gcm('infotrac_init','Not enough tracers',1)
153     END IF
154
155! Transfert number of tracers to Reprobus
156     IF (type_trac == 'repr') THEN
157
158
159
160     END IF
161
162    ELSE  ! not Earth
163       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
164       IF(ierr.EQ.0) THEN
165          WRITE(lunout,*) 'Open traceur.def : ok'
166          READ(90,*) nqtrue
167       ELSE
168          WRITE(lunout,*) 'Problem in opening traceur.def'
169          WRITE(lunout,*) 'ATTENTION using defaut values: nqtrue=1'
170          nqtrue=1 ! Defaut value
171       END IF
172       ! Other planets (for now); we have the same number of tracers
173       ! in the dynamics than in the physics
174       nbtr=nqtrue
175     
176    ENDIF  ! planet_type
177!
178! Allocate variables depending on nqtrue and nbtr
179!
180    ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue))
181    ALLOCATE(conv_flg(nbtr), pbl_flg(nbtr), tracnam(nbtr))
182    conv_flg(:) = 1 ! convection activated for all tracers
183    pbl_flg(:)  = 1 ! boundary layer activated for all tracers
184
185!-----------------------------------------------------------------------
186! 2)     Choix  des schemas d'advection pour l'eau et les traceurs
187!
188!     iadv = 1    schema  transport type "humidite specifique LMD"
189!     iadv = 2    schema   amont
190!     iadv = 14   schema  Van-leer + humidite specifique
191!                            Modif F.Codron
192!     iadv = 10   schema  Van-leer (retenu pour l'eau vapeur et liquide)
193!     iadv = 11   schema  Van-Leer pour hadv et version PPM (Monotone) pour vadv
194!     iadv = 12   schema  Frederic Hourdin I
195!     iadv = 13   schema  Frederic Hourdin II
196!     iadv = 16   schema  PPM Monotone(Collela & Woodward 1984)
197!     iadv = 17   schema  PPM Semi Monotone (overshoots autorisés)
198!     iadv = 18   schema  PPM Positif Defini (overshoots undershoots autorisés)
199!     iadv = 20   schema  Slopes
200!     iadv = 30   schema  Prather
201!
202!        Dans le tableau q(ij,l,iq) : iq = 1  pour l'eau vapeur
203!                                     iq = 2  pour l'eau liquide
204!       Et eventuellement             iq = 3,nqtot pour les autres traceurs
205!
206!        iadv(1): choix pour l'eau vap. et  iadv(2) : choix pour l'eau liq.
207!------------------------------------------------------------------------
208!
209!    Get choice of advection schema from file tracer.def or from INCA
210!---------------------------------------------------------------------
211    IF (planet_type=='earth') THEN
212     IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
213       IF(ierr.EQ.0) THEN
214          ! Continue to read tracer.def
215          DO iq=1,nqtrue
216             READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
217          END DO
218          CLOSE(90) 
219       ELSE ! Without tracer.def, set default values (for Earth!)
220         if ((nqtrue==4).and.(planet_type=="earth")) then
221          hadv(1) = 14
222          vadv(1) = 14
223          tnom_0(1) = 'H2Ov'
224          hadv(2) = 10
225          vadv(2) = 10
226          tnom_0(2) = 'H2Ol'
227          hadv(3) = 10
228          vadv(3) = 10
229          tnom_0(3) = 'RN'
230          hadv(4) = 10
231          vadv(4) = 10
232          tnom_0(4) = 'PB'
233         else
234           ! Error message, we need a traceur.def file
235           write(lunout,*) trim(modname),&
236           ': Cannot set default tracer names!'
237           write(lunout,*) trim(modname),' Make a traceur.def file!!!'
238           CALL abort_gcm('infotrac_init','Need a traceur.def file!',1)
239         endif ! of if (nqtrue==4)
240       END IF
241       
242       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
243       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
244       DO iq=1,nqtrue
245          WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
246       END DO
247
248     ELSE  ! type_trac=inca : config_inca='aero' ou 'chem'
249! le module de chimie fournit les noms des traceurs
250! et les schemas d'advection associes.
251     
252       tnom_0(1)='H2Ov'
253       tnom_0(2)='H2Ol'
254
255       DO iq =3,nqtrue
256          tnom_0(iq)=tracnam(iq-2)
257       END DO
258
259     END IF ! type_trac
260
261    ELSE  ! not Earth
262       IF(ierr.EQ.0) THEN
263          ! Continue to read tracer.def
264          DO iq=1,nqtrue
265             !READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
266            ! try to be smart when reading traceur.def
267            read(90,'(80a)') line ! store the line from traceur.def
268            ! assume format is hadv,vadv,tnom_0
269            read(line,*,iostat=ierr2) hadv(iq),vadv(iq),tnom_0(iq)
270            if (ierr2.ne.0) then
271              ! maybe format is tnom0,hadv,vadv
272              read(line,*,iostat=ierr3) tnom_0(iq),hadv(iq),vadv(iq)
273              if (ierr3.ne.0) then
274                ! assume only tnom0 is provided (havd and vad default to 10)
275                read(line,*) tnom_0(iq)
276                hadv(iq)=10
277                vadv(iq)=10
278              endif
279            endif ! of if(ierr2.ne.0)
280          END DO ! of DO iq=1,nqtrue
281          CLOSE(90) 
282       ELSE ! Without tracer.def
283          hadv(1) = 10
284          vadv(1) = 10
285          tnom_0(1) = 'dummy'
286       END IF
287       
288       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
289       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
290       DO iq=1,nqtrue
291          WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
292       END DO
293
294    ENDIF  ! planet_type
295
296!-----------------------------------------------------------------------
297!
298! 3) Verify if advection schema 20 or 30 choosen
299!    Calculate total number of tracers needed: nqtot
300!    Allocate variables depending on total number of tracers
301!-----------------------------------------------------------------------
302    new_iq=0
303    DO iq=1,nqtrue
304       ! Add tracers for certain advection schema
305       IF (hadv(iq)<20 .AND. vadv(iq)<20 ) THEN
306          new_iq=new_iq+1  ! no tracers added
307       ELSE IF (hadv(iq)==20 .AND. vadv(iq)==20 ) THEN
308          new_iq=new_iq+4  ! 3 tracers added
309       ELSE IF (hadv(iq)==30 .AND. vadv(iq)==30 ) THEN
310          new_iq=new_iq+10 ! 9 tracers added
311       ELSE
312          WRITE(lunout,*) trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
313          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 1',1)
314       END IF
315    END DO
316   
317    IF (new_iq /= nqtrue) THEN
318       ! The choice of advection schema imposes more tracers
319       ! Assigne total number of tracers
320       nqtot = new_iq
321
322       WRITE(lunout,*) trim(modname),': The choice of advection schema for one or more tracers'
323       WRITE(lunout,*) 'makes it necessary to add tracers'
324       WRITE(lunout,*) trim(modname)//': ',nqtrue,' is the number of true tracers'
325       WRITE(lunout,*) trim(modname)//': ',nqtot, ' is the total number of tracers needed'
326
327    ELSE
328       ! The true number of tracers is also the total number
329       nqtot = nqtrue
330    END IF
331
332!
333! Allocate variables with total number of tracers, nqtot
334!
335    ALLOCATE(tname(nqtot), ttext(nqtot))
336    ALLOCATE(iadv(nqtot), niadv(nqtot))
337
338!-----------------------------------------------------------------------
339!
340! 4) Determine iadv, long and short name
341!
342!-----------------------------------------------------------------------
343    new_iq=0
344    DO iq=1,nqtrue
345       new_iq=new_iq+1
346
347       ! Verify choice of advection schema
348       IF (hadv(iq)==vadv(iq)) THEN
349          iadv(new_iq)=hadv(iq)
350       ELSE IF (hadv(iq)==10 .AND. vadv(iq)==16) THEN
351          iadv(new_iq)=11
352       ELSE
353          WRITE(lunout,*)trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
354
355          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 2',1)
356       END IF
357     
358       str1=tnom_0(iq)
359       tname(new_iq)= tnom_0(iq)
360       IF (iadv(new_iq)==0) THEN
361          ttext(new_iq)=trim(str1)
362       ELSE
363          ttext(new_iq)=trim(tnom_0(iq))//descrq(iadv(new_iq))
364       END IF
365
366       ! schemas tenant compte des moments d'ordre superieur
367       str2=ttext(new_iq)
368       IF (iadv(new_iq)==20) THEN
369          DO jq=1,3
370             new_iq=new_iq+1
371             iadv(new_iq)=-20
372             ttext(new_iq)=trim(str2)//txts(jq)
373             tname(new_iq)=trim(str1)//txts(jq)
374          END DO
375       ELSE IF (iadv(new_iq)==30) THEN
376          DO jq=1,9
377             new_iq=new_iq+1
378             iadv(new_iq)=-30
379             ttext(new_iq)=trim(str2)//txtp(jq)
380             tname(new_iq)=trim(str1)//txtp(jq)
381          END DO
382       END IF
383    END DO
384
385!
386! Find vector keeping the correspodence between true and total tracers
387!
388    niadv(:)=0
389    iiq=0
390    DO iq=1,nqtot
391       IF(iadv(iq).GE.0) THEN
392          ! True tracer
393          iiq=iiq+1
394          niadv(iiq)=iq
395       ENDIF
396    END DO
397
398
399    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
400    WRITE(lunout,*) trim(modname),': iadv  niadv tname  ttext :'
401    DO iq=1,nqtot
402       WRITE(lunout,*) iadv(iq),niadv(iq),&
403       ' ',trim(tname(iq)),' ',trim(ttext(iq))
404    END DO
405
406!
407! Test for advection schema.
408! This version of LMDZ only garantees iadv=10 and iadv=14 (14 only for water vapour) .
409!
410    DO iq=1,nqtot
411       IF (iadv(iq)/=10 .AND. iadv(iq)/=14 .AND. iadv(iq)/=0) THEN
412          WRITE(lunout,*)trim(modname),' STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
413          CALL abort_gcm('infotrac_init','In this version only iadv=10 and iadv=14 is tested!',1)
414       ELSE IF (iadv(iq)==14 .AND. iq/=1) THEN
415          WRITE(lunout,*)trim(modname),'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
416          CALL abort_gcm('infotrac_init','In this version iadv=14 is only permitted for water vapour!',1)
417       END IF
418    END DO
419
420!-----------------------------------------------------------------------
421! Finalize :
422!
423    DEALLOCATE(tnom_0, hadv, vadv)
424    DEALLOCATE(tracnam)
425
426  END SUBROUTINE infotrac_init
427
428END MODULE infotrac
Note: See TracBrowser for help on using the repository browser.