w90_readwrite_write_win Subroutine

public subroutine w90_readwrite_write_win(settings, seedname, error, comm)

Uses

  • proc~~w90_readwrite_write_win~~UsesGraph proc~w90_readwrite_write_win w90_readwrite_write_win module~w90_error w90_error proc~w90_readwrite_write_win->module~w90_error module~w90_comms w90_comms module~w90_error->module~w90_comms module~w90_error_base w90_error_base module~w90_error->module~w90_error_base module~w90_comms->module~w90_error_base module~w90_constants w90_constants module~w90_comms->module~w90_constants

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout), target :: settings
character(len=*), intent(in) :: seedname
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_write_win~~CallsGraph proc~w90_readwrite_write_win w90_readwrite_write_win proc~set_error_fatal set_error_fatal proc~w90_readwrite_write_win->proc~set_error_fatal proc~comms_sync_error comms_sync_error proc~set_error_fatal->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~w90_readwrite_write_win~~CalledByGraph proc~w90_readwrite_write_win w90_readwrite_write_win proc~w90_input_setopt w90_input_setopt proc~w90_input_setopt->proc~w90_readwrite_write_win proc~w90_input_setopt_f w90_input_setopt_f proc~w90_input_setopt_f->proc~w90_input_setopt

Source Code

  subroutine w90_readwrite_write_win(settings, seedname, error, comm)
    ! print win file
    use w90_error, only: w90_error_type, set_error_fatal

    implicit none

    ! arguments
    character(len=*), intent(in) :: seedname
    type(settings_type), intent(inout), target :: settings
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    ! local variables
    integer :: i, j, l, fu
    type(settings_data), pointer :: entry_ptr

    open (newunit=fu, file=trim(seedname)//".win_dump", err=101)

    do l = 1, size(settings%entries, 1)

      entry_ptr => settings%entries(l)

      if (allocated(entry_ptr%txtdata)) then
        write (fu, *) entry_ptr%keyword, " = ", entry_ptr%txtdata

      else if (allocated(entry_ptr%idata)) then
        write (fu, *) entry_ptr%keyword, " = ", entry_ptr%idata

      else if (allocated(entry_ptr%ldata)) then
        if (entry_ptr%keyword == "dump_inputs") cycle ! this is not valid .win input
        write (fu, *) entry_ptr%keyword, " = ", entry_ptr%ldata

      else if (allocated(entry_ptr%rdata)) then
        write (fu, *) entry_ptr%keyword, " = ", entry_ptr%rdata

      else if (allocated(entry_ptr%i1d)) then
        if (entry_ptr%keyword == "distk") cycle ! this is not valid .win input
        write (fu, *) entry_ptr%keyword, " = ", entry_ptr%i1d(:)
      end if

      nullify (entry_ptr)
    end do

    ! same again, to put the long lists (kpoints, etc?) last
    ! 2d "block" data, integer or float
    do l = 1, size(settings%entries, 1)

      entry_ptr => settings%entries(l)

      if (allocated(entry_ptr%i2d)) then
        write (fu, *) "begin ", entry_ptr%keyword
        do j = 1, size(entry_ptr%i2d, 2)
          do i = 1, size(entry_ptr%i2d, 1)
            write (fu, '(i4)', advance='no') entry_ptr%i2d(i, j)
          end do
          write (fu, *) '' ! EOL
        end do
        write (fu, *) "end ", entry_ptr%keyword

      else if (allocated(entry_ptr%r2d)) then
        write (fu, *) "begin ", entry_ptr%keyword
        do j = 1, size(entry_ptr%r2d, 2)
          do i = 1, size(entry_ptr%r2d, 1)
            write (fu, '(f20.12)', advance='no') entry_ptr%r2d(i, j)
          end do
          write (fu, *) '' ! EOL
        end do
        write (fu, *) "end ", entry_ptr%keyword
      end if

      nullify (entry_ptr)
    end do

    close (fu)
    return

101 call set_error_fatal(error, 'Error: failed to open .win_dump output file', comm)
    return
  end subroutine w90_readwrite_write_win