Changeset 5844866 in flexpart.git


Ignore:
Timestamp:
Oct 12, 2016, 1:14:19 PM (8 years ago)
Author:
Sabine <sabine.eckhardt@…>
Branches:
master, 10.4.1_pesei, GFS_025, bugfixes+enhancements, dev, release-10, release-10.4.1, scaling-bug, univie
Children:
df4a68e
Parents:
0581cac
Message:

first working version with backward deposition

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/advance.f90

    ra652cd5 r5844866  
    569569               prob(ks)=1.+(prob(ks)-1.)* &
    570570                    exp(-vdepo(ks)*abs(dt)/(2.*href))
     571!              write(*,*) 'Prob calc: ',zt,href,prob(ks)
    571572          endif
    572573        end do
  • src/advance_rec.f90

    rdced13c r5844866  
    2020!**********************************************************************
    2121
    22 subroutine advance_rec(itime,nrelpoint,ldt,up,vp,wp, &
    23        usigold,vsigold,wsigold,nstop,xt,yt,zt,prob,icbt)
    24   !                     i    i  i/oi/oi/o
    25   !  i/o     i/o     i/o     o  i/oi/oi/o i/o  i/o
     22subroutine advance_rec(itime,xt,yt,zt,prob)
     23  !                    i     i  i  i  o
    2624  !*****************************************************************************
    2725  !                                                                            *
     
    6664  !                                                                            *
    6765  ! Variables:                                                                 *
    68   ! icbt               1 if particle not transferred to forbidden state,       *
    69   !                    else -1                                                 *
    70   ! dawsave            accumulated displacement in along-wind direction        *
    71   ! dcwsave            accumulated displacement in cross-wind direction        *
    72   ! dxsave             accumulated displacement in longitude                   *
    73   ! dysave             accumulated displacement in latitude                    *
    74   ! h [m]              Mixing height                                           *
    75   ! lwindinterv [s]    time interval between two wind fields                   *
    7666  ! itime [s]          time at which this subroutine is entered                *
    7767  ! itimec [s]         actual time, which is incremented in this subroutine    *
    7868  ! href [m]           height for which dry deposition velocity is calculated  *
    79   ! ladvance [s]       Total integration time period                           *
    8069  ! ldirect            1 forward, -1 backward                                  *
    8170  ! ldt [s]            Time step for the next integration                      *
    8271  ! lsynctime [s]      Synchronisation interval of FLEXPART                    *
    8372  ! ngrid              index which grid is to be used                          *
    84   ! nrand              index for a variable to be picked from rannumb          *
    85   ! nstop              if > 1 particle has left domain and must be stopped     *
    8673  ! prob               probability of absorption due to dry deposition         *
    87   ! rannumb(maxrand)   normally distributed random variables                   *
    88   ! rhoa               air density                                             *
    89   ! rhograd            vertical gradient of the air density                    *
    90   ! up,vp,wp           random velocities due to turbulence (along wind, cross  *
    91   !                    wind, vertical wind                                     *
    92   ! usig,vsig,wsig     mesoscale wind fluctuations                             *
    93   ! usigold,vsigold,wsigold  like usig, etc., but for the last time step       *
    9474  ! vdepo              Deposition velocities for all species                   *
    9575  ! xt,yt,zt           Particle position                                       *
     
    10181  use com_mod
    10282  use interpol_mod
    103   use hanna_mod
    104   use cmapf_mod
    105   use random_mod, only: ran3
    10683
    10784  implicit none
    10885
    10986  real(kind=dp) :: xt,yt
    110   real :: zt,xts,yts,weight
    111   integer :: itime,itimec,nstop,ldt,i,j,k,nrand,loop,memindnext,mind
    112   integer :: ngr,nix,njy,ks,nsp,nrelpoint
    113   real :: dz,dz1,dz2,xlon,ylat,xpol,ypol,gridsize
    114   real :: ru,rv,rw,dt,ux,vy,cosfact,xtn,ytn,tropop
    115   real :: prob(maxspec),up,vp,wp,dxsave,dysave,dawsave
    116   real :: dcwsave
    117   real :: usigold,vsigold,wsigold,r,rs
    118   real :: uold,vold,wold,vdepo(maxspec)
    119   !real uprof(nzmax),vprof(nzmax),wprof(nzmax)
    120   !real usigprof(nzmax),vsigprof(nzmax),wsigprof(nzmax)
    121   !real rhoprof(nzmax),rhogradprof(nzmax)
    122   real :: rhoa,rhograd,delz,dtf,rhoaux,dtftlw,uxscale,wpscale
    123   integer(kind=2) :: icbt
    124   real,parameter :: eps=nxmax/3.e5,eps2=1.e-9
    125   real :: ptot_lhh,Q_lhh,phi_lhh,ath,bth !modified by mc
    126   real :: old_wp_buf,dcas,dcas1,del_test !added by mc
    127   integer :: i_well,jj,flagrein !test well mixed: modified by mc
    128 
    129 
    130   integer :: idummy = -7
    131   real    :: settling = 0.
    132 
    133 
    134   nstop=0
    135   do i=1,nmixz
    136     indzindicator(i)=.true.
    137   end do
    138 
     87  real :: zt,xtn,ytn
     88  integer :: itime,i,j,k,memindnext
     89  integer :: nix,njy,ks
     90  real :: prob(maxspec),vdepo(maxspec)
     91  real,parameter :: eps=nxmax/3.e5
    13992
    14093  if (DRYDEP) then    ! reset probability for deposition
     
    14497    end do
    14598  endif
    146 
    147   dxsave=0.           ! reset position displacements
    148   dysave=0.           ! due to mean wind
    149   dawsave=0.          ! and turbulent wind
    150   dcwsave=0.
    151 
    152   itimec=itime
    153 
    154   nrand=int(ran3(idummy)*real(maxrand-1))+1
    15599
    156100
     
    207151
    208152
    209   ! Compute maximum mixing height around particle position
    210   !*******************************************************
    211 
    212   h=0.
    213   if (ngrid.le.0) then
    214     do k=1,2
    215       mind=memind(k) ! eso: compatibility with 3-field version
    216       do j=jy,jyp
    217         do i=ix,ixp
    218           if (hmix(i,j,1,mind).gt.h) h=hmix(i,j,1,mind)
    219         end do
    220       end do
    221     end do
    222     tropop=tropopause(nix,njy,1,1)
    223   else
    224     do k=1,2
    225       mind=memind(k)
    226       do j=jy,jyp
    227         do i=ix,ixp
    228           if (hmixn(i,j,1,mind,ngrid).gt.h) h=hmixn(i,j,1,mind,ngrid)
    229         end do
    230       end do
    231     end do
    232     tropop=tropopausen(nix,njy,1,1,ngrid)
    233   endif
    234 
    235   zeta=zt/h
    236 
    237 
    238 
    239   !*************************************************************
    240   ! If particle is in the PBL, interpolate once and then make a
    241   ! time loop until end of interval is reached
    242   !*************************************************************
    243 
    244   if (zeta.le.1.) then
    245 
    246   ! BEGIN TIME LOOP
    247   !================
    248 
    249     loop=0
    250 100   loop=loop+1
    251       if (method.eq.1) then
    252         ldt=min(ldt,abs(lsynctime-itimec+itime))
    253         itimec=itimec+ldt*ldirect
    254       else
    255         ldt=abs(lsynctime)
    256         itimec=itime+lsynctime
    257       endif
    258       dt=real(ldt)
    259 
    260       zeta=zt/h
    261 
    262 
    263       if (loop.eq.1) then
    264         if (ngrid.le.0) then
    265           xts=real(xt)
    266           yts=real(yt)
    267           call interpol_all(itime,xts,yts,zt)
    268         else
    269           call interpol_all_nests(itime,xtn,ytn,zt)
    270         endif
    271 
    272       else
    273 
    274 
    275   ! Determine the level below the current position for u,v,rho
    276   !***********************************************************
    277 
    278         do i=2,nz
    279           if (height(i).gt.zt) then
    280             indz=i-1
    281             indzp=i
    282             goto 6
    283           endif
    284         end do
    285 6       continue
    286 
    287   ! If one of the levels necessary is not yet available,
    288   ! calculate it
    289   !*****************************************************
    290 
    291         do i=indz,indzp
    292           if (indzindicator(i)) then
    293             if (ngrid.le.0) then
    294               call interpol_misslev(i)
    295             else
    296               call interpol_misslev_nests(i)
    297             endif
    298           endif
    299         end do
    300       endif
    301 
    302 
    303   ! Vertical interpolation of u,v,w,rho and drhodz
    304   !***********************************************
    305 
    306   ! Vertical distance to the level below and above current position
    307   ! both in terms of (u,v) and (w) fields
    308   !****************************************************************
    309 
    310       dz=1./(height(indzp)-height(indz))
    311       dz1=(zt-height(indz))*dz
    312       dz2=(height(indzp)-zt)*dz
    313 
    314       u=dz1*uprof(indzp)+dz2*uprof(indz)
    315       v=dz1*vprof(indzp)+dz2*vprof(indz)
    316       w=dz1*wprof(indzp)+dz2*wprof(indz)
    317       rhoa=dz1*rhoprof(indzp)+dz2*rhoprof(indz)
    318       rhograd=dz1*rhogradprof(indzp)+dz2*rhogradprof(indz)
    319 
    320 
    321   ! Compute the turbulent disturbances
    322   ! Determine the sigmas and the timescales
    323   !****************************************
    324 
    325       if (turbswitch) then
    326         call hanna(zt)
    327       else
    328         call hanna1(zt)
    329       endif
    330 
    331 
    332   !*****************************************
    333   ! Determine the new diffusivity velocities
    334   !*****************************************
    335 
    336   ! Horizontal components
    337   !**********************
    338 
    339       if (nrand+1.gt.maxrand) nrand=1
    340       if (dt/tlu.lt..5) then
    341         up=(1.-dt/tlu)*up+rannumb(nrand)*sigu*sqrt(2.*dt/tlu)
    342       else
    343         ru=exp(-dt/tlu)
    344         up=ru*up+rannumb(nrand)*sigu*sqrt(1.-ru**2)
    345       endif
    346       if (dt/tlv.lt..5) then
    347         vp=(1.-dt/tlv)*vp+rannumb(nrand+1)*sigv*sqrt(2.*dt/tlv)
    348       else
    349         rv=exp(-dt/tlv)
    350         vp=rv*vp+rannumb(nrand+1)*sigv*sqrt(1.-rv**2)
    351       endif
    352       nrand=nrand+2
    353 
    354 
    355       if (nrand+ifine.gt.maxrand) nrand=1
    356       rhoaux=rhograd/rhoa
    357       dtf=dt*fine
    358 
    359       dtftlw=dtf/tlw
    360 
    361   ! Loop over ifine short time steps for vertical component
    362   !********************************************************
    363 
    364       do i=1,ifine
    365 
    366   ! Determine the drift velocity and density correction velocity
    367   !*************************************************************
    368 
    369         if (turbswitch) then
    370           if (dtftlw.lt..5) then
    371   !*************************************************************
    372   !************** CBL options added by mc see routine cblf90 ***
    373             if (cblflag.eq.1) then  !modified by mc
    374               if (-h/ol.gt.5) then  !modified by mc
    375               !if (ol.lt.0.) then   !modified by mc 
    376               !if (ol.gt.0.) then   !modified by mc : for test
    377                   !print  *,zt,wp,ath,bth,tlw,dtf,'prima'
    378                   flagrein=0
    379                   nrand=nrand+1
    380                   old_wp_buf=wp
    381                   call cbl(wp,zt,ust,wst,h,rhoa,rhograd,sigw,dsigwdz,tlw,ptot_lhh,Q_lhh,phi_lhh,ath,bth,ol,flagrein) !inside the routine for inverse time
    382                   wp=(wp+ath*dtf+bth*rannumb(nrand)*sqrt(dtf))*real(icbt)
    383                   ! wp=(wp+ath*dtf+bth*gasdev2(mydum)*sqrt(dtf))*real(icbt)
    384                   delz=wp*dtf
    385                   if (flagrein.eq.1) then
    386                       call re_initialize_particle(zt,ust,wst,h,sigw,old_wp_buf,nrand,ol)
    387                       wp=old_wp_buf
    388                       delz=wp*dtf
    389                       nan_count=nan_count+1
    390                   end if
    391                   !print  *,zt,wp,ath,bth,tlw,dtf,rannumb(nrand+i),icbt
    392                   !pause                 
    393               else
    394                   nrand=nrand+1
    395                   old_wp_buf=wp
    396                   ath=-wp/tlw+sigw*dsigwdz+wp*wp/sigw*dsigwdz+sigw*sigw/rhoa*rhograd  !1-note for inverse time should be -wp/tlw*ldirect+... calculated for wp=-wp
    397                                                                                       !2-but since ldirect =-1 for inverse time and this must be calculated for (-wp) and
    398                                                                                       !3-the gaussian pdf is symmetric (i.e. pdf(w)=pdf(-w) ldirect can be discarded
    399                   bth=sigw*rannumb(nrand)*sqrt(2.*dtftlw)
    400                   wp=(wp+ath*dtf+bth)*real(icbt) 
    401                   delz=wp*dtf
    402                   del_test=(1.-wp)/wp !catch infinity value
    403                   if (isnan(wp).or.isnan(del_test)) then
    404                       nrand=nrand+1                     
    405                       wp=sigw*rannumb(nrand)
    406                       delz=wp*dtf
    407                       nan_count2=nan_count2+1
    408                       !print *,'NaN coutner equal to:', nan_count,'reduce ifine if this number became a non-negligible fraction of the particle number'
    409                   end if 
    410               end if
    411   !******************** END CBL option *******************************           
    412   !*******************************************************************           
    413             else
    414                  wp=((1.-dtftlw)*wp+rannumb(nrand+i)*sqrt(2.*dtftlw) &
    415                  +dtf*(dsigwdz+rhoaux*sigw))*real(icbt)
    416                  delz=wp*sigw*dtf
    417             end if
    418           else
    419             rw=exp(-dtftlw)
    420             wp=(rw*wp+rannumb(nrand+i)*sqrt(1.-rw**2) &
    421                  +tlw*(1.-rw)*(dsigwdz+rhoaux*sigw))*real(icbt)
    422             delz=wp*sigw*dtf
    423           endif
    424          
    425         else
    426           rw=exp(-dtftlw)
    427           wp=(rw*wp+rannumb(nrand+i)*sqrt(1.-rw**2)*sigw &
    428                +tlw*(1.-rw)*(dsigw2dz+rhoaux*sigw**2))*real(icbt)
    429           delz=wp*dtf
    430         endif
    431 
    432   !****************************************************
    433   ! Compute turbulent vertical displacement of particle
    434   !****************************************************
    435 
    436         if (abs(delz).gt.h) delz=mod(delz,h)
    437 
    438   ! Determine if particle transfers to a "forbidden state" below the ground
    439   ! or above the mixing height
    440   !************************************************************************
    441 
    442         if (delz.lt.-zt) then         ! reflection at ground
    443           icbt=-1
    444           zt=-zt-delz
    445         else if (delz.gt.(h-zt)) then ! reflection at h
    446           icbt=-1
    447           zt=-zt-delz+2.*h
    448         else                         ! no reflection
    449           icbt=1
    450           zt=zt+delz
    451         endif
    452 
    453         if (i.ne.ifine) then
    454           zeta=zt/h
    455           call hanna_short(zt)
    456         endif
    457 
    458       end do
    459       if (cblflag.ne.1) nrand=nrand+i
    460 
    461   ! Determine time step for next integration
    462   !*****************************************
    463 
    464       if (turbswitch) then
    465         ldt=int(min(tlw,h/max(2.*abs(wp*sigw),1.e-5), &
    466              0.5/abs(dsigwdz))*ctl)
    467       else
    468         ldt=int(min(tlw,h/max(2.*abs(wp),1.e-5))*ctl)
    469       endif
    470       ldt=max(ldt,mintime)
    471 
    472153  ! Determine probability of deposition
    473154  !************************************
     
    487168  !   where f(n) is the exponential term
    488169               prob(ks)=1.+(prob(ks)-1.)* &
    489                     exp(-vdepo(ks)*abs(dt)/(2.*href))
     170                    exp(-vdepo(ks)*abs(ideltas)/(2.*href))
    490171          endif
    491172        end do
    492173      endif
    493174
    494   endif
    495175
    496176end subroutine advance_rec
  • src/interpol_vdep.f90

    re200b7a r5844866  
    5454
    5555  ! a) Bilinear horizontal interpolation
    56 
     56! write(*,*) 'interpol: ',dt1,dt2,dtt,lsynctime,ix,jy
    5757  do m=1,2
    5858    indexh=memind(m)
  • src/par_mod.f90

    r842074e r5844866  
    186186  !**************************************************
    187187
    188   integer,parameter :: maxpart=20000000
     188  integer,parameter :: maxpart=40000000
    189189  integer,parameter :: maxspec=2
    190190  real,parameter :: minmass=0.0001
  • src/releaseparticles.f90

    r54cbd6c r5844866  
    209209
    210210            ztra1(ipart)=zpoint1(i)+ran1(idummy)*zaux
    211 
    212211  ! Interpolation of topography and density
    213212  !****************************************
  • src/timemanager.f90

    r0581cac r5844866  
    107107  integer :: ix,jy,ldeltat,itage,nage
    108108  integer :: i_nan=0,ii_nan,total_nan_intl=0  !added by mc to check instability in CBL scheme
    109   real :: outnum,weight,prob(maxspec),decfact
     109  real :: outnum,weight,prob_rec(maxspec),prob(maxspec),decfact
    110110  ! real :: uap(maxpart),ucp(maxpart),uzp(maxpart)
    111111  ! real :: us(maxpart),vs(maxpart),ws(maxpart)
     
    552552      do ks=1,nspec
    553553         if  ((xscav_frac1(j,ks).lt.0)) then
    554          call advance_rec(itime,npoint(j),idt(j),uap(j),ucp(j),uzp(j), &
    555             us(j),vs(j),ws(j),nstop,xtra1(j),ytra1(j),ztra1(j),prob, &
    556             cbt(j))
     554         call advance_rec(itime,xtra1(j),ytra1(j),ztra1(j),prob_rec)
    557555            if (decay(ks).gt.0.) then             ! radioactive decay
    558556                decfact=exp(-real(abs(lsynctime))*decay(ks))
     
    561559            endif
    562560            if (DRYDEPSPEC(ks)) then        ! dry deposition
    563                drydeposit(ks)=xmass1(j,ks)*prob(ks)*decfact
     561               drydeposit(ks)=xmass1(j,ks)*prob_rec(ks)*decfact
    564562               xscav_frac1(j,ks)=xscav_frac1(j,ks)*(-1.)* &
    565563               drydeposit(ks)/xmass1(j,ks)
     564!               write (*,*) 'notance: ',prob(ks),xmass1(j,ks),ztra1(j)
    566565               if (decay(ks).gt.0.) then   ! correct for decay (see wetdepo)
    567566                  drydeposit(ks)=drydeposit(ks)* &
     
    572571                xscav_frac1(j,ks)=0.
    573572             endif
     573!         write (*,*) 'xscav: ',j,ks,xscav_frac1(j,ks)
    574574         endif
    575575       enddo
     
    600600            us(j),vs(j),ws(j),nstop,xtra1(j),ytra1(j),ztra1(j),prob, &
    601601            cbt(j))
     602!        write (*,*) 'advance: ',prob(1),xmass1(j,1),ztra1(j)
    602603
    603604  ! Calculate the gross fluxes across layer interfaces
  • src/wetdepo.f90

    r54cbd6c r5844866  
    2020!**********************************************************************
    2121
    22 subroutine wetdepo(itime,ltsample,loutnext,forreceptor)
    23 !                  i      i        i            i
     22subroutine wetdepo(itime,ltsample,loutnext)
     23!                  i      i        i
    2424!*****************************************************************************
    2525!                                                                            *
     
    3030! This fraction is parameterized from total cloud cover and rates of large   *
    3131! scale and convective precipitation.                                        *
    32 ! SEC: if forrecptor is true then the wetdeposition fraction is only applied *
    33 ! on the xscav_frac and not on the xmass                                     *
    3432!                                                                            *
    3533!    Author: A. Stohl                                                        *
     
    9492  integer :: blc_count, inc_count
    9593  real    :: Si_dummy, wetscav_dummy
    96   logical :: readclouds_this_nest,forreceptor
     94  logical :: readclouds_this_nest
    9795
    9896
     
    174172           memtime(1),memtime(2),interp_time,lsp,convp,cc)
    175173    endif
     174
     175!  If total precipitation is less than 0.01 mm/h - no scavenging occurs
     176!  sec this is just valid if release is over a point
     177    if ((lsp.lt.0.01).and.(convp.lt.0.01)) then
     178          if (WETBKDEP) then
     179             do ks=1,nspec
     180                if (xscav_frac1(jpart,ks).lt.0) then ! first timestep no scavenging
     181                   xmass1(jpart,ks)=0.
     182                   xscav_frac1(jpart,ks)=0.
     183!                  write (*,*) 'paricle removed - no scavenging: ',jpart,ks
     184                endif
     185             end do
     186          endif
     187          goto 20
     188    endif
     189
    176190
    177191! get the level were the actual particle is in
     
    399413        kp=1
    400414      endif
    401       if (forreceptor .eqv. .false.) then
    402          if (restmass .gt. smallnum) then
    403            xmass1(jpart,ks)=restmass
     415      if (restmass .gt. smallnum) then
     416        xmass1(jpart,ks)=restmass
    404417!   depostatistic
    405418!   wetdepo_sum(ks,kp)=wetdepo_sum(ks,kp)+wetdeposit(ks)
    406419!   depostatistic
    407          else
    408            xmass1(jpart,ks)=0.
    409         endif
    410      else ! for the backward deposition calculation
    411          if (wetdeposit(ks).gt.0) then ! deposition occured
    412                 xscav_frac1(jpart,ks)=xscav_frac1(jpart,ks)*(-1.)* &
    413                    wetdeposit(ks)/xmass1(jpart,ks)
    414 !                write (*,*) 'paricle kept: ',jpart,ks,wetdeposit(ks),xscav_frac1(jpart,ks)
    415          else
    416                 xmass1(jpart,ks)=0.
    417                 xscav_frac1(jpart,ks)=0.
    418          endif
    419      endif
     420      else
     421        xmass1(jpart,ks)=0.
     422      endif
    420423!   Correct deposited mass to the last time step when radioactive decay of
    421424!   gridded deposited mass was calculated
     
    423426        wetdeposit(ks)=wetdeposit(ks)*exp(abs(ldeltat)*decay(ks))
    424427      endif
     428
     429      if (WETBKDEP) then
     430! the calculation of the scavenged mass shall only be done once after release
     431! xscav_frac1 was initialised with a negative value
     432          if (xscav_frac1(jpart,ks).lt.0) then
     433             if (wetdeposit(ks).eq.0) then
     434! terminate particle
     435                xmass1(jpart,ks)=0.
     436                xscav_frac1(jpart,ks)=0.
     437             else
     438                xscav_frac1(jpart,ks)=xscav_frac1(jpart,ks)*(-1.)* &
     439                   wetdeposit(ks)/xmass1(jpart,ks)
     440!                write (*,*) 'paricle kept: ',jpart,ks,wetdeposit(ks),xscav_frac1(jpart,ks)
     441             endif
     442          endif
     443      endif
     444
    425445
    426446    end do !all species
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG