Skip to content

Commit 6b38d61

Browse files
committedFeb 9, 2024
Merge branch '360-yaml-renames-fortran' into 'development'
make clear that functionality is YAML specific Closes #360 See merge request damask/DAMASK!878
2 parents fe2401a + 30efb0c commit 6b38d61

22 files changed

+405
-419
lines changed
 

‎src/IO.f90

+4-209
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,14 @@ module IO
2424
IO_WHITESPACE = achar(44)//achar(32)//achar(9)//achar(10)//achar(13), & !< whitespace characters
2525
IO_QUOTES = "'"//'"'
2626
character, parameter, public :: &
27-
IO_EOL = LF, & !< end of line character
28-
IO_COMMENT = '#'
27+
IO_EOL = LF !< end of line character
2928

3029
public :: &
3130
IO_init, &
3231
IO_selfTest, &
3332
IO_read, &
34-
IO_readlines, &
35-
IO_isBlank, &
3633
IO_wrapLines, &
37-
IO_strPos, &
38-
IO_strValue, &
39-
IO_intValue, &
40-
IO_realValue, &
4134
IO_lc, &
42-
IO_rmComment, &
4335
IO_glueDiffering, &
4436
IO_intAsStr, &
4537
IO_strAsInt, &
@@ -66,53 +58,6 @@ subroutine IO_init()
6658
end subroutine IO_init
6759

6860

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-
11661
!--------------------------------------------------------------------------------------------------
11762
!> @brief Read ASCII file.
11863
!> @details Proper Unix style (LF line endings and LF at EOF) is ensured.
@@ -149,22 +94,6 @@ function IO_read(fileName) result(fileContent)
14994
end function IO_read
15095

15196

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-
16897
!--------------------------------------------------------------------------------------------------
16998
!> @brief Insert EOL at separator trying to keep line length below limit.
17099
!--------------------------------------------------------------------------------------------------
@@ -210,89 +139,6 @@ function IO_wrapLines(str,separator,filler,length)
210139
end function IO_wrapLines
211140

212141

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-
296142
!--------------------------------------------------------------------------------------------------
297143
!> @brief Convert characters in string to lower case.
298144
!--------------------------------------------------------------------------------------------------
@@ -316,27 +162,6 @@ pure function IO_lc(str)
316162
end function IO_lc
317163

318164

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
340165

341166

342167
!--------------------------------------------------------------------------------------------------
@@ -614,8 +439,6 @@ subroutine IO_error(error_ID,ext_msg,label1,ID1,label2,ID2)
614439
msg = 'length mismatch'
615440
case (710)
616441
msg = 'closing quotation mark missing in string'
617-
case (711)
618-
msg = 'incorrect type'
619442

620443
!-------------------------------------------------------------------------------------------------
621444
! errors related to the mesh solver
@@ -695,9 +518,9 @@ subroutine IO_warning(warning_ID,ext_msg,label1,ID1,label2,ID2)
695518
end select
696519

697520
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)
701524

702525
end subroutine IO_warning
703526

@@ -846,17 +669,6 @@ subroutine IO_selfTest()
846669
if ('1234' /= IO_intAsStr(1234)) error stop 'IO_intAsStr'
847670
if ('-12' /= IO_intAsStr(-0012)) error stop 'IO_intAsStr'
848671

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-
860672
if (CRLF2LF('') /= '') error stop 'CRLF2LF/0'
861673
if (CRLF2LF(LF) /= LF) error stop 'CRLF2LF/1a'
862674
if (CRLF2LF(CR//LF) /= LF) error stop 'CRLF2LF/1b'
@@ -867,25 +679,8 @@ subroutine IO_selfTest()
867679
'A'//LF//'B'//LF) error stop 'CRLF2LF/4'
868680
if (CRLF2LF('A'//LF//CR//'B') /= 'A'//LF//CR//'B') error stop 'CRLF2LF/5'
869681

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-
874682
str='*(HiU!)3';if ('*(hiu!)3' /= IO_lc(str)) error stop 'IO_lc'
875683

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-
889684
if ('abc, def' /= IO_wrapLines('abc, def')) &
890685
error stop 'IO_wrapLines/1'
891686
if ('abc,'//IO_EOL//'def' /= IO_wrapLines('abc,def',length=3)) &

‎src/Marc/DAMASK_Marc.f90

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "../parallelization.f90"
2121
#include "../misc.f90"
2222
#include "../IO.f90"
23-
#include "../YAML_types.f90"
24-
#include "../YAML_parse.f90"
23+
#include "../types.f90"
24+
#include "../YAML.f90"
2525
#include "../HDF5_utilities.f90"
2626

2727
module DAMASK_interface
@@ -187,7 +187,7 @@ subroutine hypela2(d,g,e,de,s,t,dt,ngens,m,nn,kcus,matus,ndi,nshear,disp, &
187187
use prec
188188
use DAMASK_interface
189189
use config
190-
use YAML_types
190+
use types
191191
use discretization_Marc
192192
use homogenization
193193
use materialpoint_Marc

0 commit comments

Comments
 (0)
Failed to load comments.