nc_species Subroutine

public subroutine nc_species(file_id)

Uses

Write spec to output netCDF file

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: file_id

NetCDF ID of the file to write to


Contents

Source Code


Source Code

  subroutine nc_species(file_id)
#ifdef NETCDF
    use species, only: spec
    use neasyf, only: neasyf_write
#endif
    implicit none
    !> NetCDF ID of the file to write to
    integer, intent(in) :: file_id
#ifdef NETCDF
    ! Note: Here parentheses around variables passed to neasyf_write are an intentional
    ! workaround to a gfortran bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105658
    call neasyf_write(file_id, "charge", (spec%z), dim_names=["species"], &
         long_name="Charge", units="e")
    call neasyf_write(file_id, "mass", (spec%mass), dim_names=["species"], &
         long_name="Atomic mass", units="AMU")
    call neasyf_write(file_id, "dens", (spec%dens), dim_names=["species"], &
         long_name="Normalised density", units="nref")
    call neasyf_write(file_id, "temp", (spec%temp), dim_names=["species"], &
         long_name="Normalised temperature", units="Tref")
    call neasyf_write(file_id, "tprim", (spec%tprim), dim_names=["species"], &
         long_name="Normalised temperature gradient scale length -1/rho dT/drho", units="1/aref")
    call neasyf_write(file_id, "fprim", (spec%fprim), dim_names=["species"], &
         long_name="Normalised density gradient scale length -Lref/n dn/drho", units="1/aref")
    call neasyf_write(file_id, "uprim", (spec%uprim), dim_names=["species"], &
         long_name="Normalised parallel velocity gradient scale length -1/v_t du_par/drho", units="1/aref")
    call neasyf_write(file_id, "uprim2", (spec%uprim2), dim_names=["species"])
    call neasyf_write(file_id, "vnewk", (spec%vnewk), dim_names=["species"], &
         long_name="Collisionality", units="vtref/aref")

    ! FIXME: duplicated variable, old/new diagnostics
    call neasyf_write(file_id, "type_of_species", (spec%type), dim_names=["species"], &
         long_name="Species type: 1=ion, 2=electron, 3=trace, 4=hybrid_electron")
    call neasyf_write(file_id, "type", (spec%type), dim_names=["species"], &
         long_name="Species type: 1=ion, 2=electron, 3=trace, 4=hybrid_electron")

    call neasyf_write(file_id, "f0type", (spec%f0type), dim_names=["species"], &
         long_name="Species type: 1=Maxwellian, 2=Tabulated, 3=Analytic slowing down")
    call neasyf_write(file_id, "nu_h", (spec%nu_h), dim_names=["species"], &
         long_name="Hypervicsous collision factor")
    call neasyf_write(file_id, "bess_fac", (spec%bess_fac), dim_names=["species"], &
         long_name="Artificial factor scaling Bessel function arguments")
    ! Parameters used in slowing down calculation
    call neasyf_write(file_id, "vcrit", (spec%vcrit), dim_names=["species"])
    call neasyf_write(file_id, "vcprim", (spec%vcprim), dim_names=["species"])
    ! Parameters only used for certain initialisation options
    call neasyf_write(file_id, "dens0", (spec%dens0), dim_names=["species"])
    call neasyf_write(file_id, "u0", (spec%u0), dim_names=["species"])
    call neasyf_write(file_id, "tpar0", (spec%tpar0), dim_names=["species"])
    call neasyf_write(file_id, "tperp0", (spec%tperp0), dim_names=["species"])

#endif
  end subroutine nc_species