Routine to dump the current source term used in invert_rhs.
This might be relatively expensive so care should be taken in calling this. It makes use of the existing code for saving restart files and as such produces either one file per processor or a single file depending on if the build uses parallel i/o or not. These files are automatically overwritten so calling it repeatedly within a single run might not be useful.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | istep | |||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | phi | ||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | apar | ||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | bpar | ||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | phinew | ||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | aparnew | ||
complex, | intent(in), | dimension (-ntgrid:,:,:) | :: | bparnew | ||
complex, | intent(in) | :: | sourcefac |
subroutine dump_current_source_term(istep, phi, apar, bpar, phinew, &
aparnew, bparnew, sourcefac)
use gs2_save, only: gs2_save_for_restart
use dist_fn_arrays, only: g_work
use theta_grid, only: ntgrid
use run_parameters, only: has_phi, has_apar, has_bpar
use gs2_time, only: user_time, code_dt, code_dt_prev1, code_dt_prev2, code_dt_max
use collisions, only: vnmult
use array_utils, only: zero_array
implicit none
integer, intent(in) :: istep
complex, dimension (-ntgrid:,:,:), intent (in) :: phi, apar, bpar
complex, dimension (-ntgrid:,:,:), intent (in) :: phinew, aparnew, bparnew
complex, intent(in) :: sourcefac
character(len = 20), parameter :: extension = '.source'
integer :: istatus
! Is this needed?
call zero_array(g_work)
call get_source_term_on_local_domain(g_work, phi, apar, bpar, phinew, &
aparnew, bparnew, istep, sourcefac)
call gs2_save_for_restart (g_work, user_time, vnmult, istatus, &
has_phi, has_apar, has_bpar, &
code_dt, code_dt_prev1, code_dt_prev2, code_dt_max, fileopt = extension)
end subroutine dump_current_source_term