Module s2dw_fileio_mod

module s2dw_fileio_mod

        ! Uses
    use s2dw_types_mod
    use s2dw_error_mod
    use s2dw_core_mod

        ! Interfaces
    public interface s2dw_fileio_matlab_wav_write
    public interface s2dw_fileio_matlab_wav_read
    public interface s2dw_fileio_fits_wav_write
    public interface s2dw_fileio_fits_wav_read

        ! Subroutines and functions
    private subroutine s2dw_fileio_matlab_wav_write_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    private subroutine s2dw_fileio_matlab_wav_write_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    private subroutine s2dw_fileio_matlab_wav_read_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename)
    private subroutine s2dw_fileio_matlab_wav_read_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename)
    private subroutine s2dw_fileio_fits_wav_write_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    private subroutine s2dw_fileio_fits_wav_write_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    private subroutine s2dw_fileio_fits_wav_read_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename)
    private subroutine s2dw_fileio_fits_wav_read_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename)
    private subroutine s2dw_fileio_fits_error_check (status, halt)
    private subroutine s2dw_fileio_fits_exists (filename, status, exists)
    private subroutine s2dw_fileio_fits_del (filename, status)

end module s2dw_fileio_mod
Functionality to read and write S2DW formatted fits and matlab files containing wavelet and scaling coefficients. Both statically and dynamically allocated wavelet coefficients may be written and read from files (both data types have the same fits file format).

Author: J. D. McEwen (mcewen@mrao.cam.ac.uk)

Version: 0.1 November 2007


Description of Interfaces

s2dw_fileio_matlab_wav_write

public interface s2dw_fileio_matlab_wav_write
    module procedure s2dw_fileio_matlab_wav_write_static
    module procedure s2dw_fileio_matlab_wav_write_dynamic
end interface s2dw_fileio_matlab_wav_write

s2dw_fileio_matlab_wav_read

public interface s2dw_fileio_matlab_wav_read
    module procedure s2dw_fileio_matlab_wav_read_static
    module procedure s2dw_fileio_matlab_wav_read_dynamic
end interface s2dw_fileio_matlab_wav_read

s2dw_fileio_fits_wav_write

public interface s2dw_fileio_fits_wav_write
    module procedure s2dw_fileio_fits_wav_write_static
    module procedure s2dw_fileio_fits_wav_write_dynamic
end interface s2dw_fileio_fits_wav_write

s2dw_fileio_fits_wav_read

public interface s2dw_fileio_fits_wav_read
    module procedure s2dw_fileio_fits_wav_read_static
    module procedure s2dw_fileio_fits_wav_read_dynamic
end interface s2dw_fileio_fits_wav_read

Description of Subroutines and Functions

s2dw_fileio_matlab_wav_write_static

private subroutine s2dw_fileio_matlab_wav_write_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    real (kind=dp), intent(in), dimension (0:J, 0:2*B-2, 0:2*B-1, 0:N-1) :: wav
    complex (kind=dpc), intent(in), dimension (0:bl_scoeff-1, 0:bl_scoeff-1) :: scoeff
    integer, intent(in) :: J
    integer, intent(in) :: B
    integer, intent(in) :: N
    integer, intent(in) :: bl_scoeff
    real (kind=dp), intent(in) :: alpha
    character (len=*), intent(in) :: filename
    character (len=*), optional, intent(in) :: comment
end subroutine s2dw_fileio_matlab_wav_write_static
Writes (statically allocated) wavelet and scaling coefficients to an output S2DW formatted .m matlab file and corresponding .dat data files.

Variables:

Author: J. D. McEwen

Version: 0.1 - May 2008

s2dw_fileio_matlab_wav_write_dynamic

private subroutine s2dw_fileio_matlab_wav_write_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    type (s2dw_wav_abg), intent(in), allocatable, dimension (:) :: wavdyn
    complex (kind=dpc), intent(in), dimension (0:bl_scoeff-1, 0:bl_scoeff-1) :: scoeff
    integer, intent(in) :: J
    integer, intent(in) :: B
    integer, intent(in) :: N
    integer, intent(in) :: bl_scoeff
    real (kind=dp), intent(in) :: alpha
    character (len=*), intent(in) :: filename
    character (len=*), optional, intent(in) :: comment
