@@ -24,22 +24,14 @@ module IO
24
24
IO_WHITESPACE = achar (44 )// achar (32 )// achar (9 )// achar (10 )// achar (13 ), & ! < whitespace characters
25
25
IO_QUOTES = " '" // ' "'
26
26
character , parameter , public :: &
27
- IO_EOL = LF, & ! < end of line character
28
- IO_COMMENT = ' #'
27
+ IO_EOL = LF ! < end of line character
29
28
30
29
public :: &
31
30
IO_init, &
32
31
IO_selfTest, &
33
32
IO_read, &
34
- IO_readlines, &
35
- IO_isBlank, &
36
33
IO_wrapLines, &
37
- IO_strPos, &
38
- IO_strValue, &
39
- IO_intValue, &
40
- IO_realValue, &
41
34
IO_lc, &
42
- IO_rmComment, &
43
35
IO_glueDiffering, &
44
36
IO_intAsStr, &
45
37
IO_strAsInt, &
@@ -66,53 +58,6 @@ subroutine IO_init()
66
58
end subroutine IO_init
67
59
68
60
69
- !- -------------------------------------------------------------------------------------------------
70
- ! > @brief Read ASCII file and split at EOL.
71
- !- -------------------------------------------------------------------------------------------------
72
- function IO_readlines (fileName ) result(fileContent)
73
-
74
- character (len=* ), intent (in ) :: fileName
75
- character (len= pSTRLEN), dimension (:), allocatable :: fileContent ! < file content, separated per lines
76
-
77
- character (len= pSTRLEN) :: line
78
- character (len= :), allocatable :: rawData
79
- integer :: &
80
- startPos, endPos, &
81
- N_lines, & ! < # lines in file
82
- l
83
- logical :: warned
84
-
85
-
86
- rawData = IO_read(fileName)
87
-
88
- N_lines = count ([(rawData(l:l) == IO_EOL,l= 1 ,len (rawData))])
89
- allocate (fileContent(N_lines))
90
-
91
- !- -------------------------------------------------------------------------------------------------
92
- ! split raw data at end of line
93
- warned = .false.
94
- startPos = 1
95
- l = 1
96
- do while (l <= N_lines)
97
- endPos = startPos + scan (rawData(startPos:),IO_EOL) - 2
98
- if (endPos - startPos > pSTRLEN-1 ) then
99
- line = rawData(startPos:startPos+ pSTRLEN-1 )
100
- if (.not. warned) then
101
- call IO_warning(207 ,trim (fileName),label1= ' line' ,ID1= l)
102
- warned = .true.
103
- end if
104
- else
105
- line = rawData(startPos:endpos)
106
- end if
107
- startPos = endPos + 2 ! jump to next line start
108
-
109
- fileContent(l) = trim (line)// ' '
110
- l = l + 1
111
- end do
112
-
113
- end function IO_readlines
114
-
115
-
116
61
!- -------------------------------------------------------------------------------------------------
117
62
! > @brief Read ASCII file.
118
63
! > @details Proper Unix style (LF line endings and LF at EOF) is ensured.
@@ -149,22 +94,6 @@ function IO_read(fileName) result(fileContent)
149
94
end function IO_read
150
95
151
96
152
- !- -------------------------------------------------------------------------------------------------
153
- ! > @brief Identifiy strings without content.
154
- !- -------------------------------------------------------------------------------------------------
155
- logical pure function IO_isBlank(str)
156
-
157
- character (len=* ), intent (in ) :: str ! < string to check for content
158
-
159
- integer :: posNonBlank
160
-
161
-
162
- posNonBlank = verify (str,IO_WHITESPACE)
163
- IO_isBlank = posNonBlank == 0 .or. posNonBlank == scan (str,IO_COMMENT)
164
-
165
- end function IO_isBlank
166
-
167
-
168
97
!- -------------------------------------------------------------------------------------------------
169
98
! > @brief Insert EOL at separator trying to keep line length below limit.
170
99
!- -------------------------------------------------------------------------------------------------
@@ -210,89 +139,6 @@ function IO_wrapLines(str,separator,filler,length)
210
139
end function IO_wrapLines
211
140
212
141
213
- !- -------------------------------------------------------------------------------------------------
214
- ! > @brief Locate all whitespace-separated chunks in given string and returns array containing
215
- ! ! number them and the left/right position to be used by IO_xxxVal.
216
- ! ! Array size is dynamically adjusted to number of chunks found in string
217
- ! ! IMPORTANT: first element contains number of chunks!
218
- !- -------------------------------------------------------------------------------------------------
219
- pure function IO_strPos (str )
220
-
221
- character (len=* ), intent (in ) :: str ! < string in which chunk positions are searched for
222
- integer , dimension (:), allocatable :: IO_strPos
223
-
224
- integer :: left, right
225
-
226
-
227
- allocate (IO_strPos(1 ), source= 0 )
228
- right = 0
229
-
230
- do while (verify (str(right+1 :),IO_WHITESPACE)>0 )
231
- left = right + verify (str(right+1 :),IO_WHITESPACE)
232
- right = left + scan (str(left:),IO_WHITESPACE) - 2
233
- if ( str(left:left) == IO_COMMENT) exit
234
- IO_strPos = [IO_strPos,left,right]
235
- IO_strPos(1 ) = IO_strPos(1 )+ 1
236
- endOfStr: if (right < left) then
237
- IO_strPos(IO_strPos(1 )* 2+1 ) = len_trim (str)
238
- exit
239
- end if endOfStr
240
- end do
241
-
242
- end function IO_strPos
243
-
244
-
245
- !- -------------------------------------------------------------------------------------------------
246
- ! > @brief Read string value at myChunk from string.
247
- !- -------------------------------------------------------------------------------------------------
248
- function IO_strValue (str ,chunkPos ,myChunk )
249
-
250
- character (len=* ), intent (in ) :: str ! < raw input with known start and end of each chunk
251
- integer , dimension (:), intent (in ) :: chunkPos ! < positions of start and end of each tag/chunk in given string
252
- integer , intent (in ) :: myChunk ! < position number of desired chunk
253
- character (len= :), allocatable :: IO_strValue
254
-
255
-
256
- validChunk: if (myChunk > chunkPos(1 ) .or. myChunk < 1 ) then
257
- IO_strValue = ' '
258
- call IO_error(110 ,' IO_strValue: "' // trim (str)// ' "' ,label1= ' chunk' ,ID1= myChunk)
259
- else validChunk
260
- IO_strValue = str(chunkPos(myChunk* 2 ):chunkPos(myChunk* 2+1 ))
261
- end if validChunk
262
-
263
- end function IO_strValue
264
-
265
-
266
- !- -------------------------------------------------------------------------------------------------
267
- ! > @brief Read integer value at myChunk from string.
268
- !- -------------------------------------------------------------------------------------------------
269
- integer function IO_intValue (str ,chunkPos ,myChunk )
270
-
271
- character (len=* ), intent (in ) :: str ! < raw input with known start and end of each chunk
272
- integer , dimension (:), intent (in ) :: chunkPos ! < positions of start and end of each tag/chunk in given string
273
- integer , intent (in ) :: myChunk ! < position number of desired chunk
274
-
275
-
276
- IO_intValue = IO_strAsInt(IO_strValue(str,chunkPos,myChunk))
277
-
278
- end function IO_intValue
279
-
280
-
281
- !- -------------------------------------------------------------------------------------------------
282
- ! > @brief Read real value at myChunk from string.
283
- !- -------------------------------------------------------------------------------------------------
284
- real(pREAL) function IO_realValue (str ,chunkPos ,myChunk )
285
-
286
- character (len=* ), intent (in ) :: str ! < raw input with known start and end of each chunk
287
- integer , dimension (:), intent (in ) :: chunkPos ! < positions of start and end of each tag/chunk in given string
288
- integer , intent (in ) :: myChunk ! < position number of desired chunk
289
-
290
-
291
- IO_realValue = IO_strAsReal(IO_strValue(str,chunkPos,myChunk))
292
-
293
- end function IO_realValue
294
-
295
-
296
142
!- -------------------------------------------------------------------------------------------------
297
143
! > @brief Convert characters in string to lower case.
298
144
!- -------------------------------------------------------------------------------------------------
@@ -316,27 +162,6 @@ pure function IO_lc(str)
316
162
end function IO_lc
317
163
318
164
319
- !- -------------------------------------------------------------------------------------------------
320
- ! @brief Remove comments (characters beyond '#') and trailing space.
321
- ! ToDo: Discuss name (the trim aspect is not clear)
322
- !- -------------------------------------------------------------------------------------------------
323
- function IO_rmComment (line )
324
-
325
- character (len=* ), intent (in ) :: line
326
- character (len= :), allocatable :: IO_rmComment
327
-
328
- integer :: split
329
-
330
-
331
- split = index (line,IO_COMMENT)
332
-
333
- if (split == 0 ) then
334
- IO_rmComment = trim (line)
335
- else
336
- IO_rmComment = trim (line(:split-1 ))
337
- end if
338
-
339
- end function IO_rmComment
340
165
341
166
342
167
!- -------------------------------------------------------------------------------------------------
@@ -614,8 +439,6 @@ subroutine IO_error(error_ID,ext_msg,label1,ID1,label2,ID2)
614
439
msg = ' length mismatch'
615
440
case (710 )
616
441
msg = ' closing quotation mark missing in string'
617
- case (711 )
618
- msg = ' incorrect type'
619
442
620
443
!- ------------------------------------------------------------------------------------------------
621
444
! errors related to the mesh solver
@@ -695,9 +518,9 @@ subroutine IO_warning(warning_ID,ext_msg,label1,ID1,label2,ID2)
695
518
end select
696
519
697
520
call panel(' warning' ,warning_ID,msg, &
698
- ext_msg= ext_msg, &
699
- label1= label1,ID1= ID1, &
700
- label2= label2,ID2= ID2)
521
+ ext_msg= ext_msg, &
522
+ label1= label1,ID1= ID1, &
523
+ label2= label2,ID2= ID2)
701
524
702
525
end subroutine IO_warning
703
526
@@ -846,17 +669,6 @@ subroutine IO_selfTest()
846
669
if (' 1234' /= IO_intAsStr(1234 )) error stop ' IO_intAsStr'
847
670
if (' -12' /= IO_intAsStr(- 0012 )) error stop ' IO_intAsStr'
848
671
849
- if (any ([1 ,1 ,1 ] /= IO_strPos(' a' ))) error stop ' IO_strPos'
850
- if (any ([2 ,2 ,3 ,5 ,5 ] /= IO_strPos(' aa b' ))) error stop ' IO_strPos'
851
-
852
- str = ' 1.0 xxx'
853
- chunkPos = IO_strPos(str)
854
- if (dNeq(1.0_pREAL ,IO_realValue(str,chunkPos,1 ))) error stop ' IO_realValue'
855
-
856
- str = ' M 3112019 F'
857
- chunkPos = IO_strPos(str)
858
- if (3112019 /= IO_intValue(str,chunkPos,2 )) error stop ' IO_intValue'
859
-
860
672
if (CRLF2LF(' ' ) /= ' ' ) error stop ' CRLF2LF/0'
861
673
if (CRLF2LF(LF) /= LF) error stop ' CRLF2LF/1a'
862
674
if (CRLF2LF(CR// LF) /= LF) error stop ' CRLF2LF/1b'
@@ -867,25 +679,8 @@ subroutine IO_selfTest()
867
679
' A' // LF// ' B' // LF) error stop ' CRLF2LF/4'
868
680
if (CRLF2LF(' A' // LF// CR// ' B' ) /= ' A' // LF// CR// ' B' ) error stop ' CRLF2LF/5'
869
681
870
- str= ' ' ; if (.not. IO_isBlank(str)) error stop ' IO_isBlank/1'
871
- str= ' #isBlank' ;if (.not. IO_isBlank(str)) error stop ' IO_isBlank/2'
872
- str= ' i#s' ; if ( IO_isBlank(str)) error stop ' IO_isBlank/3'
873
-
874
682
str= ' *(HiU!)3' ;if (' *(hiu!)3' /= IO_lc(str)) error stop ' IO_lc'
875
683
876
- str= ' #' ;out = IO_rmComment(str)
877
- if (out /= ' ' .or. len (out ) /= 0 ) error stop ' IO_rmComment/1'
878
- str= ' #' ;out = IO_rmComment(str)
879
- if (out /= ' ' .or. len (out ) /= 0 ) error stop ' IO_rmComment/2'
880
- str= ' # ' ;out = IO_rmComment(str)
881
- if (out /= ' ' .or. len (out ) /= 0 ) error stop ' IO_rmComment/3'
882
- str= ' # a' ;out = IO_rmComment(str)
883
- if (out /= ' ' .or. len (out ) /= 0 ) error stop ' IO_rmComment/4'
884
- str= ' a#' ;out = IO_rmComment(str)
885
- if (out /= ' a' .or. len (out ) /= 2 ) error stop ' IO_rmComment/5'
886
- str= ' ab #' ;out = IO_rmComment(str)
887
- if (out /= ' ab' .or. len (out ) /= 3 ) error stop ' IO_rmComment/6'
888
-
889
684
if (' abc, def' /= IO_wrapLines(' abc, def' )) &
890
685
error stop ' IO_wrapLines/1'
891
686
if (' abc,' // IO_EOL// ' def' /= IO_wrapLines(' abc,def' ,length= 3 )) &
0 commit comments