Changeset f251e57 in flexpart.git


Ignore:
Timestamp:
Jun 25, 2018, 7:44:14 PM (6 years ago)
Author:
pesei <petra seibert at univie ac at>
Branches:
univie
Children:
c0884a8
Parents:
8b3d324
Message:

fix ticket:140 (ref position for vert. grid) in verttransform_gfs, minor changes in both verttransforms

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/changelog.txt

    r1a8fbee rf251e57  
    50507) Bring some more code under the IF (INIT) block
    51518) make some annotations
     52   [minor modification PS 2018-06-25]
    5253
    5354* com_mod.f90  PS 2018-06-13
     
    63643) Change name of loops to represent the index
    64654) make some annotations
     66
     67* verttransform_ecmwf.f90 PS 2018-06-25
     68  ===================
     69
     701) Some code layout improvement in the first part
     712) Fix ticket:140 Introduce a new way of establishing the reference position
     72   for the vertical grid. Also correct a minor bug in the calculation
     73   of height (array assignment where it was not intended)
     743) Add back the SAVE attribute to INIT, just to be sure
  • src/verttransform_ecmwf.f90

    r8b3d324 rf251e57  
    157157
    158158    if (ioldref .eq. 0) then ! old reference grid point
    159        do jy=0,nymin1
    160          do ix=0,nxmin1
    161            if (ps(ix,jy,1,n).gt.1000.e2) then
    162              ixref=ix
    163              jyref=jy
    164              goto 3
    165            endif
    166          end do
    167        end do
     159      do jy=0,nymin1
     160        do ix=0,nxmin1
     161          if (ps(ix,jy,1,n).gt.1000.e2) then
     162            ixref=ix
     163            jyref=jy
     164            goto 3
     165          endif
     166        end do
     167      end do
    1681683     continue
    169169
     
    175175
    176176      psmean = sum( ps(:,:,1,n) ) / (nx*ny)
    177       print*,'height: fg psmean',psmean
     177!      print*,'height: fg psmean',psmean
    178178      psstd = sqrt(sum( (ps(:,:,1,n) - psmean)**2 ) / (nx*ny))
    179179
     
    201201
    202202      pintref = akz(kz)+bkz(kz)*ps(ixref,jyref,1,n)
    203       tv = tth(ixref,jyref,kz,n)*(1.+0.608*qvh(ixref,jyref,kz,n))
     203      tv(ixref,jyref) = tth(ixref,jyref,kz,n)*(1.+0.608*qvh(ixref,jyref,kz,n))
    204204
    205205      if (abs(tv(ixref,jyref)-tvoldref) .gt. 0.2) then
     
    214214      tvoldref = tv(ixref,jyref)
    215215      poldref = pintref
    216       print*,'height=',kz,height(kz),tvoldref,poldref
     216!      print*,'height=',kz,height(kz),tvoldref,poldref
    217217
    218218    end do
  • src/verttransform_gfs.f90

    r6ecb30a rf251e57  
    2121
    2222subroutine verttransform_gfs(n,uuh,vvh,wwh,pvh)
    23   !                      i  i   i   i   i
    24   !*****************************************************************************
    25   !                                                                            *
    26   !     This subroutine transforms temperature, dew point temperature and      *
    27   !     wind components from eta to meter coordinates.                         *
    28   !     The vertical wind component is transformed from Pa/s to m/s using      *
    29   !     the conversion factor pinmconv.                                        *
    30   !     In addition, this routine calculates vertical density gradients        *
    31   !     needed for the parameterization of the turbulent velocities.           *
    32   !                                                                            *
    33   !     Author: A. Stohl, G. Wotawa                                            *
    34   !                                                                            *
    35   !     12 August 1996                                                         *
    36   !     Update: 16 January 1998                                                *
    37   !                                                                            *
    38   !     Major update: 17 February 1999                                         *
    39   !     by G. Wotawa                                                           *
    40   !     CHANGE 17/11/2005 Caroline Forster, NCEP GFS version                   *
    41   !                                                                            *
    42   !   - Vertical levels for u, v and w are put together                        *
    43   !   - Slope correction for vertical velocity: Modification of calculation    *
    44   !     procedure                                                              *
    45   !                                                                            *
    46   !*****************************************************************************
    47   !  Changes, Bernd C. Krueger, Feb. 2001:
    48   !   Variables tth and qvh (on eta coordinates) from common block
    49   !
    50   !   Unified ECMWF and GFS builds                                     
    51   !   Marian Harustak, 12.5.2017                                       
    52   !     - Renamed routine from verttransform to verttransform_gfs
    53   !
    54   !*****************************************************************************
    55   !                                                                            *
    56   ! Variables:                                                                 *
    57   ! nx,ny,nz                        field dimensions in x,y and z direction    *
    58   ! uu(0:nxmax,0:nymax,nzmax,2)     wind components in x-direction [m/s]       *
    59   ! vv(0:nxmax,0:nymax,nzmax,2)     wind components in y-direction [m/s]       *
    60   ! ww(0:nxmax,0:nymax,nzmax,2)     wind components in z-direction [deltaeta/s]*
    61   ! tt(0:nxmax,0:nymax,nzmax,2)     temperature [K]                            *
    62   ! pv(0:nxmax,0:nymax,nzmax,2)     potential voriticity (pvu)                 *
    63   ! ps(0:nxmax,0:nymax,2)           surface pressure [Pa]                      *
    64   ! clouds(0:nxmax,0:nymax,0:nzmax,2) cloud field for wet deposition           *
    65   !                                                                            *
    66   !*****************************************************************************
     23!                      i  i   i   i   i
     24!*****************************************************************************
     25!                                                                            *
     26!     This subroutine transforms temperature, dew point temperature and      *
     27!     wind components from eta to meter coordinates.                         *
     28!     The vertical wind component is transformed from Pa/s to m/s using      *
     29!     the conversion factor pinmconv.                                        *
     30!     In addition, this routine calculates vertical density gradients        *
     31!     needed for the parameterization of the turbulent velocities.           *
     32!                                                                            *
     33!     Author: A. Stohl, G. Wotawa                                            *
     34!                                                                            *
     35!     12 August 1996                                                         *
     36!     Update: 16 January 1998                                                *
     37!                                                                            *
     38!     Major update: 17 February 1999                                         *
     39!     by G. Wotawa                                                           *
     40!     CHANGE 17/11/2005 Caroline Forster, NCEP GFS version                   *
     41!                                                                            *
     42!   - Vertical levels for u, v and w are put together                        *
     43!   - Slope correction for vertical velocity: Modification of calculation    *
     44!     procedure                                                              *
     45!                                                                            *
     46!*****************************************************************************
     47!  Changes, Bernd C. Krueger, Feb. 2001:
     48!    Variables tth and qvh (on eta coordinates) from common block
     49!
     50!   Unified ECMWF and GFS builds                                     
     51!   Marian Harustak, 12.5.2017                                       
     52!     - Renamed from verttransform to verttransform_ecmwf
     53!
     54!  undocumented modifications by NILU for v10                                *
     55!                                                                            *
     56!  Petra Seibert, 2018-06-13:                                                *
     57!   - fix bug of ticket:140 (find reference position for vertical grid)      *
     58!   - put back SAVE attribute for INIT, just to be safe                      *
     59!   - minor changes, most of them just cosmetics                             *
     60!   for details see changelog.txt                                            *
     61!                                                                            *
     62!*****************************************************************************
     63!                                                                            *
     64! Variables:                                                                 *
     65! nx,ny,nz                        field dimensions in x,y and z direction    *
     66! uu(0:nxmax,0:nymax,nzmax,2)     wind components in x-direction [m/s]       *
     67! vv(0:nxmax,0:nymax,nzmax,2)     wind components in y-direction [m/s]       *
     68! ww(0:nxmax,0:nymax,nzmax,2)     wind components in z-direction [deltaeta/s]*
     69! tt(0:nxmax,0:nymax,nzmax,2)     temperature [K]                            *
     70! pv(0:nxmax,0:nymax,nzmax,2)     potential voriticity (pvu)                 *
     71! ps(0:nxmax,0:nymax,2)           surface pressure [Pa]                      *
     72! clouds(0:nxmax,0:nymax,0:nzmax,2) cloud field for wet deposition           *
     73!                                                                            *
     74!*****************************************************************************
    6775
    6876  use par_mod
     
    7280  implicit none
    7381
    74   integer :: ix,jy,kz,iz,n,kmin,kl,klp,ix1,jy1,ixp,jyp,ixm,jym
     82  integer :: ix,jy,kz,iz,n,kmin,kl,klp,ix1,jy1,ixp,jyp
    7583  integer :: rain_cloud_above,kz_inv
    7684  real :: f_qvsat,pressure
     
    7886  real :: rhoh(nuvzmax),pinmconv(nzmax)
    7987  real :: ew,pint,tv,tvold,pold,dz1,dz2,dz,ui,vi
     88
     89!>   for reference profile (PS) 
     90  real ::  tvoldref, poldref, pintref, psmean, psstd
     91  integer :: ixyref(2), ixref,jyref
     92  integer, parameter :: ioldref = 1 ! PS 2018-06-13: set to 0 if you
     93!!   want old method of searching reference location for the vertical grid
     94!!   1 for new method (options for other methods 2,... in the future)
     95
    8096  real :: xlon,ylat,xlonr,dzdx,dzdy
    8197  real :: dzdx1,dzdx2,dzdy1,dzdy2,cosf
     
    88104  real,parameter :: const=r_air/ga
    89105
    90   ! NCEP version
     106  logical, save :: init = .true. ! PS 2018-06-13: add back save attribute
     107
     108!> GFS version
    91109  integer :: llev, i
    92110
    93   logical :: init = .true.
    94 
    95 
    96   !*************************************************************************
    97   ! If verttransform is called the first time, initialize heights of the   *
    98   ! z levels in meter. The heights are the heights of model levels, where  *
    99   ! u,v,T and qv are given.                                                *
    100   !*************************************************************************
     111
     112
     113!*************************************************************************
     114! If verttransform is called the first time, initialize heights of the   *
     115! z levels in meter. The heights are the heights of model levels, where  *
     116! u,v,T and qv are given.                                                *
     117!*************************************************************************
    101118
    102119  if (init) then
    103120
    104   ! Search for a point with high surface pressure (i.e. not above significant topography)
    105   ! Then, use this point to construct a reference z profile, to be used at all times
    106   !*****************************************************************************
    107 
    108     do jy=0,nymin1
    109       do ix=0,nxmin1
    110         if (ps(ix,jy,1,n).gt.100000.) then
    111           ixm=ix
    112           jym=jy
     121! Search for a point with high surface pressure (i.e. not above significant topography)
     122! Then, use this point to construct a reference z profile, to be used at all times
     123!*****************************************************************************
     124
     125    if (ioldref .eq. 0) then ! old reference grid point
     126      do jy=0,nymin1
     127        do ix=0,nxmin1
     128          if (ps(ix,jy,1,n).gt.1000.e2) then
     129            ixref=ix
     130            jyref=jy
    113131          goto 3
    114132        endif
     
    116134    end do
    1171353   continue
    118 
    119 
    120     tvold=tt2(ixm,jym,1,n)*(1.+0.378*ew(td2(ixm,jym,1,n))/ &
    121     ps(ixm,jym,1,n))
    122     pold=ps(ixm,jym,1,n)
     136!      print*,'oldheights at' ,ixref,jyref,ps(ixref,jyref,1,n)
     137    else ! new reference grid point
     138!     PS: the old version fails if the pressure is <=1000 hPa in the whole
     139!     domain. Let us find a good replacement, not just a quick fix.
     140!     Search point near to mean pressure after excluding mountains
     141
     142      psmean = sum( ps(:,:,1,n) ) / (nx*ny)
     143!      print*,'height: fg psmean',psmean
     144      psstd = sqrt(sum( (ps(:,:,1,n) - psmean)**2 ) / (nx*ny))
     145
     146!>    new psmean using only points within $\plusminus\sigma$ 
     147!      psmean = sum( ps(:,:,1,n), abs(ps(:,:,1,n)-psmean) < psstd ) / &
     148!        count(abs(ps(:,:,1,n)-psmean) < psstd)
     149
     150!>    new psmean using only points with $p\gt \overbar{p}+\sigma_p$ 
     151!>    (reject mountains, accept valleys)
     152      psmean = sum( ps(:,:,1,n), ps(:,:,1,n) > psmean - psstd ) / &
     153        count(ps(:,:,1,n) > psmean - psstd)
     154!      print*,'height: std, new psmean',psstd,psmean
     155      ixyref = minloc( abs( ps(:,:,1,n) - psmean ) )
     156      ixref = ixyref(1)
     157      jyref = ixyref(2)
     158!      print*,'newheights at' ,ixref,jyref,ps(ixref,jyref,1,n)
     159    endif 
     160
     161    tvoldref=tt2(ixref,jyref,1,n)* &
     162      ( 1. + 0.378*ew(td2(ixref,jyref,1,n) ) / ps(ixref,jyref,1,n))
     163    poldref=ps(ixref,jyref,1,n)
    123164    height(1)=0.
     165    kz=1
     166!    print*,'height=',kz,height(kz),tvoldref,poldref
    124167
    125168    do kz=2,nuvz
    126       pint=akz(kz)+bkz(kz)*ps(ixm,jym,1,n)
    127       tv=tth(ixm,jym,kz,n)*(1.+0.608*qvh(ixm,jym,kz,n))
    128 
    129       if (abs(tv-tvold).gt.0.2) then
    130         height(kz)=height(kz-1)+const*log(pold/pint)* &
    131         (tv-tvold)/log(tv/tvold)
     169     
     170      pintref = akz(kz)
     171      ! Note that for GFS data, the akz variable contains the input level
     172      ! pressure values. bkz is zero (I removed all terms with bkz that
     173      ! were erroneously copied from verttransform_ecmwf). [PS, June 2018]
     174       
     175      tv = tth(ixref,jyref,kz,n)*(1.+0.608*qvh(ixref,jyref,kz,n))
     176
     177      if (abs(tv-tvoldref) .gt. 0.2) then
     178        height(kz)=height(kz-1) + &
     179          const * log(poldref/pintref) * (tv-tvoldref) / log(tv/tvoldref)
    132180      else
    133         height(kz)=height(kz-1)+const*log(pold/pint)*tv
     181        height(kz) = height(kz-1) + const*log(poldref/pintref)*tv
    134182      endif
    135183
    136       tvold=tv
    137       pold=pint
    138     end do
    139 
    140 
    141   ! Determine highest levels that can be within PBL
    142   !************************************************
     184      tvoldref=tv
     185      poldref=pintref
     186!      print*,'height=',kz,height(kz),tvoldref,poldref
     187    end do
     188
     189
     190! Determine highest levels that can be within PBL
     191!************************************************
    143192
    144193    do kz=1,nz
     
    1501999   continue
    151200
    152   ! Do not repeat initialization of the Cartesian z grid
    153   !*****************************************************
     201! Do not repeat initialization of the Cartesian z grid
     202!*****************************************************
    154203
    155204    init=.false.
    156205
    157   endif
    158 
    159 
    160   ! Loop over the whole grid
    161   !*************************
     206  endif ! init block (vertical grid construction)
     207
     208
     209! Loop over the whole grid
     210!*************************
    162211
    163212  do jy=0,nymin1
    164213    do ix=0,nxmin1
    165214
    166   ! NCEP version: find first level above ground
     215! NCEP version: find first level above ground
    167216      llev = 0
    168217      do i=1,nuvz
     
    171220       llev = llev+1
    172221       if (llev.gt.nuvz-2) llev = nuvz-2
    173   !     if (llev.eq.nuvz-2) write(*,*) 'verttransform
    174   !    +WARNING: LLEV eq NUZV-2'
    175   ! NCEP version
    176 
    177 
    178   ! compute height of pressure levels above ground
    179   !***********************************************
     222!     if (llev.eq.nuvz-2) write(*,*) 'verttransform
     223!    +WARNING: LLEV eq NUZV-2'
     224! NCEP version
     225
     226
     227! compute height of pressure levels above ground
     228!***********************************************
    180229
    181230      tvold=tth(ix,jy,llev,n)*(1.+0.608*qvh(ix,jy,llev,n))
     
    202251      end do
    203252
    204   ! pinmconv=(h2-h1)/(p2-p1)
     253! pinmconv=(h2-h1)/(p2-p1)
    205254
    206255      pinmconv(llev)=(uvwzlev(ix,jy,llev+1)-uvwzlev(ix,jy,llev))/ &
     
    217266
    218267
    219   ! Levels, where u,v,t and q are given
    220   !************************************
     268! Levels, where u,v,t and q are given
     269!************************************
    221270
    222271      uu(ix,jy,1,n)=uuh(ix,jy,llev)
     
    267316
    268317
    269   ! Levels, where w is given
    270   !*************************
     318! Levels, where w is given
     319!*************************
    271320
    272321      ww(ix,jy,1,n)=wwh(ix,jy,llev)*pinmconv(llev)
     
    287336
    288337
    289   ! Compute density gradients at intermediate levels
    290   !*************************************************
     338! Compute density gradients at intermediate levels
     339!*************************************************
    291340
    292341      drhodz(ix,jy,1,n)=(rho(ix,jy,2,n)-rho(ix,jy,1,n))/ &
     
    302351
    303352
    304   !****************************************************************
    305   ! Compute slope of eta levels in windward direction and resulting
    306   ! vertical wind correction
    307   !****************************************************************
     353!****************************************************************
     354! Compute slope of eta levels in windward direction and resulting
     355! vertical wind correction
     356!****************************************************************
    308357
    309358  do jy=1,ny-2
     
    311360    do ix=1,nx-2
    312361
    313   ! NCEP version: find first level above ground
     362! NCEP version: find first level above ground
    314363      llev = 0
    315364      do i=1,nuvz
     
    318367       llev = llev+1
    319368       if (llev.gt.nuvz-2) llev = nuvz-2
    320   !     if (llev.eq.nuvz-2) write(*,*) 'verttransform
    321   !    +WARNING: LLEV eq NUZV-2'
    322   ! NCEP version
     369!     if (llev.eq.nuvz-2) write(*,*) 'verttransform
     370!    +WARNING: LLEV eq NUZV-2'
     371! NCEP version
    323372
    324373      kmin=llev+1
     
    361410
    362411
    363   ! If north pole is in the domain, calculate wind velocities in polar
    364   ! stereographic coordinates
    365   !*******************************************************************
     412! If north pole is in the domain, calculate wind velocities in polar
     413! stereographic coordinates
     414!*******************************************************************
    366415
    367416  if (nglobal) then
     
    381430    do iz=1,nz
    382431
    383   ! CALCULATE FFPOL, DDPOL FOR CENTRAL GRID POINT
     432! CALCULATE FFPOL, DDPOL FOR CENTRAL GRID POINT
    384433      xlon=xlon0+real(nx/2-1)*dx
    385434      xlonr=xlon*pi/180.
     
    396445      if(ddpol.gt.2.0*pi) ddpol=ddpol-2.0*pi
    397446
    398   ! CALCULATE U,V FOR 180 DEG, TRANSFORM TO POLAR STEREOGRAPHIC GRID
     447! CALCULATE U,V FOR 180 DEG, TRANSFORM TO POLAR STEREOGRAPHIC GRID
    399448      xlon=180.0
    400449      xlonr=xlon*pi/180.
     
    411460
    412461
    413   ! Fix: Set W at pole to the zonally averaged W of the next equator-
    414   ! ward parallel of latitude
     462! Fix: Set W at pole to the zonally averaged W of the next equator-
     463! ward parallel of latitude
    415464
    416465    do iz=1,nz
     
    430479
    431480
    432   ! If south pole is in the domain, calculate wind velocities in polar
    433   ! stereographic coordinates
    434   !*******************************************************************
     481! If south pole is in the domain, calculate wind velocities in polar
     482! stereographic coordinates
     483!*******************************************************************
    435484
    436485  if (sglobal) then
     
    448497    do iz=1,nz
    449498
    450   ! CALCULATE FFPOL, DDPOL FOR CENTRAL GRID POINT
     499! CALCULATE FFPOL, DDPOL FOR CENTRAL GRID POINT
    451500      xlon=xlon0+real(nx/2-1)*dx
    452501      xlonr=xlon*pi/180.
     
    462511      if(ddpol.gt.2.0*pi) ddpol=ddpol-2.0*pi
    463512
    464   ! CALCULATE U,V FOR 180 DEG, TRANSFORM TO POLAR STEREOGRAPHIC GRID
     513! CALCULATE U,V FOR 180 DEG, TRANSFORM TO POLAR STEREOGRAPHIC GRID
    465514      xlon=180.0
    466515      xlonr=xlon*pi/180.
     
    478527
    479528
    480   ! Fix: Set W at pole to the zonally averaged W of the next equator-
    481   ! ward parallel of latitude
     529! Fix: Set W at pole to the zonally averaged W of the next equator-
     530! ward parallel of latitude
    482531
    483532    do iz=1,nz
     
    496545
    497546
    498   !   write (*,*) 'initializing clouds, n:',n,nymin1,nxmin1,nz
    499   !   create a cloud and rainout/washout field, clouds occur where rh>80%
    500   !   total cloudheight is stored at level 0
     547!   write (*,*) 'initializing clouds, n:',n,nymin1,nxmin1,nz
     548!   create a cloud and rainout/washout field, clouds occur where rh>80%
     549!   total cloudheight is stored at level 0
    501550  do jy=0,nymin1
    502551    do ix=0,nxmin1
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG