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

Last change on this file since 3026 was 2369, checked in by jvatant, 5 years ago

Titan GCM: Enable to switch off microphysics compiling for old compilo such as CICLAD, in this case just use -cpp OLD_COMPILO in your makelmdz_fcm

  • Property svn:executable set to *
File size: 9.2 KB
Line 
1
2
3SUBROUTINE calmufi(dt, plev, zlev, play, zlay, g3d, temp, pq, zdqfi, zdq)
4
5! Old compilers do not handle modern Fortran in microphysics
6#ifndef OLD_COMPILO
7
8  !! Interface subroutine to YAMMS model for Titan LMDZ GCM.
9  !!
10  !! The subroutine computes the microphysics processes for a single vertical column.
11  !!
12  !! - All input vectors are assumed to be defined from GROUND to TOP of the atmosphere.
13  !! - All output vectors are defined from GROUND to TOP of the atmosphere.
14  !! - Only tendencies are returned.
15  !!
16  !! @important
17  !! The method assumes global initialization of YAMMS model (and extras) has been already
18  !! done elsewhere.
19  !!
20  !! Authors : J.Burgalat, J.Vatant d'Ollone - 2017
21  !!
22  USE MMP_GCM
23  USE tracer_h
24  USE callkeys_mod, only : callclouds
25  USE muphy_diag
26  IMPLICIT NONE
27
28  REAL(kind=8), INTENT(IN) :: dt  !! Physics timestep (s).
29 
30  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: plev  !! Pressure levels (Pa).
31  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlev  !! Altitude levels (m).
32  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: play  !! Pressure layers (Pa).
33  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: zlay  !! Altitude at the center of each layer (m).
34  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: g3d   !! Latitude-Altitude depending gravitational acceleration (m.s-2).
35  REAL(kind=8), DIMENSION(:,:), INTENT(IN) :: temp  !! Temperature at the center of each layer (K).
36
37  REAL(kind=8), DIMENSION(:,:,:), INTENT(IN)  :: pq    !! Tracers (\(X.kg^{-1}}\)).
38  REAL(kind=8), DIMENSION(:,:,:), INTENT(IN)  :: zdqfi !! Tendency from former processes for tracers (\(X.kg^{-1}}\)).
39  REAL(kind=8), DIMENSION(:,:,:), INTENT(OUT) :: zdq   !! Microphysical tendency for tracers (\(X.kg^{-1}}\)).
40 
41  REAL(kind=8), DIMENSION(:,:,:), ALLOCATABLE :: zq !! Local tracers updated from former processes (\(X.kg^{-1}}\)).
42 
43  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0as !! 0th order moment of the spherical mode (\(m^{-2}\)).
44  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3as !! 3rd order moment of the spherical mode (\(m^{3}.m^{-2}\)).
45  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m0af !! 0th order moment of the fractal mode (\(m^{-2}\)).
46  REAL(kind=8), DIMENSION(:), ALLOCATABLE :: m3af !! 3rd order moment of the fractal mode (\(m^{3}.m^{-2}\)).
47
48  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m0n  !! 0th order moment of the CCN distribution (\(m^{-2}\)).
49  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: m3n  !! 3rd order moment of the CCN distribution (\(m^{3}.m^{-2}\)).
50  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: m3i  !! 3rd order moments of the ice components (\(m^{3}.m^{-2}\)).
51  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: gazs !! Condensible species gazs molar fraction (\(mol.mol^{-1}\)).
52
53  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0as !! Tendency of the 0th order moment of the spherical mode distribution (\(m^{-2}\)).
54  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3as !! Tendency of the 3rd order moment of the spherical mode distribution (\(m^{3}.m^{-2}\)).
55  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0af !! Tendency of the 0th order moment of the fractal mode distribution (\(m^{-2}\)).
56  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3af !! Tendency of the 3rd order moment of the fractal mode distribution (\(m^{3}.m^{-2}\)).
57  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm0n  !! Tendency of the 0th order moment of the _CCN_ distribution (\(m^{-2}\)).
58  REAL(kind=8), DIMENSION(:), ALLOCATABLE   :: dm3n  !! Tendency of the 3rd order moment of the _CCN_ distribution (\(m^{3}.m^{-2}\)).
59  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dm3i  !! Tendencies of the 3rd order moments of each ice components (\(m^{3}.m^{-2}\)).
60  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE :: dgazs !! Tendencies of each condensible gaz species !(\(mol.mol^{-1}\)).
61
62  REAL(kind=8), DIMENSION(:,:), ALLOCATABLE ::  int2ext !! (\(m^{-2}\)).
63  TYPE(error) :: err
64
65  INTEGER :: ilon, i,nices
66  INTEGER :: nq,nlon,nlay
67
68  ! Read size of arrays
69  nq    = size(pq,DIM=3)
70  nlon  = size(play,DIM=1)
71  nlay  = size(play,DIM=2)
72  nices = size(ices_indx)
73  ! Conversion intensive to extensive
74  ALLOCATE( int2ext(nlon,nlay) ) 
75
76  ! Allocate arrays
77  ALLOCATE( zq(nlon,nlay,nq) )
78
79  ALLOCATE( m0as(nlay) )
80  ALLOCATE( m3as(nlay) )
81  ALLOCATE( m0af(nlay) )
82  ALLOCATE( m3af(nlay) )
83  ALLOCATE( m0n(nlay) )
84  ALLOCATE( m3n(nlay) )
85  ALLOCATE( m3i(nlay,nices) )
86  ALLOCATE( gazs(nlay,nices) )
87
88  ALLOCATE( dm0as(nlay) )
89  ALLOCATE( dm3as(nlay) )
90  ALLOCATE( dm0af(nlay) )
91  ALLOCATE( dm3af(nlay) )
92  ALLOCATE( dm0n(nlay) )
93  ALLOCATE( dm3n(nlay) )
94  ALLOCATE( dm3i(nlay,nices) )
95  ALLOCATE( dgazs(nlay,nices) )
96
97  ! Initialization of zdq here since intent=out and no action performed on every tracers
98  zdq(:,:,:) = 0.D0
99
100  ! Initialize tracers updated with former processes from physics
101  zq(:,:,:) = pq(:,:,:) + zdqfi(:,:,:)*dt
102
103  ! Loop on horizontal grid points
104  DO ilon = 1, nlon
105    ! Convert tracers to extensive ( except for gazs where we work with molar mass ratio )
106    ! We suppose a given order of tracers !
107    int2ext(ilon,:) = ( plev(ilon,1:nlay)-plev(ilon,2:nlay+1) ) / g3d(ilon,1:nlay)
108   
109    ! Check because of the threshold of small tracers values in the dynamics
110    ! WARNING : With this patch it enables to handles the small values required
111    ! by YAMMS, but still it might still leads to some unphysical values of
112    ! radii inside YAMMS, harmless for now, but who might be a problem the day
113    ! you'll want to compute optics from the radii.
114    WHERE (pq(ilon,:,1) > 2.D-200 .AND. pq(ilon,:,2) > 2.D-200) ! Test on both moments to avoid divergences if one hit the threshold but not the other
115      m0as(:) = zq(ilon,:,1) * int2ext(ilon,:)                  ! It can still be a pb if both m0 and m3 has been set to epsilon at the beginning of dynamics
116      m3as(:) = zq(ilon,:,2) * int2ext(ilon,:)                  ! then mixed, even though both are above the threshold, their ratio can be nonsense
117    ELSEWHERE
118      m0as(:)=0.D0
119      m3as(:)=0.D0
120    ENDWHERE
121    WHERE (pq(ilon,:,3) > 2.D-200 .AND. pq(ilon,:,4) > 2.D-200)
122      m0af(:) = zq(ilon,:,3) * int2ext(ilon,:)
123      m3af(:) = zq(ilon,:,4) * int2ext(ilon,:)
124    ELSEWHERE
125      m0af(:)=0.D0
126      m3af(:)=0.D0
127    ENDWHERE
128   
129    if (callclouds) then ! if call clouds
130      m0n(:) = zq(ilon,:,5) * int2ext(ilon,:)
131      m3n(:) = zq(ilon,:,6) * int2ext(ilon,:)
132      do i=1,nices
133        m3i(:,nices) = zq(ilon,:,6+i) * int2ext(ilon,:)
134        gazs(:,i)    = zq(ilon,:,ices_indx(i)) / rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
135        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
136      enddo
137    endif
138
139    ! Initialize YAMMS atmospheric column
140    err = mm_column_init(plev(ilon,:),zlev(ilon,:),play(ilon,:),zlay(ilon,:),temp(ilon,:)) ; IF (err /= 0) call abort_program(err)
141    ! Initialize YAMMS aerosols moments column
142    err = mm_aerosols_init(m0as,m3as,m0af,m3af) ; IF (err /= 0) call abort_program(err)
143    IF (callclouds) THEN ! call clouds
144      err = mm_clouds_init(m0n,m3n,m3i,gazs) ; IF (err /= 0) call abort_program(err)
145    ENDIF
146
147    ! Check on size (???)
148
149    ! initializes tendencies:
150    !dm0as(:) = 0._mm_wp ; dm3as(:) = 0._mm_wp ; dm0af(:) = 0._mm_wp ; dm3af(:) = 0._mm_wp
151    !dm0n(:) = 0._mm_wp ; dm3n(:) = 0._mm_wp ; dm3i(:,:) = 0._mm_wp ; dgazs(:,:) = 0._mm_wp
152
153    dm0as(:) = 0.D0 ; dm3as(:) = 0.D0 ; dm0af(:) = 0.D0 ; dm3af(:) = 0.D0
154    dm0n(:) = 0.D0 ; dm3n(:) = 0.D0 ; dm3i(:,:) = 0.D0 ; dgazs(:,:) = 0.D0
155    ! call microphysics
156
157    IF (callclouds) THEN ! call clouds
158      IF(.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af,dm0n,dm3n,dm3i,dgazs)) &
159        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
160    ELSE
161      IF (.NOT.mm_muphys(dm0as,dm3as,dm0af,dm3af)) &
162        call abort_program(error("mm_muphys aborted -> initialization not done !",-1))
163    ENDIF
164    ! save diags (if no clouds, relevant arrays will be set to 0 !)
165    call mm_diagnostics(mmd_aer_prec(ilon),mmd_aer_s_flux(ilon,:),mmd_aer_f_flux(ilon,:),  &
166                        mmd_ccn_prec(ilon),mmd_ccn_flux(ilon,:), mmd_ice_prec(ilon,:),   &
167                        mmd_ice_fluxes(ilon,:,:),mmd_gazs_sat(ilon,:,:))
168    call mm_get_radii(mmd_rc_sph(ilon,:),mmd_rc_fra(ilon,:),mmd_rc_cld(ilon,:))
169
170    ! Convert tracers back to intensives ( except for gazs where we work with molar mass ratio )
171    ! We suppose a given order of tracers !
172 
173    zdq(ilon,:,1) = dm0as(:) / int2ext(ilon,:)
174    zdq(ilon,:,2) = dm3as(:) / int2ext(ilon,:)
175    zdq(ilon,:,3) = dm0af(:) / int2ext(ilon,:)
176    zdq(ilon,:,4) = dm3af(:) / int2ext(ilon,:)
177   
178    if (callclouds) then ! if call clouds
179      zdq(ilon,:,5) = dm0n(:) / int2ext(ilon,:)
180      zdq(ilon,:,6) = dm3n(:) / int2ext(ilon,:)
181      do i=1,nices
182        zdq(ilon,:,6+i) = dm3i(:,nices) / int2ext(ilon,:)
183        zdq(ilon,:,ices_indx(i)) = dgazs(:,i) * rat_mmol(ices_indx(i)) ! For gazs we work on the full tracer array !!
184        ! We use the molar mass ratio from GCM in case there is discrepancy with the mm one
185      enddo
186    endif
187   
188  END DO ! loop on ilon
189
190  ! YAMMS gives a tendency which is integrated for all the timestep but in the GCM
191  ! we want to have routines spitting tendencies in s-1 -> let's divide !
192  zdq(:,:,:) = zdq(:,:,:) / dt
193
194#endif
195
196END SUBROUTINE calmufi
Note: See TracBrowser for help on using the repository browser.