1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/IO.f90"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/IO.f90"
17 character(len=*),
parameter,
public :: &
18 io_eof =
'#EOF#', & !< end of file string
19 io_whitespace = achar(44)//achar(32)//achar(9)//achar(10)//achar(13)
20 character,
parameter,
public :: &
21 io_eol = new_line(
'DAMASK'), &
23 character(len=*),
parameter,
private :: &
25 '───────────────────'//&
26 '───────────────────'//&
50 write(6,
'(/,a)')
' <<<+- IO init -+>>>';
flush(6)
62 character(len=*),
intent(in) :: filename
64 character(len=pStringLen),
dimension(:),
allocatable :: filecontent
65 character(len=pStringLen) :: line
66 character(len=:),
allocatable :: rawdata
71 mytotallines, & !< # lines read from file
78 inquire(file = filename, size=filelength)
79 if (filelength == 0)
then
80 allocate(filecontent(0))
83 open(newunit=fileunit, file=filename, access=
'stream',&
84 status=
'old', position=
'rewind', action=
'read',iostat=mystat)
85 if(mystat /= 0)
call io_error(100,ext_msg=trim(filename))
86 allocate(
character(len=fileLength)::rawdata)
87 read(fileunit) rawdata
94 if (rawdata(l:l) ==
io_eol) mytotallines = mytotallines+1
96 allocate(filecontent(mytotallines))
103 do while (l <= mytotallines)
104 endpos = merge(startpos + scan(rawdata(startpos:),
io_eol) - 2,len(rawdata),l /= mytotallines)
106 line = rawdata(startpos:startpos+
pstringlen-1)
107 if (.not. warned)
then
108 call io_warning(207,ext_msg=trim(filename),el=l)
112 line = rawdata(startpos:endpos)
114 startpos = endpos + 2
116 filecontent(l) = line
129 character(len=*),
intent(in) :: filename
130 character,
intent(in),
optional :: mode
135 if (
present(mode))
then
143 status=
'replace',access=
'stream',action=
'write',iostat=ierr)
144 if (ierr /= 0)
call io_error(100,ext_msg=
'could not open file (w): '//trim(filename))
145 elseif(m ==
'r')
then
147 status=
'old', access=
'stream',action=
'read', iostat=ierr)
148 if (ierr /= 0)
call io_error(100,ext_msg=
'could not open file (r): '//trim(filename))
150 call io_error(100,ext_msg=
'unknown access mode: '//m)
161 character(len=*),
intent(in) :: string
163 integer :: posnonblank
174 pure function io_gettag(string,openChar,closeChar)
176 character(len=*),
intent(in) :: string
177 character,
intent(in) :: openchar, & !< indicates beginning of tag
179 character(len=:),
allocatable ::
io_gettag
181 integer :: left,right
183 left = scan(string,openchar)
184 right = merge(scan(string,closechar), &
185 left + merge(scan(string(left+1:),openchar),0,len(string) > left), &
186 openchar /= closechar)
188 foundtag:
if (left == verify(string,
io_whitespace) .and. right > left)
then
205 character(len=*),
intent(in) :: string
208 integer :: left, right
219 endofstring:
if (right < left)
then
233 character(len=*),
intent(in) :: string
234 integer,
dimension(:),
intent(in) :: chunkpos
235 integer,
intent(in) :: mychunk
238 validchunk:
if (mychunk > chunkpos(1) .or. mychunk < 1)
then
240 call io_error(110,el=mychunk,ext_msg=
'IO_stringValue: "'//trim(string)//
'"')
242 io_stringvalue = string(chunkpos(mychunk*2):chunkpos(mychunk*2+1))
251 integer function io_intvalue(string,chunkPos,myChunk)
253 character(len=*),
intent(in) :: string
254 integer,
dimension(:),
intent(in) :: chunkpos
255 integer,
intent(in) :: mychunk
267 character(len=*),
intent(in) :: string
268 integer,
dimension(:),
intent(in) :: chunkpos
269 integer,
intent(in) :: mychunk
279 pure function io_lc(string)
281 character(len=*),
intent(in) :: string
282 character(len=len(string)) ::
io_lc
284 character(len=*),
parameter :: lower =
'abcdefghijklmnopqrstuvwxyz'
285 character(len=len(LOWER)),
parameter :: upper =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
290 n = index(upper,string(i:i))
292 io_lc(i:i) = lower(n:n)
294 io_lc(i:i) = string(i:i)
304 subroutine io_error(error_ID,el,ip,g,instance,ext_msg)
306 integer,
intent(in) :: error_id
307 integer,
optional,
intent(in) :: el,ip,g,instance
308 character(len=*),
optional,
intent(in) :: ext_msg
311 character(len=pStringLen) :: msg
312 character(len=pStringLen) :: formatstring
314 select case (error_id)
319 msg =
'internal check failed:'
324 msg =
'could not open file:'
326 msg =
'write error for file:'
328 msg =
'could not read file:'
330 msg =
'could not assemble input files'
332 msg =
'working directory does not exist:'
337 msg =
'invalid chunk selected'
339 msg =
'invalid character for int:'
341 msg =
'invalid character for float:'
346 msg =
'unknown lattice structure encountered'
348 msg =
'hex lattice structure with invalid c/a ratio'
350 msg =
'trans_lattice_structure not possible'
352 msg =
'transformed hex lattice structure with invalid c/a ratio'
354 msg =
'negative lattice parameter'
356 msg =
'zero entry on stiffness diagonal'
358 msg =
'zero entry on stiffness diagonal for transformed phase'
360 msg =
'not defined for lattice structure'
362 msg =
'not enough interaction parameters given'
367 msg =
'key not found'
369 msg =
'number of chunks in string differs'
373 msg =
'no value found for key'
375 msg =
'negative number systems requested'
377 msg =
'too many systems requested'
379 msg =
'number of values does not match'
381 msg =
'not supported anymore'
383 msg =
'Nconstituents mismatch between homogenization and microstructure'
388 msg =
'index out of bounds'
390 msg =
'microstructure has no constituents'
392 msg =
'sum of phase fractions differs from 1'
394 msg =
'homogenization index out of bounds'
396 msg =
'microstructure index out of bounds'
398 msg =
'invalid texture transformation specified'
400 msg =
'no entries in config part'
402 msg =
'config part found twice'
404 msg =
'homogenization configuration'
406 msg =
'no homogenization specified via State Variable 2'
408 msg =
'no microstructure specified via State Variable 3'
410 msg =
'unknown element type:'
412 msg =
'mesh consists of more than one element type'
417 msg =
'unknown elasticity specified:'
419 msg =
'unknown plasticity specified:'
422 msg =
'unknown material parameter:'
424 msg =
'material parameter out of bounds:'
429 msg =
'unknown numerics parameter:'
431 msg =
'numerics parameter out of bounds:'
436 msg =
'matrix inversion error'
438 msg =
'error in Eigenvalue calculation'
440 msg =
'invalid orientation specified'
445 msg =
'unknown homogenization specified'
450 msg =
'Ping-Pong not possible when using non-DAMASK elements'
452 msg =
'Ping-Pong needed when using non-local plasticity'
454 msg =
'invalid selection for debug'
459 msg =
'initializing FFTW'
461 msg =
'FFTW plan creation'
463 msg =
'mask consistency violated in grid load case'
465 msg =
'ill-defined L (line partly defined) in grid load case'
467 msg =
'negative time increment in grid load case'
469 msg =
'non-positive increments in grid load case'
471 msg =
'non-positive result frequency in grid load case'
473 msg =
'incomplete loadcase'
475 msg =
'mixed boundary conditions allow rotation'
477 msg =
'non-positive restart frequency in grid load case'
479 msg =
'missing header length info in grid mesh'
481 msg =
'incomplete information in grid mesh header'
483 msg =
'microstructure count mismatch'
485 msg =
'rotation for load case rotation ill-defined (R:RT != I)'
487 msg =
'unknown solver type selected'
489 msg =
'unknown filter type selected'
497 msg =
'unknown error number...'
503 write(0,
'(a,24x,a,40x,a)')
' │',
'error',
'│'
504 write(0,
'(a,24x,i3,42x,a)')
' │',error_id,
'│'
506 write(formatstring,
'(a,i6.6,a,i6.6,a)')
'(1x,a4,a',max(1,len_trim(msg)),
',',&
507 max(1,72-len_trim(msg)-4),
'x,a)'
508 write(0,formatstring)
'│ ',trim(msg),
'│'
509 if (
present(ext_msg))
then
510 write(formatstring,
'(a,i6.6,a,i6.6,a)')
'(1x,a4,a',max(1,len_trim(ext_msg)),
',',&
511 max(1,72-len_trim(ext_msg)-4),
'x,a)'
512 write(0,formatstring)
'│ ',trim(ext_msg),
'│'
515 write(0,
'(a19,1x,i9,44x,a3)')
' │ at element ',el,
'│'
517 write(0,
'(a19,1x,i9,44x,a3)')
' │ at IP ',ip,
'│'
519 write(0,
'(a19,1x,i9,44x,a3)')
' │ at constituent',g,
'│'
520 if (
present(instance)) &
521 write(0,
'(a19,1x,i9,44x,a3)')
' │ at instance ',instance,
'│'
522 write(0,
'(a,69x,a)')
' │',
'│'
525 call quit(9000+error_id)
534 subroutine io_warning(warning_ID,el,ip,g,ext_msg)
536 integer,
intent(in) :: warning_id
537 integer,
optional,
intent(in) :: el,ip,g
538 character(len=*),
optional,
intent(in) :: ext_msg
540 character(len=pStringLen) :: msg
541 character(len=pStringLen) :: formatstring
543 select case (warning_id)
547 msg =
'invalid restart increment given'
549 msg =
'could not get $DAMASK_NUM_THREADS'
551 msg =
'found spectral solver parameter'
553 msg =
'parameter has no effect'
555 msg =
'main diagonal of C66 close to zero'
557 msg =
'no valid parameter for FFTW, using FFTW_PATIENT'
559 msg =
'not all available slip system families are defined'
561 msg =
'not all available twin system families are defined'
563 msg =
'not all available parameters are defined'
565 msg =
'not all available transformation system families are defined'
567 msg =
'crystallite debugging off'
569 msg =
'position not found when parsing line'
571 msg =
'line truncated'
573 msg =
'crystallite responds elastically'
575 msg =
'stiffness close to zero'
577 msg =
'polar decomposition failed'
579 msg =
'unknown crystal symmetry'
581 msg =
'max number of cut back exceeded, terminating'
583 msg =
'unknown warning number'
588 write(6,
'(a,24x,a,38x,a)')
' │',
'warning',
'│'
589 write(6,
'(a,24x,i3,42x,a)')
' │',warning_id,
'│'
591 write(formatstring,
'(a,i6.6,a,i6.6,a)')
'(1x,a4,a',max(1,len_trim(msg)),
',',&
592 max(1,72-len_trim(msg)-4),
'x,a)'
593 write(6,formatstring)
'│ ',trim(msg),
'│'
594 if (
present(ext_msg))
then
595 write(formatstring,
'(a,i6.6,a,i6.6,a)')
'(1x,a4,a',max(1,len_trim(ext_msg)),
',',&
596 max(1,72-len_trim(ext_msg)-4),
'x,a)'
597 write(6,formatstring)
'│ ',trim(ext_msg),
'│'
600 write(6,
'(a19,1x,i9,44x,a3)')
' │ at element ',el,
'│'
602 write(6,
'(a19,1x,i9,44x,a3)')
' │ at IP ',ip,
'│'
604 write(6,
'(a19,1x,i9,44x,a3)')
' │ at constituent',g,
'│'
605 write(6,
'(a,69x,a)')
' │',
'│'
621 character(len=*),
intent(in) :: string
623 integer :: readstatus
624 character(len=*),
parameter :: validchars =
'0123456789+- '
626 valid:
if (verify(string,validchars) == 0)
then
628 if (readstatus /= 0)
call io_error(111,ext_msg=string)
642 character(len=*),
intent(in) :: string
644 integer :: readstatus
645 character(len=*),
parameter :: validchars =
'0123456789eE.+- '
647 valid:
if (verify(string,validchars) == 0)
then
649 if (readstatus /= 0)
call io_error(112,ext_msg=string)
663 integer,
dimension(:),
allocatable :: chunkPos
664 character(len=:),
allocatable :: str