diff --git a/src/initialise_mod.f90 b/src/initialise_mod.f90 index 9a1cd6d497dadd5b2df40f2f557e55bd83c96a44..052f070f6637ad1c045f36dcf85b1511dcbdb64e 100644 --- a/src/initialise_mod.f90 +++ b/src/initialise_mod.f90 @@ -128,7 +128,7 @@ subroutine releaseparticles(itime) !*************************************************************************** ! First allocate all particles that are going to be in the simulation ! If ipin==0,1, and ipout==0, then dead particles can be overwritten to save memory - if (ipin.gt.1 .or. ipout.ne.0) then + if (ipin.gt.1 .or. ipout.ne.0 .or. ispeed.eq.1) then if (itime.eq.0) then totpart=0 do i=1,numpoint @@ -145,7 +145,7 @@ subroutine releaseparticles(itime) endif call get_totalpart_num(istart) - if (ipin.le.1 .and. ipout.eq.0) call rewrite_iterm() + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0) call rewrite_iterm() minpart=1 do i=1,numpoint if ((itime.ge.ireleasestart(i)).and. &! are we within release interval? @@ -212,7 +212,7 @@ subroutine releaseparticles(itime) yaux=ypoint2(i)-ypoint1(i) zaux=zpoint2(i)-zpoint1(i) - if (ipin.le.1 .and. ipout.eq.0) then + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0 ) then call rewrite_iterm() totpart = numrel-count%iterm_max if (totpart.gt.0) call alloc_particles(totpart) @@ -286,7 +286,7 @@ subroutine releaseparticles(itime) endif ! releasepoint end do ! numpoint - if (ipin.le.1 .and. ipout.eq.0) call rewrite_iterm() + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0 ) call rewrite_iterm() call get_totalpart_num(iend) @@ -1418,7 +1418,7 @@ subroutine boundcond_domainfill(itime,loutend) ! Terminate trajectories that have left the domain, if domain-filling ! trajectory calculation domain is not global !******************************************************************** - if (ipin.le.1 .and. ipout.eq.0) call rewrite_iterm() + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0) call rewrite_iterm() iterminate=0 do i=1,count%allocated @@ -1875,7 +1875,7 @@ subroutine boundcond_domainfill(itime,loutend) end do ! north south ! !$OMP END DO ! !$OMP END PARALLEL - if (ipin.le.1 .and. ipout.eq.0) call rewrite_iterm() + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0) call rewrite_iterm() numparticlecount = numparticlecount_tmp ! If particles shall be dumped, then accumulated masses at the domain boundaries ! must be dumped, too, to be used for later runs diff --git a/src/par_mod.f90 b/src/par_mod.f90 index 53b482f808e82a66b4e1efde8bdd7fa56f593fd1..aad5b84295c9e9a3594291abd1d640d7f17d9f87 100644 --- a/src/par_mod.f90 +++ b/src/par_mod.f90 @@ -311,4 +311,7 @@ module par_mod ! Particle dump: one file per field or all in one netcdf file logical,parameter :: lpartoutputperfield=.false. + ! To save memory, terminated particles can be overwritted, but this can cause overhead. + ! set ispeed=1 to decrease this overhead, but increasing the memory footprint + integer,parameter :: ispeed=0 end module par_mod diff --git a/src/particle_mod.f90 b/src/particle_mod.f90 index 35363566ecf31e1ecfcf7110dcc48c03b083116e..c03f6d823a07ad4ea8a5bfbf01a2ca7fa428e46c 100644 --- a/src/particle_mod.f90 +++ b/src/particle_mod.f90 @@ -13,7 +13,7 @@ module particle_mod use com_mod, only: maxspec,DRYDEP,WETDEP,DRYBKDEP,WETBKDEP,iout, & n_average,nspec,ipout,ipin - use par_mod, only: dp + use par_mod, only: dp,ispeed implicit none @@ -395,7 +395,7 @@ contains count%alive=j-1 - if (ipin.le.1 .and. ipout.eq.0) call rewrite_iterm + if (ipin.le.1 .and. ipout.eq.0 .and. ispeed.eq.0) call rewrite_iterm end subroutine rewrite_ialive subroutine rewrite_iterm()