FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 | ||
integer, | intent(in) | :: | istep |
subroutine invert_rhs (phi, apar, bpar, phinew, aparnew, bparnew, istep)
use theta_grid, only: ntgrid
use gs2_time, only: code_time
use constants, only: zi, pi
use dist_fn_arrays, only: g_work, gnew
use array_utils, only: zero_array
implicit none
complex, dimension (-ntgrid:,:,:), intent (in) :: phi, apar, bpar
complex, dimension (-ntgrid:,:,:), intent (in) :: phinew, aparnew, bparnew
integer, intent (in) :: istep
real :: time
complex :: sourcefac
time = code_time
!Sourcefac ends up being passed all the way through to get_source_term
!where it is multiplied by phi_ext (default 0.0) and added to ky<epsilon(0.0)
!modes source term. Should probably just be calculated in get_source_term and
!only if min(ky)<epsilon(0.0) & phi_ext/=0 & source_option_switch==source_option_phiext_full
!
if (time > t0) then
sourcefac = source0*exp(-zi*omega0*time+gamma0*time)
else
sourcefac = (0.5 - 0.5*cos(pi*time/t0))*exp(-zi*omega0*time+gamma0*time)
end if
! 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 invert_rhs_1 (phinew, bparnew, source = g_work)
select case (boundary_option_switch)
case (boundary_option_linked)
! Note if no_connections default was true we could also unconditionally call apply_linked_boundary_conditions
! or just call the below if no_connections is false.
call apply_linked_boundary_conditions(gnew, g_h, g_adj, phinew, bparnew)
end select
end subroutine invert_rhs