module pos_fileio_mod
  implicit none

contains

!=============================================================================
! read one frequency block receiver wavefield
!-----------------------------------------------------------------------------
   subroutine pos_fio_cdat(cdat, indw, nws, filetag, flag)
     complex, dimension(:,:,:) :: cdat
     integer                   :: indw, nws
     character(len=*)          :: filetag
     character(len=4)          :: flag
     integer, dimension(3)     :: n_cube, j_wind, n_wind, f_wind
     integer                   :: n_dim_cube, err

     n_dim_cube = 
     n_cube = (/ax%n, ay%n, aw%n/)
     j_wind = (/1, 1, 1/)
     n_wind = (/ax%n, ay%n, 1/)
     f_wind = (/0, indw-1, ish-1/)

     if (flag == "rite") then
        err = srite_window(filetag,n_dim_cube,n_cube,n_wind,f_wind,j_wind,8,crec)
        if (err.lt.0) call seperr("wem_fio_crec: trouble writing receiver wavefield")
     else if(flag == "reed") then
        crec = 0.
        err = sreed_window(filetag,n_dim_cube,n_cube,n_wind,f_wind,j_wind,8,crec)
        if (err.lt.0) call seperr("wem_fio_crec: trouble reading receiver wavefield")
     else
        call seperr("you have to specify the flag for wem_fio_crec()")
     end if
     return
   end subroutine


end module
