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

Last change on this file since 1899 was 1897, checked in by jvatant, 7 years ago

Making Titan's hazy again - part II
+ Major updates of J.Burgalat YAMMS library and optical coupling, including :
++ Added the routines for haze optics inside YAMMS
++ Calling rad. transf. with interactive haze is plugged
in but should stay unactive as long as the microphysics is
in test phase : cf "uncoupl_optic_haze" flag : true for now !
++ Also some sanity checks for negative tendencies and
some others upkeep of YAMMS model
+ Also added a temporary CPP key USE_QTEST in physiq_mod
that enables to have microphysical tendencies separated
from dynamics for debugging and test phases
-- JVO and JB

  • Property svn:executable set to *
File size: 6.9 KB
Line 
1
2
3SUBROUTINE calmufi(plev, zlev, play, zlay, temp, pq, zdq)
4  !! Interface subroutine to YAMMS model for Titan LMDZ GCM.
5  !!
6  !! The subroutine computes the microphysics processes for a si:le 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), DIMENSION(:,:), INTENT(IN) :: plev  !! Pressure levels (Pa).
25  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlev  !! Altitude levels (m).
26  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: play  !! Pressure layers (Pa).
27  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlay  !! Altitude at the center of each layer (m).
28  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: temp  !! Temperature at the center of each layer (K).
29
30  REAL(kind=8), DIMENSION(:,:,:), INTENT(IN)  :: pq   !! Tracers (\(kg.kg^{-1}}\)).
31  REAL(kind=8), DIMENSION(:,:,:), INTENT(OUT) :: zdq  !! Tendency for tracers (\(kg.kg^{-1}}\)).
32 
33  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0as !! 0th order moment of the spherical mode (\(m^{-2}\)).
34  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3as !! 3rd order moment of the spherical mode (\(m^{3}.m^{-2}\)).
35  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0af !! 0th order moment of the fractal mode (\(m^{-2}\)).
36  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3af !! 3rd order moment of the fractal mode (\(m^{3}.m^{-2}\)).
37
38  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m0n  !! 0th order moment of the CCN distribution (\(m^{-2}\)).
39  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m3n  !! 3rd order moment of the CCN distribution (\(m^{3}.m^{-2}\)).
40  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: m3i  !! 3rd order moments of the ice components (\(m^{3}.m^{-2}\)).
41  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: gazs !! Condensible species gazs molar fraction (\(mol.mol^{-1}\)).
42
43  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0as !! Tendency of the 0th order moment of the spherical mode distribution (\(m^{-2}\)).
44  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3as !! Tendency of the 3rd order moment of the spherical mode distribution (\(m^{3}.m^{-2}\)).
45  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0af !! Tendency of the 0th order moment of the fractal mode distribution (\(m^{-2}\)).
46  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3af !! Tendency of the 3rd order moment of the fractal mode distribution (\(m^{3}.m^{-2}\)).
47  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0n  !! Tendency of the 0th order moment of the _CCN_ distribution (\(m^{-2}\)).
48  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3n  !! Tendency of the 3rd order moment of the _CCN_ distribution (\(m^{3}.m^{-2}\)).
49  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dm3i  !! Tendencies of the 3rd order moments of each ice components (\(m^{3}.m^{-2}\)).
50  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dgazs !! Tendencies of each condensible gaz species !(\(mol.mol^{-1}\)).
51
52  REAL(kind=8), DIMENSION(:), ALLOCATABLE ::  int2ext
53  TYPE(error) :: err
54
55  INTEGER :: ilon, i,nices
56  INTEGER :: nlon,nlay
57
58  ! Read size of arrays
59  nlon  = size(play,DIM=1)
60  nlay  = size(play,DIM=2)
61  nices = size(ices_indx)
62  ! Conversion intensive to extensive
63  ALLOCATE( int2ext(nlay) ) 
64
65  ! Loop on horizontal grid points
66
67  ! Allocate arrays
68  ALLOCATE( m0as(nlay) )
69  ALLOCATE( m3as(nlay) )
70  ALLOCATE( m0af(nlay) )
71  ALLOCATE( m3af(nlay) )
72  ALLOCATE( m0n(nlay) )
73  ALLOCATE( m3n(nlay) )
74  ALLOCATE( m3i(nlay,nices) )
75  ALLOCATE( gazs(nlay,nices) )
76
77  ALLOCATE( dm0as(nlay) )
78  ALLOCATE( dm3as(nlay) )
79  ALLOCATE( dm0af(nlay) )
80  ALLOCATE( dm3af(nlay) )
81  ALLOCATE( dm0n(nlay) )
82  ALLOCATE( dm3n(nlay) )
83  ALLOCATE( dm3i(nlay,nices) )
84  ALLOCATE( dgazs(nlay,nices) )
85
86  ! Initialization of zdq here since intent=out and no action performed on every tracers
87  zdq(:,:,:) = 0.0
88
89  DO ilon = 1, nlon
90    ! Convert tracers to extensive ( except for gazs where we work with molar mass ratio )
91    ! We suppose a given order of tracers !
92    int2ext(:) = ( plev(ilon,1:nlay)-plev(ilon,2:nlay+1) ) / g
93    m0as(:) = pq(ilon,:,1) * int2ext(:)
94    m3as(:) = pq(ilon,:,2) * int2ext(:)
95    m0af(:) = pq(ilon,:,3) * int2ext(:)
96    m3af(:) = pq(ilon,:,4) * int2ext(:)
97   
98    if (callclouds) then ! if call clouds
99      m0n(:) = pq(ilon,:,5) * int2ext(:)
100      m3n(:) = pq(ilon,:,6) * int2ext(:)
101      do i=1,nices
102        m3i(:,nices) = pq(ilon,:,6+i) * int2ext(:)
103        gazs(:,i)    = pq(ilon,:,ices_indx(i)) * rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
104        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
105      enddo
106    endif
107
108    ! Initialize YAMMS atmospheric column
109    err = mm_column_init(plev(ilon,:),zlev(ilon,:),play(ilon,:),zlay(ilon,:),temp(ilon,:)) ; IF (err /= 0) call abort_program(err)
110    ! Initialize YAMMS aerosols moments column
111    err = mm_aerosols_init(m0as,m3as,m0af,m3af) ; IF (err /= 0) call abort_program(err)
112    IF (callclouds) THEN ! call clouds
113      err = mm_clouds_init(m0n,m3n,m3i,gazs) ; IF (err /= 0) call abort_program(err)
114    ENDIF
115
116    ! Check on size (???)
117
118    ! initializes tendencies:
119    !dm0as(:) = 0._mm_wp ; dm3as(:) = 0._mm_wp ; dm0af(:) = 0._mm_wp ; dm3af(:) = 0._mm_wp
120    !dm0n(:) = 0._mm_wp ; dm3n(:) = 0._mm_wp ; dm3i(:,:) = 0._mm_wp ; dgazs(:,:) = 0._mm_wp
121
122    dm0as(:) = 0.0 ; dm3as(:) = 0.0 ; dm0af(:) = 0.0 ; dm3af(:) = 0.0
123    dm0n(:) = 0.0 ; dm3n(:) = 0.0 ; dm3i(:,:) = 0.0 ; dgazs(:,:) = 0.0
124    ! call microphysics
125
126    IF (callclouds) THEN ! call clouds
127      IF(.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af,dm0n,dm3n,dm3i,dgazs)) &
128        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
129    ELSE
130      IF (.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af)) &
131        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
132    ENDIF
133
134    ! Convert tracers back to intensives ( except for gazs where we work with molar mass ratio )
135    ! We suppose a given order of tracers !
136 
137    zdq(ilon,:,1) = dm0as(:) / int2ext(:)
138    zdq(ilon,:,2) = dm3as(:) / int2ext(:)
139    zdq(ilon,:,3) = dm0af(:) / int2ext(:)
140    zdq(ilon,:,4) = dm3af(:) / int2ext(:)
141   
142    if (callclouds) then ! if call clouds
143      zdq(ilon,:,5) = dm0n(:) / int2ext(:)
144      zdq(ilon,:,6) = dm3n(:) / int2ext(:)
145      do i=1,nices
146        zdq(ilon,:,6+i) = dm3i(:,nices) / int2ext(:)
147        zdq(ilon,:,ices_indx(i)) = dgazs(:,i)  / rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
148        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
149      enddo
150    endif
151  END DO ! loop on ilon
152
153END SUBROUTINE calmufi
Note: See TracBrowser for help on using the repository browser.