|
|
|
@ -38,12 +38,14 @@
|
|
|
|
|
!
|
|
|
|
|
!
|
|
|
|
|
module data_input
|
|
|
|
|
use psb_base_mod, only : psb_spk_, psb_dpk_, psb_ipk_
|
|
|
|
|
|
|
|
|
|
interface read_data
|
|
|
|
|
module procedure read_char, read_int,&
|
|
|
|
|
& read_double, read_single,&
|
|
|
|
|
& read_double, read_single, read_logical,&
|
|
|
|
|
& string_read_char, string_read_int,&
|
|
|
|
|
& string_read_double, string_read_single
|
|
|
|
|
& string_read_double, string_read_single, &
|
|
|
|
|
& string_read_logical
|
|
|
|
|
end interface read_data
|
|
|
|
|
interface trim_string
|
|
|
|
|
module procedure trim_string
|
|
|
|
@ -54,9 +56,19 @@ module data_input
|
|
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
|
|
subroutine read_logical(val,file,marker)
|
|
|
|
|
logical, intent(out) :: val
|
|
|
|
|
integer(psb_ipk_), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
|
call read_data(val,charbuf,marker)
|
|
|
|
|
|
|
|
|
|
end subroutine read_logical
|
|
|
|
|
|
|
|
|
|
subroutine read_char(val,file,marker)
|
|
|
|
|
character(len=*), intent(out) :: val
|
|
|
|
|
integer, intent(in) :: file
|
|
|
|
|
integer(psb_ipk_), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
@ -65,8 +77,8 @@ contains
|
|
|
|
|
end subroutine read_char
|
|
|
|
|
|
|
|
|
|
subroutine read_int(val,file,marker)
|
|
|
|
|
integer, intent(out) :: val
|
|
|
|
|
integer, intent(in) :: file
|
|
|
|
|
integer(psb_ipk_), intent(out) :: val
|
|
|
|
|
integer(psb_ipk_), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
@ -74,9 +86,8 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine read_int
|
|
|
|
|
subroutine read_single(val,file,marker)
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
real(psb_spk_), intent(out) :: val
|
|
|
|
|
integer, intent(in) :: file
|
|
|
|
|
integer(psb_ipk_), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
@ -84,9 +95,8 @@ contains
|
|
|
|
|
|
|
|
|
|
end subroutine read_single
|
|
|
|
|
subroutine read_double(val,file,marker)
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
real(psb_dpk_), intent(out) :: val
|
|
|
|
|
integer, intent(in) :: file
|
|
|
|
|
integer(psb_ipk_), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
@ -100,7 +110,7 @@ contains
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
character(len=1024) :: charbuf
|
|
|
|
|
integer :: idx
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
@ -114,12 +124,12 @@ contains
|
|
|
|
|
end subroutine string_read_char
|
|
|
|
|
|
|
|
|
|
subroutine string_read_int(val,file,marker)
|
|
|
|
|
integer, intent(out) :: val
|
|
|
|
|
integer(psb_ipk_), intent(out) :: val
|
|
|
|
|
character(len=*), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
character(len=1024) :: charbuf
|
|
|
|
|
integer :: idx
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
@ -131,14 +141,14 @@ contains
|
|
|
|
|
if (idx == 0) idx = len(charbuf)+1
|
|
|
|
|
read(charbuf(1:idx-1),*) val
|
|
|
|
|
end subroutine string_read_int
|
|
|
|
|
|
|
|
|
|
subroutine string_read_single(val,file,marker)
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
real(psb_spk_), intent(out) :: val
|
|
|
|
|
character(len=*), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
character(len=1024) :: charbuf
|
|
|
|
|
integer :: idx
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
@ -150,14 +160,14 @@ contains
|
|
|
|
|
if (idx == 0) idx = len(charbuf)+1
|
|
|
|
|
read(charbuf(1:idx-1),*) val
|
|
|
|
|
end subroutine string_read_single
|
|
|
|
|
|
|
|
|
|
subroutine string_read_double(val,file,marker)
|
|
|
|
|
use psb_base_mod
|
|
|
|
|
real(psb_dpk_), intent(out) :: val
|
|
|
|
|
character(len=*), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
character(len=1024) :: charbuf
|
|
|
|
|
integer :: idx
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
@ -170,12 +180,31 @@ contains
|
|
|
|
|
read(charbuf(1:idx-1),*) val
|
|
|
|
|
end subroutine string_read_double
|
|
|
|
|
|
|
|
|
|
subroutine string_read_logical(val,file,marker)
|
|
|
|
|
logical, intent(out) :: val
|
|
|
|
|
character(len=*), intent(in) :: file
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
character(len=1024) :: charbuf
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
|
marker_ = def_marker
|
|
|
|
|
end if
|
|
|
|
|
read(file,'(a)')charbuf
|
|
|
|
|
charbuf = adjustl(charbuf)
|
|
|
|
|
idx=index(charbuf,marker_)
|
|
|
|
|
if (idx == 0) idx = len(charbuf)+1
|
|
|
|
|
read(charbuf(1:idx-1),*) val
|
|
|
|
|
end subroutine string_read_logical
|
|
|
|
|
|
|
|
|
|
function trim_string(string,marker)
|
|
|
|
|
character(len=*), intent(in) :: string
|
|
|
|
|
character(len=1), optional, intent(in) :: marker
|
|
|
|
|
character(len=len(string)) :: trim_string
|
|
|
|
|
character(len=1) :: marker_
|
|
|
|
|
integer :: idx
|
|
|
|
|
integer(psb_ipk_) :: idx
|
|
|
|
|
if (present(marker)) then
|
|
|
|
|
marker_ = marker
|
|
|
|
|
else
|
|
|
|
|