*******************************************************************************
*   Include file for calculation of particle trajectories (Program FLEXPART)   *
*        This file contains the parameter statements used in FLEXPART          *
*                                                                              *
*        Author: A. Stohl                                                      *
*                                                                              *
*        1997                                                                  *
*                                                                              *
*        Last update 10 August 2000                                            *
*                                                                              *
********************************************************************************

      implicit none


************************************************************
C Number of directories/files used for FLEXPART input/output
************************************************************

      integer numpath
      parameter(numpath=4)

C numpath                 Number of different pathnames for input/output files


******************************
C Physical and other constants
******************************

      real pi,pi180,r_air,r_earth,ga,cpa,kappa,vonkarman
      parameter(pi=3.14159265,r_earth=6.371e6,r_air=287.05,ga=9.81)
      parameter(cpa=1004.6,kappa=0.286,pi180=pi/180.,vonkarman=0.4)

C pi                      number "pi"
C pi180                   pi/180.
C r_earth                 radius of earth [m]
C r_air                   individual gas constant for dry air [J/kg/K]
C ga                      gravity acceleration of earth [m/s**2]
C cpa                     specific heat for dry air
C kappa                   exponent of formula for potential temperature
C vonkarman               von Karman constant

      real karman,href,convke,hmixmin,hmixmax,turbmesoscale
      real d_trop,d_strat
      parameter(karman=0.40,href=15.,convke=2.0)
      parameter(hmixmin=100.,hmixmax=4500.,turbmesoscale=0.16)
      parameter(d_trop=50.,d_strat=0.1)

C karman                  Karman's constant
C href [m]                Reference height for dry deposition
C konvke                  Relative share of kinetic energy used for parcel lifting
C hmixmin,hmixmax         Minimum and maximum allowed PBL height
C turbmesoscale           the factor by which standard deviations of winds at grid
C                         points surrounding the particle positions are scaled to
C                         yield the scales for the mesoscale wind velocity fluctuations  
C d_trop [m2/s]           Turbulent diffusivity for horizontal components in the troposphere
C d_strat [m2/s]          Turbulent diffusivity for vertical component in the stratosphere

      real xmwml
      parameter(xmwml=18.016/28.960)

C xmwml   ratio of molar weights of water vapor and dry air
*****************************************************
C Constants related to the stratospheric ozone tracer
*****************************************************

      real ozonescale,pvcrit
      parameter(ozonescale=60.,pvcrit=2.0)

C ozonescale              ppbv O3 per PV unit
C pvcrit                  PV level of the tropopause



*********************
C Some time constants
*********************

      integer idiffnorm,idiffmax,minstep
      parameter(idiffnorm=10800,idiffmax=2*idiffnorm,minstep=1)

C idiffnorm [s]           normal time interval between two wind fields
C idiffmax [s]            maximum time interval between two wind fields
C minstep [s]             minimum time step to be used within FLEXPART


******************************************************************
C Parameters for polar stereographic projection close to the poles
******************************************************************

      real switchnorth,switchsouth
      parameter(switchnorth=75.,switchsouth=-75.)

C switchnorth    use polar stereographic grid north of switchnorth
C switchsouth    use polar stereographic grid south of switchsouth


**********************************************
C Maximum dimensions of the input mother grids
**********************************************

      integer nxmax,nymax,nuvzmax,nwzmax,nzmax,nxshift
      parameter(nxmax=361,nymax=181,nuvzmax=92,nwzmax=92,nzmax=92)
c     parameter(nxmax=361,nymax=181,nuvzmax=61,nwzmax=61,nzmax=61)
c     parameter(nxmax=721,nymax=361,nuvzmax=27,nwzmax=27,nzmax=27)
      parameter(nxshift=359)
c     parameter(nxshift=0)
      integer nconvlevmax,na 
      parameter (nconvlevmax = nuvzmax-1)
      parameter (na = nconvlevmax+1)


C nxmax,nymax             maximum dimension of wind fields in x and y
C                         direction, respectively
C nuvzmax,nwzmax          maximum dimension of (u,v) and (w) wind fields in z
C                         direction (for fields on eta levels)
C nzmax                   maximum dimension of wind fields in z direction
C                         for the transformed Cartesian coordinates
C nxshift                 for global grids (in x), the grid can be shifted by
C                         nxshift grid points, in order to accomodate nested
C                         grids, and output grids overlapping the domain "boundary"
C                         nxshift must not be negative; "normal" setting would be 0
C ntracermax              maximum number of tracer species in convection
C nconvlevmax             maximum number of levels for convection
C na                      parameter used in Emanuel's convect subroutine