end subroutine s2dw_fileio_matlab_wav_write_dynamic
Writes (dynamically allocated) wavelet and scaling coefficients to an output S2DW formatted .m matlab file ad corresponding data .dat file.

Variables:

Author: J. D. McEwen

Version: 0.1 - June 2008

s2dw_fileio_matlab_wav_read_static

private subroutine s2dw_fileio_matlab_wav_read_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename)
    real (kind=dp), allocatable, intent(out), dimension (:,:,:,:) :: wav
    complex (kind=dpc), allocatable, intent(out), dimension (:,:) :: scoeff
    integer, intent(out) :: J
    integer, intent(out) :: B
    integer, intent(out) :: N
    integer, intent(out) :: bl_scoeff
    real (kind=dp), intent(out) :: alpha
    character (len=*), intent(in) :: filename
    ! Calls: s2dw_error
end subroutine s2dw_fileio_matlab_wav_read_static
Reads (statically allocated) wavelet and scaling coefficients from a S2DW formatted .m matlab file and corresponding .dat data files.

Notes:

Variables:

Author: J. D. McEwen

Version: 0.1 - May 2008

s2dw_fileio_matlab_wav_read_dynamic

private subroutine s2dw_fileio_matlab_wav_read_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename)
    type (s2dw_wav_abg), intent(out), allocatable, dimension (:) :: wavdyn
    complex (kind=dpc), allocatable, intent(out), dimension (:,:) :: scoeff
    integer, intent(out) :: J
    integer, intent(out) :: B
    integer, intent(out) :: N
    integer, intent(out) :: bl_scoeff
    real (kind=dp), intent(out) :: alpha
    character (len=*), intent(in) :: filename
    ! Calls: s2dw_error
end subroutine s2dw_fileio_matlab_wav_read_dynamic
Reads (dynamically allocated) wavelet and scaling coefficients from a S2DW formatted .m matlab file and corresponding .dat data files.

Notes:

Variables:

Author: J. D. McEwen

Version: 0.1 - May 2008

s2dw_fileio_fits_wav_write_static

private subroutine s2dw_fileio_fits_wav_write_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    real (kind=dp), intent(in), dimension (0:J, 0:2*B-2, 0:2*B-1, 0:N-1) :: wav
    complex (kind=dpc), intent(in), dimension (0:bl_scoeff-1, 0:bl_scoeff-1) :: scoeff
    integer, intent(in) :: J
    integer, intent(in) :: B
    integer, intent(in) :: N
    integer, intent(in) :: bl_scoeff
    real (kind=dp), intent(in) :: alpha
    character (len=*), intent(in) :: filename
    character (len=*), optional, intent(in) :: comment
    ! Calls: ftclos, ftfiou, ftgiou, ftiimg, ftinit, ftp2dd, ftp3dd, ftpcom, ftpdat, ftphpr, ftpkyd, ftpkyj, ftpkys, s2dw_error, s2dw_fileio_fits_error_check, s2dw_fileio_fits_exists
end subroutine s2dw_fileio_fits_wav_write_static
Writes (statically allocated) wavelet and scaling coefficients to an output S2DW formatted fits file.

Variables:

Author: J. D. McEwen

Version: 0.1 - November 2007

s2dw_fileio_fits_wav_write_dynamic

private subroutine s2dw_fileio_fits_wav_write_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename, comment)
    type (s2dw_wav_abg), intent(in), allocatable, dimension (:) :: wavdyn
    complex (kind=dpc), intent(in), dimension (0:bl_scoeff-1, 0:bl_scoeff-1) :: scoeff
    integer, intent(in) :: J
    integer, intent(in) :: B
    integer, intent(in) :: N
    integer, intent(in) :: bl_scoeff
    real (kind=dp), intent(in) :: alpha
    character (len=*), intent(in) :: filename
    character (len=*), optional, intent(in) :: comment
    ! Calls: ftclos, ftfiou, ftgiou, ftiimg, ftinit, ftp2dd, ftp3dd, ftpcom, ftpdat, ftphpr, ftpkyd, ftpkyj, ftpkys, s2dw_error, s2dw_fileio_fits_error_check, s2dw_fileio_fits_exists
