do_write_ncloop Subroutine

private subroutine do_write_ncloop(time, istep, phi2, apar2, bpar2, phitot)

Compute volume averages of the fields and write the fields, field averages, heating and frequency to the netCDF files

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: time

Simulation time

integer, intent(in) :: istep

Current timestep

real, intent(out) :: phi2

Fields squared

real, intent(out) :: apar2

Fields squared

real, intent(out) :: bpar2

Fields squared

real, intent(out), dimension (:, :) :: phitot

FIXME: add documentation. Needs phinorm documenting


Contents

Source Code


Source Code

  subroutine do_write_ncloop(time, istep, phi2, apar2, bpar2, phitot)
    use gs2_time, only: woutunits, tunits
    use gs2_io, only: nc_loop
    use mp, only: proc0
    use kt_grids, only: ntheta0, naky
    implicit none
    !> Simulation time
    real, intent(in) :: time
    !> Current timestep
    integer, intent(in) :: istep
    !> Fields squared
    real, intent(out) :: phi2, apar2, bpar2
    !> FIXME: add documentation. Needs [[phinorm]] documenting
    real, dimension (:, :), intent(out) :: phitot
    real, dimension (ntheta0, naky) :: ql_metric, growth_rates

    omega = omegahist(mod(istep,navg),:,:)

    call phinorm (phitot)

    if (write_ql_metric) then

       ! Calculate the instantaneous omega and keep the growth rate.
       growth_rates = aimag(calculate_instantaneous_omega())
       ql_metric = calculate_simple_quasilinear_flux_metric_by_k(growth_rates)
    else
       ql_metric = 0.0
    end if

    if(proc0) call nc_loop (get_netcdf_file_id(), nout, time, &
         phi2, apar2, bpar2, igomega, &
         h, hk, omega, omegaavg, woutunits, tunits, phitot, ql_metric, &
         write_omega, write_heating, write_ql_metric)

  end subroutine do_write_ncloop