source: trunk/LMDZ.TITAN/libf/phytitan/calmufi.F90 @ 1914

Last change on this file since 1914 was 1908, checked in by jvatant, 8 years ago

Making chemistry handling more flexible - Major and Final Step (hopefully) !
After preliminary commits r1871-86-87-91-94-98, here comes the major update of the interface
with photochemical module + fix how tendencies for chem and mufi tracers are managed in physiq_mod !
+ Major modifs in :
++ calchim.F90 to comply with flexible resolution, parallelism, upper pressure grid ...
++ physiq_mod.F90 where there was a bug on the update of the tracers and their tendencies for calchim

and calmufi ( we actually were sending non-updated fields to these processes )
We also now put the same tendency on all longitudes within a lat band and not
relative tendency if 2D chemistry ( and we set to zero if ever negs are created )

+ Also modifs to have chemistry in 1D in rcm1d ( and moved gr_kim_vervack in phytitan to be accessible for 1d )
+ In chemistry added a check.c to verify coherence of sizes between C and Fortran
--JVO

  • Property svn:executable set to *
File size: 7.5 KB
Line 
1
2
3SUBROUTINE calmufi(dt, plev, zlev, play, zlay, temp, pq, zdqfi, zdq)
4  !! Interface subroutine to YAMMS model for Titan LMDZ GCM.
5  !!
6  !! The subroutine computes the microphysics processes for a single vertical column.
7  !!
8  !! - All input vectors are assumed to be defined from GROUND to TOP of the atmosphere.
9  !! - All output vectors are defined from GROUND to TOP of the atmosphere.
10  !! - Only tendencies are returned.
11  !!
12  !! @important
13  !! The method assumes global initialization of YAMMS model (and extras) has been already
14  !! done elsewhere.
15  !!
16  !! Authors : J.Burgalat, J.Vatant d'Ollone - 2017
17  !!
18  USE MMP_GCM
19  USE tracer_h
20  USE comcstfi_mod, only : g
21  USE callkeys_mod, only : callclouds
22  IMPLICIT NONE
23
24  REAL(kind=8), INTENT(IN) :: dt  !! Physics timestep (s).
25 
26  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: plev  !! Pressure levels (Pa).
27  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlev  !! Altitude levels (m).
28  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: play  !! Pressure layers (Pa).
29  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlay  !! Altitude at the center of each layer (m).
30  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: temp  !! Temperature at the center of each layer (K).
31
32  REAL(kind=8), DIMENSION(:,:,:), INTENT(IN)  :: pq    !! Tracers (\(kg.kg^{-1}}\)).
33  REAL(kind=8), DIMENSION(:,:,:), INTENT(IN)  :: zdqfi !! Tendency from former processes for tracers (\(kg.kg^{-1}}\)).
34  REAL(kind=8), DIMENSION(:,:,:), INTENT(OUT) :: zdq   !! Microphysical tendency for tracers (\(kg.kg^{-1}}\)).
35 
36  REAL(kind=8), DIMENSION(:,:,:), ALLOCATABLE :: zq !! Local tracers updated from former processes (\(kg.kg^{-1}}\)).
37 
38  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0as !! 0th order moment of the spherical mode (\(m^{-2}\)).
39  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3as !! 3rd order moment of the spherical mode (\(m^{3}.m^{-2}\)).
40  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0af !! 0th order moment of the fractal mode (\(m^{-2}\)).
41  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3af !! 3rd order moment of the fractal mode (\(m^{3}.m^{-2}\)).
42
43  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m0n  !! 0th order moment of the CCN distribution (\(m^{-2}\)).
44  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m3n  !! 3rd order moment of the CCN distribution (\(m^{3}.m^{-2}\)).
45  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: m3i  !! 3rd order moments of the ice components (\(m^{3}.m^{-2}\)).
46  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: gazs !! Condensible species gazs molar fraction (\(mol.mol^{-1}\)).
47
48  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0as !! Tendency of the 0th order moment of the spherical mode distribution (\(m^{-2}\)).
49  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3as !! Tendency of the 3rd order moment of the spherical mode distribution (\(m^{3}.m^{-2}\)).
50  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0af !! Tendency of the 0th order moment of the fractal mode distribution (\(m^{-2}\)).
51  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3af !! Tendency of the 3rd order moment of the fractal mode distribution (\(m^{3}.m^{-2}\)).
52  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0n  !! Tendency of the 0th order moment of the _CCN_ distribution (\(m^{-2}\)).
53  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3n  !! Tendency of the 3rd order moment of the _CCN_ distribution (\(m^{3}.m^{-2}\)).
54  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dm3i  !! Tendencies of the 3rd order moments of each ice components (\(m^{3}.m^{-2}\)).
55  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dgazs !! Tendencies of each condensible gaz species !(\(mol.mol^{-1}\)).
56
57  REAL(kind=8), DIMENSION(:), ALLOCATABLE ::  int2ext
58  TYPE(error) :: err
59
60  INTEGER :: ilon, i,nices
61  INTEGER :: nq,nlon,nlay
62
63  ! Read size of arrays
64  nq    = size(pq,DIM=3)
65  nlon  = size(play,DIM=1)
66  nlay  = size(play,DIM=2)
67  nices = size(ices_indx)
68  ! Conversion intensive to extensive
69  ALLOCATE( int2ext(nlay) ) 
70
71  ! Allocate arrays
72  ALLOCATE( zq(nlon,nlay,nq) )
73
74  ALLOCATE( m0as(nlay) )
75  ALLOCATE( m3as(nlay) )
76  ALLOCATE( m0af(nlay) )
77  ALLOCATE( m3af(nlay) )
78  ALLOCATE( m0n(nlay) )
79  ALLOCATE( m3n(nlay) )
80  ALLOCATE( m3i(nlay,nices) )
81  ALLOCATE( gazs(nlay,nices) )
82
83  ALLOCATE( dm0as(nlay) )
84  ALLOCATE( dm3as(nlay) )
85  ALLOCATE( dm0af(nlay) )
86  ALLOCATE( dm3af(nlay) )
87  ALLOCATE( dm0n(nlay) )
88  ALLOCATE( dm3n(nlay) )
89  ALLOCATE( dm3i(nlay,nices) )
90  ALLOCATE( dgazs(nlay,nices) )
91
92  ! Initialization of zdq here since intent=out and no action performed on every tracers
93  zdq(:,:,:) = 0.0
94
95  ! Initialize tracers updated with former processes from physics
96  zq(:,:,:) = pq(:,:,:) + zdqfi(:,:,:)*dt
97
98  ! Loop on horizontal grid points
99  DO ilon = 1, nlon
100    ! Convert tracers to extensive ( except for gazs where we work with molar mass ratio )
101    ! We suppose a given order of tracers !
102    int2ext(:) = ( plev(ilon,1:nlay)-plev(ilon,2:nlay+1) ) / g
103    m0as(:) = zq(ilon,:,1) * int2ext(:)
104    m3as(:) = zq(ilon,:,2) * int2ext(:)
105    m0af(:) = zq(ilon,:,3) * int2ext(:)
106    m3af(:) = zq(ilon,:,4) * int2ext(:)
107   
108    if (callclouds) then ! if call clouds
109      m0n(:) = zq(ilon,:,5) * int2ext(:)
110      m3n(:) = zq(ilon,:,6) * int2ext(:)
111      do i=1,nices
112        m3i(:,nices) = zq(ilon,:,6+i) * int2ext(:)
113        gazs(:,i)    = zq(ilon,:,ices_indx(i)) / rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
114        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
115      enddo
116    endif
117
118    ! Initialize YAMMS atmospheric column
119    err = mm_column_init(plev(ilon,:),zlev(ilon,:),play(ilon,:),zlay(ilon,:),temp(ilon,:)) ; IF (err /= 0) call abort_program(err)
120    ! Initialize YAMMS aerosols moments column
121    err = mm_aerosols_init(m0as,m3as,m0af,m3af) ; IF (err /= 0) call abort_program(err)
122    IF (callclouds) THEN ! call clouds
123      err = mm_clouds_init(m0n,m3n,m3i,gazs) ; IF (err /= 0) call abort_program(err)
124    ENDIF
125
126    ! Check on size (???)
127
128    ! initializes tendencies:
129    !dm0as(:) = 0._mm_wp ; dm3as(:) = 0._mm_wp ; dm0af(:) = 0._mm_wp ; dm3af(:) = 0._mm_wp
130    !dm0n(:) = 0._mm_wp ; dm3n(:) = 0._mm_wp ; dm3i(:,:) = 0._mm_wp ; dgazs(:,:) = 0._mm_wp
131
132    dm0as(:) = 0.0 ; dm3as(:) = 0.0 ; dm0af(:) = 0.0 ; dm3af(:) = 0.0
133    dm0n(:) = 0.0 ; dm3n(:) = 0.0 ; dm3i(:,:) = 0.0 ; dgazs(:,:) = 0.0
134    ! call microphysics
135
136    IF (callclouds) THEN ! call clouds
137      IF(.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af,dm0n,dm3n,dm3i,dgazs)) &
138        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
139    ELSE
140      IF (.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af)) &
141        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
142    ENDIF
143
144    ! Convert tracers back to intensives ( except for gazs where we work with molar mass ratio )
145    ! We suppose a given order of tracers !
146 
147    zdq(ilon,:,1) = dm0as(:) / int2ext(:)
148    zdq(ilon,:,2) = dm3as(:) / int2ext(:)
149    zdq(ilon,:,3) = dm0af(:) / int2ext(:)
150    zdq(ilon,:,4) = dm3af(:) / int2ext(:)
151   
152    if (callclouds) then ! if call clouds
153      zdq(ilon,:,5) = dm0n(:) / int2ext(:)
154      zdq(ilon,:,6) = dm3n(:) / int2ext(:)
155      do i=1,nices
156        zdq(ilon,:,6+i) = dm3i(:,nices) / int2ext(:)
157        zdq(ilon,:,ices_indx(i)) = dgazs(:,i) * rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
158        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
159      enddo
160    endif
161  END DO ! loop on ilon
162
163  ! YAMMS gives a tendency which is integrated for all the timestep but in the GCM
164  ! we want to have routines spitting tendencies in s-1 -> let's divide !
165  zdq(:,:,:) = zdq(:,:,:) / dt
166
167END SUBROUTINE calmufi
Note: See TracBrowser for help on using the repository browser.