module delay_io_mod
  use sep
  implicit none

contains

  subroutine iodata(filetag, data, ngx, ngy, nws, nsx, nsy, indsx, indsy, flag)
  implicit none
  complex, dimension(:,:,:), pointer :: data
  integer                            :: ngx, ngy, nws, nsx, nsy
  integer                            :: indsx, indsy
  character(len=*)                   :: filetag
  character(len=4)                   :: flag

  integer, dimension(5)              :: n_cube, j_wind, n_wind, f_wind
  integer                            :: n_dim_cube, err
  integer                  ,external :: sreed_window, srite_window
  n_dim_cube = 5
  n_cube = (/ngx, ngy, nws, nsx, nsy/)
  j_wind = (/1, 1, 1, 1, 1/)
  n_wind = (/ngx, ngy, nws, 1, 1/)
  f_wind = (/0, 0, 0, indsx-1, indsy-1/)


  if (flag == "reed") then
     err = sreed_window(filetag,n_dim_cube,n_cube,n_wind,f_wind,j_wind,8,data)
  else if (flag == "rite") then
     err = srite_window(filetag,n_dim_cube,n_cube,n_wind,f_wind,j_wind,8,data)
  else
     call seperr("error")
  end if
  return
  end subroutine


end module
