FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(initial_values_overrides_type), | intent(inout) | :: | initval_ov |
subroutine set_initval_overrides_to_current_vals(initval_ov)
use dist_fn_arrays, only: gnew, gexp_1, gexp_2, gexp_3
use gs2_save, only: gs2_save_for_restart
use mp, only: proc0, broadcast, mp_abort
use collisions, only: vnmult
use file_utils, only: error_unit
use run_parameters, only: has_phi, has_apar, has_bpar
use fields, only: force_maxwell_reinit
use fields_arrays, only: phinew, aparnew, bparnew
use gs2_time, only: user_time, code_dt, code_dt_prev1, code_dt_prev2, code_dt_max
use overrides, only: initial_values_overrides_type
use antenna, only: dump_ant_amp
use array_utils, only: copy
implicit none
type(initial_values_overrides_type), intent(inout) :: initval_ov
if (.not.initval_ov%is_initialised()) &
call mp_abort("Trying to set initial value overrides &
& before they are initialized... have you called &
& prepare_initial_values_overrides ? ", .true.)
if(initval_ov%in_memory)then
call copy(gnew, initval_ov%g)
initval_ov%vnmult = vnmult
if (allocated(initval_ov%gexp_1)) call copy(gexp_1, initval_ov%gexp_1)
if (allocated(initval_ov%gexp_2)) call copy(gexp_2, initval_ov%gexp_2)
if (allocated(initval_ov%gexp_3)) call copy(gexp_3, initval_ov%gexp_3)
! Do not use the value from [old_iface_]state%init%initval_ov%force_maxwell_reinit = initval_ov%force_maxwell_reinit as
! follows:
! if (.not. initval_ov%force_maxwell_reinit) then
! as was done previously. This is because this causes problems in gs2_init so we use the value from
! fields::force_maxwell_reinit directly (see comments in gs2_init for details). To use here the value from
! initval_ov%force_maxwell_reinit could result in inconsistent values being used in different parts of the code. Therefore, we
! now use the value from fields::force_maxwell_reinit directly here too. Now that the reference to
! initval_ov%force_maxwell_reinit here has also been removed, this component is no longer referenced anywhere in the codebase.
! Therefore, the force_maxwell_reinit component has been completely removed from the initial_values_overrides_type derived
! type to avoid confusion in the future.
if (.not. force_maxwell_reinit) then
if(has_phi) call copy(phinew, initval_ov%phi)
if(has_apar) call copy(aparnew, initval_ov%apar)
if(has_bpar) call copy(bparnew, initval_ov%bpar)
end if
else ! if(.not.in_memory)then
!Should really do this with in_memory=.true. as well but
!not sure that we really need to as we never read in the dumped data.
if (proc0) call dump_ant_amp
call gs2_save_for_restart (gnew, user_time, vnmult, &
has_phi, has_apar, has_bpar, code_dt, code_dt_prev1, code_dt_prev2, code_dt_max)
endif
end subroutine set_initval_overrides_to_current_vals