**********************************************
C Maximum dimensions of the nested input grids
**********************************************

      integer maxnests,nxmaxn,nymaxn
      parameter(maxnests=1,nxmaxn=1,nymaxn=1)
c     parameter(maxnests=1,nxmaxn=226,nymaxn=126)

C maxnests                maximum number of nested grids
C nxmaxn,nymaxn           maximum dimension of nested wind fields in
C                         x and y direction, respectively


**********************************
C Parmaters for GRIB file decoding
**********************************

      integer jpack,jpunp
      parameter(jpack=4*nxmax*nymax,jpunp=4*jpack)

C jpack,jpunp             maximum dimensions needed for GRIB file decoding


***************************************
C Maximum dimensions of the output grid
***************************************

      integer nclassunc,maxageclass
c     parameter(maxageclass=1,maxzgrid=10,nclassunc=1)
      parameter(maxageclass=1,nclassunc=1)

C nclassunc               number of classes used to calculate the uncertainty
C                         of the output
C maxageclass             maximum number of age classes used for output

C Sabine Eckhardt, June, 2008
C the dimensions of the OUTGRID are now set dynamically during runtime
C maxxgrid,maxygrid,maxzgrid    maximum dimensions in x,y,z direction
C maxxgridn,maxygridn           maximum dimension of the nested grid
c     integer maxxgrid,maxygrid,maxzgrid,maxxgridn,maxygridn
c     parameter(maxxgrid=361,maxygrid=181,maxxgridn=0,maxygridn=0)

      integer maxreceptor
      parameter(maxreceptor=200)

C maxreceptor             maximum number of receptor points


***************************************************
C Maximum number of particles, species, and similar
***************************************************

      integer maxpart,maxspec
      parameter(maxpart=1000000)
      parameter(maxspec=5)


C maxpart                 Maximum number of particles
C maxspec                 Maximum number of chemical species per release

C maxpoint is also set dynamically during runtime
C maxpoint                Maximum number of release locations

C ---------
C Sabine Eckhardt: change of landuse inventary numclass=13
C ---------
      integer maxwf,maxtable,numclass,ni
      parameter(maxwf=50000,maxtable=1000,numclass=13,ni=11)

C maxwf                   maximum number of wind fields to be used for simulation
C maxtable                Maximum number of chemical species that can be
C                         tabulated for FLEXPART
C numclass                Number of landuse classes available to FLEXPART
C ni                      Number of diameter classes of particles

***************************************************************************
C dimension of the OH field
***************************************************************************
      integer maxxOH,maxyOH,maxzOH
      parameter(maxxOH=72,maxyOH=46,maxzOH=7)

***************************************************************************
C Maximum number of particles to be released in a single atmospheric column
C for the domain-filling trajectories option
***************************************************************************

      integer maxcolumn
      parameter(maxcolumn=3000)


**********************************
C Dimension of random number field
**********************************

      integer maxrand
      parameter(maxrand=2000000)

C maxrand                 number of random numbers used


******************************************************
C Number of clusters to be used for plume trajectories
******************************************************

      integer ncluster
      parameter(ncluster=5)

*************************************
C Unit numbers for input/output files
*************************************

      integer unitpath,unitcommand,unitageclasses,unitgrid,unitavailab
      integer unitreleases,unitoutrecept,unitoutreceptppt
      integer unitvert,unitoro,unitlsm,unitreceptor,unitouttraj
      integer unitpoin,unitoutgrid,unitoutgridppt,unitoutinfo
      integer unitspecies,unitland,unitsurfdata,unitwesely,unitOH
      integer unitpartout,unitpartin,unitflux,unitdates,unitheader
      integer unitshortpart,unitboundcond
      parameter(unitpath=1,unitcommand=1,unitageclasses=1,unitgrid=1)
      parameter(unitavailab=1,unitreleases=88,unitpartout=93)
      parameter(unitpartin=93,unitflux=98,unitouttraj=96)
      parameter(unitvert=1,unitoro=1,unitpoin=1,unitreceptor=1)
      parameter(unitoutgrid=97,unitoutgridppt=99,unitoutinfo=1)
      parameter(unitspecies=1,unitoutrecept=91,unitoutreceptppt=92)
      parameter(unitlsm=1,unitsurfdata=1,unitland=1,unitwesely=1)
      parameter(unitOH=1)
      parameter(unitdates=94,unitheader=90,unitshortpart=95)
      parameter(unitboundcond=89)

