!!----------------------------------------------------
!! Author: Yaxun Tang, tang@sep.stanford.edu
!!----------------------------------------------------
module base_ioutil_mod
  use  sep
  use  base_struct_mod
  implicit none
  
contains
  !!--------------------------------------------------------------------
  !!.. input file history for axis ndim
  !!--------------------------------------------------------------------
  subroutine hinaxis(filetag, ax, ndim, ndefault, ddefault, odefault)
    character(len=*)           :: filetag
    type(axis)                 :: ax
    integer                    :: ndim
    integer         , optional :: ndefault
    real            , optional :: ddefault
    real            , optional :: odefault

    character(len=128)         :: buffer

    write(buffer, "(a,i1)") "n", ndim
    call from_aux(filetag, buffer, ax%n, ndefault)
    write(buffer, "(a,i1)") "d", ndim
    call from_aux(filetag, buffer, ax%d, ddefault)
    write(buffer, "(a,i1)") "o", ndim
    call from_aux(filetag, buffer, ax%o, odefault)

    return
  end subroutine

  !!------------------------------------------------------------------------
  !!.. output file history for axis ndim
  !!------------------------------------------------------------------------
  subroutine houaxis(filetag, ax, ndim)
    character(len=*)   :: filetag
    type(axis)         :: ax
    integer            :: ndim

    character(len=128) :: buffer

    write(buffer, "(a,i1)") "n", ndim
    call auxputch(buffer, "i", ax%n, filetag)
    write(buffer, "(a,i1)") "d", ndim
    call auxputch(buffer, "r", ax%d, filetag)
    write(buffer, "(a,i1)") "o", ndim
    call auxputch(buffer, "r", ax%o, filetag)

    return
  end subroutine

end module
