Changeset 8a65cb0 in flexpart.git for src/advance.f90
- Timestamp:
- Mar 2, 2015, 3:11:55 PM (9 years ago)
- Branches:
- master, 10.4.1_pesei, GFS_025, bugfixes+enhancements, dev, release-10, release-10.4.1, scaling-bug, univie
- Children:
- 1d207bb
- Parents:
- 60403cd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/advance.f90
re200b7a r8a65cb0 103 103 use hanna_mod 104 104 use cmapf_mod 105 use random_mod, only: ran3 105 106 106 107 implicit none … … 108 109 real(kind=dp) :: xt,yt 109 110 real :: zt,xts,yts,weight 110 integer :: itime,itimec,nstop,ldt,i,j,k,nrand,loop,memindnext 111 integer :: itime,itimec,nstop,ldt,i,j,k,nrand,loop,memindnext,mind 111 112 integer :: ngr,nix,njy,ks,nsp,nrelpoint 112 113 real :: dz,dz1,dz2,xlon,ylat,xpol,ypol,gridsize … … 119 120 !real usigprof(nzmax),vsigprof(nzmax),wsigprof(nzmax) 120 121 !real rhoprof(nzmax),rhogradprof(nzmax) 121 real :: rhoa,rhograd, ran3,delz,dtf,rhoaux,dtftlw,uxscale,wpscale122 real :: rhoa,rhograd,delz,dtf,rhoaux,dtftlw,uxscale,wpscale 122 123 integer(kind=2) :: icbt 123 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 124 128 125 129 … … 225 229 if (ngrid.le.0) then 226 230 do k=1,2 231 ! eso: compatibility with 3-field version 232 mind=memind(k) 227 233 do j=jy,jyp 228 234 do i=ix,ixp 229 if (hmix(i,j,1, k).gt.h) h=hmix(i,j,1,k)235 if (hmix(i,j,1,mind).gt.h) h=hmix(i,j,1,mind) 230 236 end do 231 237 end do … … 234 240 else 235 241 do k=1,2 242 mind=memind(k) 236 243 do j=jy,jyp 237 244 do i=ix,ixp 238 if (hmixn(i,j,1, k,ngrid).gt.h) h=hmixn(i,j,1,k,ngrid)245 if (hmixn(i,j,1,mind,ngrid).gt.h) h=hmixn(i,j,1,mind,ngrid) 239 246 end do 240 247 end do … … 379 386 if (turbswitch) then 380 387 if (dtftlw.lt..5) then 381 wp=((1.-dtftlw)*wp+rannumb(nrand+i)*sqrt(2.*dtftlw) & 382 +dtf*(dsigwdz+rhoaux*sigw))*real(icbt) 388 !************************************************************* 389 !************** CBL options added by mc see routine cblf90 *** 390 if (cblflag.eq.1) then !modified by mc 391 if (-h/ol.gt.5) then !modified by mc 392 !if (ol.lt.0.) then !modified by mc 393 !if (ol.gt.0.) then !modified by mc : for test 394 !print *,zt,wp,ath,bth,tlw,dtf,'prima' 395 flagrein=0 396 nrand=nrand+1 397 old_wp_buf=wp 398 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 399 wp=(wp+ath*dtf+bth*rannumb(nrand)*sqrt(dtf))*real(icbt) 400 ! wp=(wp+ath*dtf+bth*gasdev2(mydum)*sqrt(dtf))*real(icbt) 401 delz=wp*dtf 402 if (flagrein.eq.1) then 403 call re_initialize_particle(zt,ust,wst,h,sigw,old_wp_buf,nrand,ol) 404 wp=old_wp_buf 405 delz=wp*dtf 406 nan_count=nan_count+1 407 end if 408 !print *,zt,wp,ath,bth,tlw,dtf,rannumb(nrand+i),icbt 409 !pause 410 else 411 nrand=nrand+1 412 old_wp_buf=wp 413 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 414 !2-but since ldirect =-1 for inverse time and this must be calculated for (-wp) and 415 !3-the gaussian pdf is symmetric (i.e. pdf(w)=pdf(-w) ldirect can be discarded 416 bth=sigw*rannumb(nrand)*sqrt(2.*dtftlw) 417 wp=(wp+ath*dtf+bth)*real(icbt) 418 delz=wp*dtf 419 del_test=(1.-wp)/wp !catch infinity value 420 if (isnan(wp).or.isnan(del_test)) then 421 nrand=nrand+1 422 wp=sigw*rannumb(nrand) 423 delz=wp*dtf 424 nan_count2=nan_count2+1 425 !print *,'NaN coutner equal to:', nan_count,'reduce ifine if this number became a non-negligible fraction of the particle number' 426 end if 427 end if 428 !******************** END CBL option ******************************* 429 !******************************************************************* 430 else 431 wp=((1.-dtftlw)*wp+rannumb(nrand+i)*sqrt(2.*dtftlw) & 432 +dtf*(dsigwdz+rhoaux*sigw))*real(icbt) 433 delz=wp*sigw*dtf 434 end if 383 435 else 384 436 rw=exp(-dtftlw) 385 437 wp=(rw*wp+rannumb(nrand+i)*sqrt(1.-rw**2) & 386 438 +tlw*(1.-rw)*(dsigwdz+rhoaux*sigw))*real(icbt) 439 delz=wp*sigw*dtf 387 440 endif 388 delz=wp*sigw*dtf441 389 442 else 390 443 rw=exp(-dtftlw) … … 421 474 422 475 end do 423 nrand=nrand+i476 if (cblflag.ne.1) nrand=nrand+i 424 477 425 478 ! Determine time step for next integration … … 463 516 dcwsave=dcwsave+vp*dt 464 517 zt=zt+w*dt*real(ldirect) 518 519 ! HSO/AL: Particle managed to go over highest level -> interpolation error in goto 700 520 ! alias interpol_wind (division by zero) 521 if (zt.ge.height(nz)) zt=height(nz)-100.*eps 465 522 466 523 if (zt.gt.h) then … … 493 550 !if (mod(itime,10800).ne.0) dump=.true. 494 551 !!! CHANGE 495 496 552 553 !!!----- TEST OF THE WELL-MIXED CRITERION: modified by mc, not to be included in final version mc 554 ! if (zt.lt.h) then 555 ! i_well=int(zt/h*25.)+1 556 ! well_mixed_vector(i_well)=well_mixed_vector(i_well)+dt 557 ! well_mixed_norm=well_mixed_norm+dt 558 ! avg_air_dens(i_well)=avg_air_dens(i_well)+rhoa*dt 559 ! avg_wst=avg_wst+wst*dt 560 ! avg_ol=avg_ol+ol*dt 561 ! avg_h=avg_h+h*dt 562 ! end if 563 ! h_well=h 564 !------- END TEST 565 497 566 ! Determine probability of deposition 498 567 !************************************ … … 656 725 657 726 call windalign(dxsave,dysave,dawsave,dcwsave,ux,vy) 658 dxsave=dxsave+ux 727 dxsave=dxsave+ux ! comment by mc: comment this line to stop the particles horizontally for test reasons 659 728 dysave=dysave+vy 660 729 if (ngrid.ge.0) then … … 663 732 yt=yt+real(dysave*dyconst*real(ldirect),kind=dp) 664 733 else if (ngrid.eq.-1) then ! around north pole 665 xlon=xlon0+xt*dx 734 xlon=xlon0+xt*dx !comment by mc: compute old particle position 666 735 ylat=ylat0+yt*dy 667 call cll2xy(northpolemap,ylat,xlon,xpol,ypol) 668 gridsize=1000.*cgszll(northpolemap,ylat,xlon) 669 dxsave=dxsave/gridsize 736 call cll2xy(northpolemap,ylat,xlon,xpol,ypol) !convert old particle position in polar stereographic 737 gridsize=1000.*cgszll(northpolemap,ylat,xlon) !calculate size in m of grid element in polar stereographic coordinate 738 dxsave=dxsave/gridsize !increment from meter to grdi unit 670 739 dysave=dysave/gridsize 671 xpol=xpol+dxsave*real(ldirect) 740 xpol=xpol+dxsave*real(ldirect) !position in grid unit polar stereographic 672 741 ypol=ypol+dysave*real(ldirect) 673 call cxy2ll(northpolemap,xpol,ypol,ylat,xlon) 674 xt=(xlon-xlon0)/dx 742 call cxy2ll(northpolemap,xpol,ypol,ylat,xlon) !convert to lat long coordinate 743 xt=(xlon-xlon0)/dx !convert to grid units in lat long coordinate, comment by mc 675 744 yt=(ylat-ylat0)/dy 676 745 else if (ngrid.eq.-2) then ! around south pole … … 699 768 endif 700 769 770 ! HSO/AL: Prevent particles from disappearing at the pole 771 !****************************************************************** 772 773 if ( yt.lt.0. ) then 774 xt=mod(xt+180.,360.) 775 yt=-yt 776 else if ( yt.gt.real(nymin1) ) then 777 xt=mod(xt+180.,360.) 778 yt=2*real(nymin1)-yt 779 endif 701 780 702 781 ! Check position: If trajectory outside model domain, terminate it … … 704 783 705 784 if ((xt.lt.0.).or.(xt.ge.real(nxmin1)).or.(yt.lt.0.).or. & 706 (yt.g e.real(nymin1))) then785 (yt.gt.real(nymin1))) then 707 786 nstop=3 708 787 return … … 859 938 endif 860 939 940 ! HSO/AL: Prevent particles from disappearing at the pole 941 !****************************************************************** 942 943 if ( yt.lt.0. ) then 944 xt=mod(xt+180.,360.) 945 yt=-yt 946 else if ( yt.gt.real(nymin1) ) then 947 xt=mod(xt+180.,360.) 948 yt=2*real(nymin1)-yt 949 endif 950 861 951 ! Check position: If trajectory outside model domain, terminate it 862 952 !***************************************************************** 863 953 864 954 if ((xt.lt.0.).or.(xt.ge.real(nxmin1)).or.(yt.lt.0.).or. & 865 (yt.g e.real(nymin1))) then955 (yt.gt.real(nymin1))) then 866 956 nstop=3 867 957 return
Note: See TracChangeset
for help on using the changeset viewer.