Let particles evolve in time. The routine also handles grid variables and output.
subroutine handle_particles() use mod_global_parameters use mod_timing integer :: steps_taken, nparticles_left tpartc0 = MPI_WTIME() call set_neighbor_ipe if (time_advance) then tmax_particles = global_time + dt call update_gridvars() else tmax_particles = time_max end if tpartc_com0=MPI_WTIME() call comm_particles_global() tpartc_com=tpartc_com + (MPI_WTIME()-tpartc_com0) ! main integration loop do if (tmax_particles >= t_next_output) then call advance_particles(t_next_output, steps_taken) tpartc_io_0 = MPI_WTIME() if (mype .eq. 0 .and. (.not. time_advance)) print*,& "Writing particle output at time",t_next_output call write_particle_output() timeio_tot = timeio_tot+(MPI_WTIME()-tpartc_io_0) tpartc_io = tpartc_io+(MPI_WTIME()-tpartc_io_0) ! If we are using a constant time step, this prevents multiple outputs ! at the same time t_next_output = max(t_next_output,& min_particle_time) + dtsave_particles else call advance_particles(tmax_particles, steps_taken) ! call write_particle_output() exit end if call MPI_ALLREDUCE(nparticles_on_mype, nparticles_left, 1, MPI_INTEGER,& MPI_SUM, icomm, ierrmpi) if (nparticles_left == 0 .and. convert) call & mpistop('No particles left') end do tpartc = tpartc + (MPI_WTIME() - tpartc0) end subroutine handle_particles