write_namelists Subroutine

private subroutine write_namelists(jr, tag1, tag2, header)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: jr
character(len=*), intent(in), optional :: tag1
character(len=*), intent(in), optional :: tag2
type(standard_header_type), intent(in), optional :: header

Header for files with build and run information


Contents

Source Code


Source Code

  subroutine write_namelists (jr, tag1, tag2, header)
    use antenna, only: wnml_antenna
    use collisions, only: wnml_collisions
    use dist_fn, only: wnml_dist_fn, wnml_dist_fn_species 
    use fields, only: wnml_fields
    use gs2_reinit, only: wnml_gs2_reinit
    use gs2_layouts, only: wnml_gs2_layouts
    use gs2_diagnostics, only: wnml_gs2_diagnostics
    use hyper, only: wnml_hyper
    use init_g, only : wnml_init_g
    use kt_grids, only: wnml_kt
    use le_grids, only: wnml_le_grids
    use nonlinear_terms, only: nonlin, wnml_nonlinear_terms
    use run_parameters, only: wnml_run_parameters
    use species, only: wnml_species
    use theta_grid, only: wnml_theta_grid
    use theta_grid_params, only: wnml_theta_grid_params
    use standard_header, only: standard_header_type
    use file_utils, only: run_name
    integer, intent (in), optional :: jr
    character (*), intent (in), optional :: tag1, tag2
    !> Header for files with build and run information
    type(standard_header_type), intent(in), optional :: header
    ! Actual value for optional `header` input
    type(standard_header_type) :: local_header
    integer :: h, t, u, unit
    character (4) :: suffix
    character(len=:), allocatable :: filename
    
    if (present(header)) then
      local_header = header
    else
      local_header = standard_header_type()
    end if

    if (present(jr)) then

       h = jr / 100
       t = (jr - h * 100) / 10
       u = (jr - h * 100 - t * 10)
       suffix = '_'//achar(48+h)//achar(48+t)//achar(48+u)
       filename = trim(run_name) // suffix // ".in"
    else
       filename = trim(run_name) // ".inp"
    endif

    open (newunit=unit, file=filename)
    write (*, *) "Writing processed input file to '" // filename // "'"

    write (unit, *)

    write (unit=unit, fmt='(a)') local_header%to_string(file_description="Input parameters as set by ingen")

    if (present(tag1)) then
       write (unit, *) '*****************************************************'
       write (unit, *) trim(tag1)
       if (present(tag2)) write (unit, *) trim(tag2)
       write (unit, *) '*****************************************************'
    end if

    call wnml_gs2_layouts(unit)
    call wnml_collisions(unit)
    call wnml_init_g(unit)
    call wnml_dist_fn(unit)
    call wnml_fields(unit)
    call wnml_gs2_diagnostics(unit)
    if (nonlin) call wnml_gs2_reinit(unit)
    call wnml_hyper(unit)
    call wnml_kt(unit)
    call wnml_le_grids(unit)
    call wnml_nonlinear_terms(unit)
    call wnml_run_parameters(unit)
    call wnml_species(unit)
    call wnml_dist_fn_species(unit)

    call wnml_theta_grid_params(unit)
    call wnml_theta_grid(unit)

    call wnml_antenna(unit)

    write(unit, fmt=*)
    close (unit)
    
  end subroutine write_namelists