advance_implicit Subroutine

public subroutine advance_implicit(istep, remove_zonal_flows_switch)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep
logical, intent(in) :: remove_zonal_flows_switch

Contents

Source Code


Source Code

  subroutine advance_implicit (istep, remove_zonal_flows_switch)
    use run_parameters, only: reset
    use fields_arrays, only: phi, apar, bpar, phinew, aparnew, bparnew
    use fields_arrays, only: apar_ext, time_field, time_field_mpi
    use antenna, only: antenna_amplitudes, no_driver
    use dist_fn, only: timeadv, exb_shear, collisions_advance
    use dist_fn_arrays, only: g, gnew, kx_shift, theta0_shift
    use unit_tests, only: debug_message
    use job_manage, only: time_message
    use mp, only: get_mp_times
    use array_utils, only: copy
    implicit none
    integer :: diagnostics = 1
    real :: mp_total, mp_total_after
    integer, intent (in) :: istep
    logical, intent (in) :: remove_zonal_flows_switch

    !GGH NOTE: apar_ext is initialized in this call
    if(.not.no_driver) call antenna_amplitudes (apar_ext)
       
    if (allocated(kx_shift) .or. allocated(theta0_shift)) call exb_shear (gnew, phinew, aparnew, bparnew, istep) 
    
    call copy(gnew, g)
    call copy(phinew, phi); call copy(aparnew, apar); call copy(bparnew, bpar)
    
    call debug_message(4, 'fields_implicit::advance_implicit calling timeadv 1')
    call timeadv (phi, apar, bpar, phinew, aparnew, bparnew, istep)
    call debug_message(4, 'fields_implicit::advance_implicit called timeadv 1')
    if(reset) return !Return is resetting

    if(.not.no_driver) aparnew = aparnew + apar_ext 
    
    call debug_message(4, 'fields_implicit::advance_implicit calling getfield')

    call time_message(.false.,time_field,' Field Solver')
    call get_mp_times(total_time = mp_total)

    call getfield (phinew, aparnew, bparnew)

    phinew   = phinew  + phi
    aparnew  = aparnew + apar
    bparnew  = bparnew + bpar

    call time_message(.false.,time_field,' Field Solver')
    call get_mp_times(total_time = mp_total_after)
    time_field_mpi = time_field_mpi + (mp_total_after - mp_total)

    if (remove_zonal_flows_switch) call remove_zonal_flows
    
    call debug_message(4, 'fields_implicit::advance_implicit calling timeadv')
    call timeadv (phi, apar, bpar, phinew, aparnew, bparnew, istep, diagnostics)
    call debug_message(4, 'fields_implicit::advance_implicit called timeadv')

    ! Advance collisions, if separate from timeadv
    call collisions_advance (phi, bpar, phinew, aparnew, bparnew, diagnostics)

  end subroutine advance_implicit