15 #include "sll_working_precision.h"
39 character(len=*),
intent(in) :: filename
43 open (newunit=iunit, file=filename, status=
'OLD')
44 close (iunit, status=
'DELETE')
51 character(len=*),
intent(in) :: filename
52 character(len=:),
allocatable,
intent(out) :: str
54 integer :: iunit, istat, filesize
58 open (newunit=iunit, file=filename, status=
'OLD', &
59 form=
'UNFORMATTED', access=
'STREAM')
62 inquire (file=filename, size=filesize)
63 if (filesize < 0)
then
64 write (*, *)
'ERROR: negative file size'
69 allocate (
character(len=filesize) :: str)
70 read (iunit, pos=1) str
73 read (iunit, pos=filesize + 1, iostat=istat) c
74 if (.not. is_iostat_end(istat))
then
75 write (*, *)
'Error: file was not completely read'
80 close (iunit, iostat=istat)
87 character(len=*),
intent(in) :: filename1
88 character(len=*),
intent(in) :: filename2
91 character(len=:),
allocatable :: str1
92 character(len=:),
allocatable :: str2
97 equal = (str1 == str2)
104 character(len=*),
intent(in) :: filename
109 inquire (file=filename, size=filesize)
110 empty = (filesize == 0)
119 sll_int32,
intent(in) :: ints(:)
120 character(len=:),
allocatable,
intent(out) :: str
122 sll_int32 :: i, ni, nc, lc, str_len
123 character(len=11),
allocatable :: tmp(:)
124 sll_int32,
allocatable :: ints_len(:)
129 allocate (ints_len(ni))
134 write (tmp(i),
'(i11)') ints(i)
135 tmp(i) = adjustl(tmp(i))
136 ints_len(i) = len_trim(tmp(i), i32)
140 str_len = sum(ints_len) + ni - 1
141 allocate (
character(len=str_len) :: str)
147 str(lc + 1:lc + nc) = trim(tmp(i))
150 str(lc + 1:lc + 1) =
' '
160 character(len=*),
intent(in) :: path
161 character(len=*),
intent(out) :: head
162 character(len=*),
intent(out) :: tail
168 nc = len_trim(path, i32)
171 if (path(nc:nc) ==
'/')
then
178 if (path(i:i) ==
'/')
then
180 tail = path(i + 1:nc)
194 character(len=*),
intent(in) :: filename
195 sll_real64,
intent(out) ::
data(:)
199 open (newunit=iunit, file=trim(filename), status=
"old", action=
"read")
200 read (unit=iunit, fmt=*)
data
213 character(len=*),
intent(in) :: filename
214 character(len=*),
intent(in) :: otherfile
215 character(len=*),
intent(out) :: filepath
219 ipath = scan(otherfile,
"/", back=.true.)
220 filepath = trim(otherfile(1:ipath))//filename
Collection of functions/subroutines operating on files and strings.
subroutine, public sll_s_read_data_real_array(filename, data)
Read data from file to real array.
logical function, public sll_f_check_equal_files(filename1, filename2)
subroutine, public sll_s_ints_to_string(ints, str)
Write an array of integers to a single string: . Numbers are separated by a blank space; ....
subroutine, public sll_s_remove_file(filename)
Remove file (dangerous function!)
subroutine, public sll_s_split_path(path, head, tail)
Split path into head (directory) and tail (file)
logical function, public sll_f_check_empty_file(filename)
Return True if file is empty, False otherwise.
subroutine, public sll_s_read_file(filename, str)
Read whole file content into allocatable string.
subroutine, public sll_s_concatenate_filename_and_path(filename, otherfile, filepath)
Concatenate filename and path where path is extracted from another file name Example use: call sll_s_...