end subroutine s2dw_fileio_fits_wav_write_dynamic
Writes (dynamically allocated) wavelet and scaling coefficients to an output S2DW formatted fits file.

Variables:

Author: J. D. McEwen

Version: 0.1 - February 2008

s2dw_fileio_fits_wav_read_static

private subroutine s2dw_fileio_fits_wav_read_static (wav, scoeff, J, B, N, bl_scoeff, alpha, filename)
    real (kind=dp), allocatable, intent(out), dimension (:,:,:,:) :: wav
    complex (kind=dpc), allocatable, intent(out), dimension (:,:) :: scoeff
    integer, intent(out) :: J
    integer, intent(out) :: B
    integer, intent(out) :: N
    integer, intent(out) :: bl_scoeff
    real (kind=dp), intent(out) :: alpha
    character (len=*), intent(in) :: filename
    ! Calls: ftclos, ftfiou, ftg2dd, ftg3dd, ftgiou, ftgkyd, ftgkyj, ftmahd, ftopen, ftthdu, s2dw_error, s2dw_fileio_fits_error_check, s2dw_fileio_fits_exists
end subroutine s2dw_fileio_fits_wav_read_static
Reads (statically allocated) wavelet and scaling coefficients from a S2DW formatted fits file.

Notes:

Variables:

Author: J. D. McEwen

Version: 0.1 - November 2007

s2dw_fileio_fits_wav_read_dynamic

private subroutine s2dw_fileio_fits_wav_read_dynamic (wavdyn, scoeff, J, B, N, bl_scoeff, alpha, filename)
    type (s2dw_wav_abg), intent(out), allocatable, dimension (:) :: wavdyn
    complex (kind=dpc), allocatable, intent(out), dimension (:,:) :: scoeff
    integer, intent(out) :: J
    integer, intent(out) :: B
    integer, intent(out) :: N
    integer, intent(out) :: bl_scoeff
    real (kind=dp), intent(out) :: alpha
    character (len=*), intent(in) :: filename
    ! Calls: ftclos, ftfiou, ftg2dd, ftg3dd, ftgiou, ftgkyd, ftgkyj, ftmahd, ftopen, ftthdu, s2dw_error, s2dw_fileio_fits_error_check, s2dw_fileio_fits_exists
end subroutine s2dw_fileio_fits_wav_read_dynamic
Reads (dynamically allocated) wavelet and scaling coefficients from a S2DW formatted fits file.

Notes:

Variables:

Author: J. D. McEwen

Version: 0.1 - February 2008

s2dw_fileio_fits_error_check

private subroutine s2dw_fileio_fits_error_check (status, halt)
    integer, intent(inout) :: status
    logical, intent(in) :: halt
    ! Calls: ftgerr, ftgmsg
end subroutine s2dw_fileio_fits_error_check
Checks if a fits error has occured and print error message. Halt program execution if halt flag is set.

Variables:

Author: J. D. McEwen

Version: 0.1 - November 2007

s2dw_fileio_fits_exists

private subroutine s2dw_fileio_fits_exists (filename, status, exists)
    character (len=*), intent(in) :: filename
    integer, intent(inout) :: status
    logical, intent(out) :: exists
    ! Calls: ftclos, ftfiou, ftgiou, ftopen, s2dw_fileio_fits_error_check
end subroutine s2dw_fileio_fits_exists
Checks if a fits file exists.

Variables:

Author: J. D. McEwen

Version: 0.1 - November 2007

s2dw_fileio_fits_del

private subroutine s2dw_fileio_fits_del (filename, status)
    character (len=*), intent(in) :: filename
    integer, intent(inout) :: status
    ! Calls: ftcmsg, ftdelt, ftfiou, ftgiou, ftopen
end subroutine s2dw_fileio_fits_del
Deletes a fits file.

Variables:

Author: J. D. McEwen

Version: 0.1 - November 2007