source: flexpart.git/src/calcmatrix.f90 @ c0884a8

univie
Last change on this file since c0884a8 was c0884a8, checked in by pesei <petra seibert at univie ac at>, 6 years ago

replace CTBTO code for checking type of GRIB

  • Property mode set to 100644
File size: 6.6 KB
Line 
1!**********************************************************************
2! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
3! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
4! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
5!                                                                     *
6! This file is part of FLEXPART.                                      *
7!                                                                     *
8! FLEXPART is free software: you can redistribute it and/or modify    *
9! it under the terms of the GNU General Public License as published by*
10! the Free Software Foundation, either version 3 of the License, or   *
11! (at your option) any later version.                                 *
12!                                                                     *
13! FLEXPART is distributed in the hope that it will be useful,         *
14! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
16! GNU General Public License for more details.                        *
17!                                                                     *
18! You should have received a copy of the GNU General Public License   *
19! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
20!**********************************************************************
21
22subroutine calcmatrix(lconv,delt,cbmf,id_centre)
23  !                        o    i    o
24  !*****************************************************************************
25  !                                                                            *
26  !  This subroutine calculates the matrix describing convective               *
27  !  redistribution of mass in a grid column, using the subroutine             *
28  !  convect43c.f provided by Kerry Emanuel.                                   *
29  !                                                                            *
30  !  Petra Seibert, Bernd C. Krueger, 2000-2001                                *
31  !                                                                            *
32  !*****************************************************************************
33  ! Changes:                                                                   *
34  !  changed by C. Forster, November 2003 - February 2004                      *
35  !  array fmassfrac(nconvlevmax,nconvlevmax) represents                       *
36  !  the convective redistribution matrix for the particles                    *
37  !                                                                            *
38  !   Unified ECMWF and GFS builds                                             *
39  !   Marian Harustak, 12.5.2017                                               *
40  !     - Merged calcmatrix and calcmatrix_gfs into one routine using if-then  *
41  !       for meteo-type dependent code                                        *
42  !                                                                            *
43  !  Petra Seibert, 2018-06-26: simplified version met data format detection   *
44  !                                                                            *
45  !*****************************************************************************
46  !                                                                            *
47  !  lconv        indicates whether there is convection in this cell, or not   *
48  !  delt         time step for convection [s]                                 *
49  !  cbmf         cloud base mass flux                                         *
50  !  id_centre    format of metdata (ecmwf/gfs)                                *
51  !                                                                            *
52  !*****************************************************************************
53
54  use par_mod
55  use com_mod
56  use conv_mod
57  use check_gribfile_mod
58
59  implicit none
60
61  real :: rlevmass,summe
62  integer :: id_centre
63
64  integer :: iflag, k, kk, kuvz
65
66  !1-d variables for convection
67  !variables for redistribution matrix
68  real :: cbmfold, precip, qprime
69  real :: tprime, wd, f_qvsat
70  real :: delt,cbmf
71  logical :: lconv
72
73  lconv = .false.
74
75
76  ! calculate pressure at eta levels for use in convect
77  ! and assign temp & spec. hum. to 1D workspace
78  ! -------------------------------------------------------
79
80  ! pconv(1) is the pressure at the first level above ground
81  ! phconv(k) is the pressure between levels k-1 and k
82  ! dpr(k) is the pressure difference "around" tconv(k)
83  ! phconv(kmax) must also be defined 1/2 level above pconv(kmax)
84  ! Therefore, we define k = kuvz-1 and let kuvz start from 2
85  ! top layer cannot be used for convection because p at top of this layer is
86  ! not given
87
88
89  phconv(1) = psconv
90  ! Emanuel subroutine needs pressure in hPa, therefore convert all pressures
91  do kuvz = 2,nuvz
92    k = kuvz-1
93    if (id_centre.eq.icg_id_ecmwf) then
94    pconv(k) = (akz(kuvz) + bkz(kuvz)*psconv)
95    phconv(kuvz) = (akm(kuvz) + bkm(kuvz)*psconv)
96    else
97      phconv(kuvz) =  0.5*(pconv(kuvz)+pconv(k))
98    endif
99    dpr(k) = phconv(k) - phconv(kuvz)
100    qsconv(k) = f_qvsat( pconv(k), tconv(k) )
101
102  ! initialize mass fractions
103    do kk=1,nconvlev
104      fmassfrac(k,kk)=0.
105    end do
106  end do
107
108
109  !note that Emanuel says it is important
110  !a. to set this =0. every grid point
111  !b. to keep this value in the calling programme in the iteration
112
113  ! CALL CONVECTION
114  !******************
115
116    cbmfold = cbmf
117  ! Convert pressures to hPa, as required by Emanuel scheme
118  !********************************************************
119!!$    do k=1,nconvlev     !old
120    do k=1,nconvlev+1      !bugfix
121      pconv_hpa(k)=pconv(k)/100.
122      phconv_hpa(k)=phconv(k)/100.
123    end do
124    phconv_hpa(nconvlev+1)=phconv(nconvlev+1)/100.
125    call convect(nconvlevmax, nconvlev, delt, iflag, &
126         precip, wd, tprime, qprime, cbmf)
127
128  ! do not update fmassfrac and cloudbase massflux
129  ! if no convection takes place or
130  ! if a CFL criterion is violated in convect43c.f
131   if (iflag .ne. 1 .and. iflag .ne. 4) then
132     cbmf=cbmfold
133     goto 200
134   endif
135
136  ! do not update fmassfrac and cloudbase massflux
137  ! if the old and the new cloud base mass
138  ! fluxes are zero
139   if (cbmf.le.0..and.cbmfold.le.0.) then
140     cbmf=cbmfold
141     goto 200
142   endif
143
144  ! Update fmassfrac
145  ! account for mass displaced from level k to level k
146
147   lconv = .true.
148    do k=1,nconvtop
149      rlevmass = dpr(k)/ga
150      summe = 0.
151      do kk=1,nconvtop
152        fmassfrac(k,kk) = delt*fmass(k,kk)
153        summe = summe + fmassfrac(k,kk)
154      end do
155      fmassfrac(k,k)=fmassfrac(k,k) + rlevmass - summe
156    end do
157
158200   continue
159
160end subroutine calcmatrix
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG