DAMASK with grid solvers  Revision: v2.0.3-2204-gdb1f2151
The Düsseldorf Advanced Material Simulation Kit with Grid Solvers
debug.f90
Go to the documentation of this file.
1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/debug.f90"
2 # 1 "<built-in>"
3 # 1 "<command-line>"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/debug.f90"
5 !--------------------------------------------------------------------------------------------------
11 !--------------------------------------------------------------------------------------------------
12 module debug
13  use prec
14  use io
15 
16  implicit none
17  private
18 
19  integer, parameter, public :: &
20  debug_levelselective = 2**0, &
21  debug_levelbasic = 2**1, &
23  integer, parameter, private :: &
24  debug_maxgeneral = debug_levelextensive ! must be set to the last bitcode used by (potentially) all debug types
25  integer, parameter, public :: &
31 
32  integer, parameter, public :: &
33  debug_debug = 1, &
34  debug_math = 2, &
35  debug_fesolving = 3, &
36  debug_mesh = 4, &
37  debug_material = 5, &
38  debug_lattice = 6, &
39  debug_constitutive = 7, &
40  debug_crystallite = 8, &
42  debug_cpfem = 10, &
43  debug_spectral = 11, &
44  debug_marc = 12
45  integer, parameter, private :: &
47 
48  integer,protected, dimension(debug_maxNtype+2), public :: & ! specific ones, and 2 for "all" and "other"
49  debug_level = 0
50 
51  integer, protected, public :: &
52  debug_e = 1, &
53  debug_i = 1, &
54  debug_g = 1
55 
56  integer, dimension(2), public :: &
61 
62 
63  real(preal), public :: &
64  debug_stressmax = -huge(1.0_preal), &
65  debug_stressmin = huge(1.0_preal), &
66  debug_jacobianmax = -huge(1.0_preal), &
67  debug_jacobianmin = huge(1.0_preal)
68 
69 
70  character(len=1024), parameter, public :: &
71  petscdebug = ' -snes_view -snes_monitor '
72 
73  public :: debug_init, &
74  debug_reset, &
76 
77 contains
78 
79 
80 !--------------------------------------------------------------------------------------------------
82 !--------------------------------------------------------------------------------------------------
83 subroutine debug_init
84 
85  character(len=pStringLen), dimension(:), allocatable :: filecontent
86 
87  integer :: i, what, j
88  integer, allocatable, dimension(:) :: chunkpos
89  character(len=pStringLen) :: tag, line
90  logical :: fexist
91 
92  write(6,'(/,a)') ' <<<+- debug init -+>>>'
93 
94 
95 
96 
97 
98  inquire(file='debug.config', exist=fexist)
99 
100  fileexists: if (fexist) then
101  filecontent = io_read_ascii('debug.config')
102  do j=1, size(filecontent)
103  line = filecontent(j)
104  if (io_isblank(line)) cycle ! skip empty lines
105  chunkpos = io_stringpos(line)
106  tag = io_lc(io_stringvalue(line,chunkpos,1)) ! extract key
107  select case(tag)
108  case ('element','e','el')
109  debug_e = io_intvalue(line,chunkpos,2)
110  case ('integrationpoint','i','ip')
111  debug_i = io_intvalue(line,chunkpos,2)
112  case ('grain','g','gr')
113  debug_g = io_intvalue(line,chunkpos,2)
114  end select
115 
116  what = 0
117  select case(tag)
118  case ('debug')
119  what = debug_debug
120  case ('math')
121  what = debug_math
122  case ('fesolving', 'fe')
123  what = debug_fesolving
124  case ('mesh')
125  what = debug_mesh
126  case ('material')
127  what = debug_material
128  case ('lattice')
129  what = debug_lattice
130  case ('constitutive')
131  what = debug_constitutive
132  case ('crystallite')
133  what = debug_crystallite
134  case ('homogenization')
135  what = debug_homogenization
136  case ('cpfem')
137  what = debug_cpfem
138  case ('spectral')
139  what = debug_spectral
140  case ('marc')
141  what = debug_marc
142  case ('all')
143  what = debug_maxntype + 1
144  case ('other')
145  what = debug_maxntype + 2
146  end select
147  if (what /= 0) then
148  do i = 2, chunkpos(1)
149  select case(io_lc(io_stringvalue(line,chunkpos,i)))
150  case('basic')
151  debug_level(what) = ior(debug_level(what), debug_levelbasic)
152  case('extensive')
153  debug_level(what) = ior(debug_level(what), debug_levelextensive)
154  case('selective')
155  debug_level(what) = ior(debug_level(what), debug_levelselective)
156  case('restart')
157  debug_level(what) = ior(debug_level(what), debug_spectralrestart)
158  case('fft','fftw')
159  debug_level(what) = ior(debug_level(what), debug_spectralfftw)
160  case('divergence')
162  case('rotation')
164  case('petsc')
165  debug_level(what) = ior(debug_level(what), debug_spectralpetsc)
166  end select
167  enddo
168  endif
169  enddo
170 
171  do i = 1, debug_maxntype
172  if (debug_level(i) == 0) &
173  debug_level(i) = ior(debug_level(i), debug_level(debug_maxntype + 2)) ! fill undefined debug types with levels specified by "other"
174 
175  debug_level(i) = ior(debug_level(i), debug_level(debug_maxntype + 1)) ! fill all debug types with levels specified by "all"
176  enddo
177 
178  if (iand(debug_level(debug_debug),debug_levelbasic) /= 0) &
179  write(6,'(a,/)') ' using values from config file'
180  else fileexists
181  if (iand(debug_level(debug_debug),debug_levelbasic) /= 0) &
182  write(6,'(a,/)') ' using standard values'
183  endif fileexists
184 
185 !--------------------------------------------------------------------------------------------------
186 ! output switched on (debug level for debug must be extensive)
187  if (iand(debug_level(debug_debug),debug_levelextensive) /= 0) then
188  do i = 1, debug_maxntype
189  select case(i)
190  case (debug_debug)
191  tag = ' Debug'
192  case (debug_math)
193  tag = ' Math'
194  case (debug_fesolving)
195  tag = ' FEsolving'
196  case (debug_mesh)
197  tag = ' Mesh'
198  case (debug_material)
199  tag = ' Material'
200  case (debug_lattice)
201  tag = ' Lattice'
202  case (debug_constitutive)
203  tag = ' Constitutive'
204  case (debug_crystallite)
205  tag = ' Crystallite'
206  case (debug_homogenization)
207  tag = ' Homogenizaiton'
208  case (debug_cpfem)
209  tag = ' CPFEM'
210  case (debug_spectral)
211  tag = ' Spectral solver'
212  case (debug_marc)
213  tag = ' MSC.MARC FEM solver'
214  end select
215 
216  if(debug_level(i) /= 0) then
217  write(6,'(3a)') ' debug level for ', trim(tag), ':'
218  if(iand(debug_level(i),debug_levelbasic) /= 0) write(6,'(a)') ' basic'
219  if(iand(debug_level(i),debug_levelextensive) /= 0) write(6,'(a)') ' extensive'
220  if(iand(debug_level(i),debug_levelselective) /= 0) then
221  write(6,'(a)') ' selective on:'
222  write(6,'(a24,1x,i8)') ' element: ',debug_e
223  write(6,'(a24,1x,i8)') ' ip: ',debug_i
224  write(6,'(a24,1x,i8)') ' grain: ',debug_g
225  endif
226  if(iand(debug_level(i),debug_spectralrestart) /= 0) write(6,'(a)') ' restart'
227  if(iand(debug_level(i),debug_spectralfftw) /= 0) write(6,'(a)') ' FFTW'
228  if(iand(debug_level(i),debug_spectraldivergence)/= 0) write(6,'(a)') ' divergence'
229  if(iand(debug_level(i),debug_spectralrotation) /= 0) write(6,'(a)') ' rotation'
230  if(iand(debug_level(i),debug_spectralpetsc) /= 0) write(6,'(a)') ' PETSc'
231  endif
232  enddo
233  endif
234 
235 end subroutine debug_init
236 
237 
238 !--------------------------------------------------------------------------------------------------
240 !--------------------------------------------------------------------------------------------------
241 subroutine debug_reset
242 
247  debug_stressmax = -huge(1.0_preal)
248  debug_stressmin = huge(1.0_preal)
249  debug_jacobianmax = -huge(1.0_preal)
250  debug_jacobianmin = huge(1.0_preal)
251 
252 end subroutine debug_reset
253 
254 
255 !--------------------------------------------------------------------------------------------------
257 !--------------------------------------------------------------------------------------------------
258 subroutine debug_info
259 
260  !$OMP CRITICAL (write2out)
261  debugoutputcpfem: if (iand(debug_level(debug_cpfem),debug_levelbasic) /= 0 &
262  .and. any(debug_stressminlocation /= 0) &
263  .and. any(debug_stressmaxlocation /= 0) ) then
264  write(6,'(2/,a,/)') ' Extreme values of returned stress and Jacobian'
265  write(6,'(a39)') ' value el ip'
266  write(6,'(a14,1x,e12.3,1x,i8,1x,i4)') ' stress min :', debug_stressmin, debug_stressminlocation
267  write(6,'(a14,1x,e12.3,1x,i8,1x,i4)') ' max :', debug_stressmax, debug_stressmaxlocation
268  write(6,'(a14,1x,e12.3,1x,i8,1x,i4)') ' Jacobian min :', debug_jacobianmin, debug_jacobianminlocation
269  write(6,'(a14,1x,e12.3,1x,i8,1x,i4,/)') ' max :', debug_jacobianmax, debug_jacobianmaxlocation
270  endif debugoutputcpfem
271  !$OMP END CRITICAL (write2out)
272 
273 end subroutine debug_info
274 
275 end module debug
debug::debug_init
subroutine, public debug_init
reads in parameters from debug.config and allocates arrays
Definition: debug.f90:84
io::io_stringpos
pure integer function, dimension(:), allocatable, public io_stringpos(string)
locates all whitespace-separated chunks in given string and returns array containing number them and ...
Definition: IO.f90:204
debug::debug_spectraldivergence
integer, parameter, public debug_spectraldivergence
Definition: debug.f90:25
io::io_read_ascii
character(len=pstringlen) function, dimension(:), allocatable, public io_read_ascii(fileName)
reads an entire ASCII file into an array
Definition: IO.f90:61
debug::debug_info
subroutine, public debug_info
writes debug statements to standard out
Definition: debug.f90:259
debug::debug_i
integer, public, protected debug_i
Definition: debug.f90:51
debug::debug_mesh
integer, parameter, public debug_mesh
stores debug level for mesh part of DAMASK bitwise coded
Definition: debug.f90:32
debug::debug_level
integer, dimension(debug_maxntype+2), public, protected debug_level
Definition: debug.f90:48
debug::debug_stressminlocation
integer, dimension(2), public debug_stressminlocation
Definition: debug.f90:56
debug::debug_reset
subroutine, public debug_reset
resets all debug values
Definition: debug.f90:242
debug::debug_spectralrestart
integer, parameter, public debug_spectralrestart
Definition: debug.f90:25
debug::debug_fesolving
integer, parameter, public debug_fesolving
Definition: debug.f90:32
debug::debug_crystallite
integer, parameter, public debug_crystallite
Definition: debug.f90:32
debug::debug_lattice
integer, parameter, public debug_lattice
stores debug level for lattice part of DAMASK bitwise coded
Definition: debug.f90:32
debug::debug_stressmax
real(preal), public debug_stressmax
Definition: debug.f90:63
prec
setting precision for real and int type
Definition: prec.f90:13
debug::debug_jacobianminlocation
integer, dimension(2), public debug_jacobianminlocation
Definition: debug.f90:56
debug::debug_material
integer, parameter, public debug_material
stores debug level for material part of DAMASK bitwise coded
Definition: debug.f90:32
debug::debug_levelselective
integer, parameter, public debug_levelselective
Definition: debug.f90:19
debug::petscdebug
character(len=1024), parameter, public petscdebug
Definition: debug.f90:70
debug::debug_jacobianmax
real(preal), public debug_jacobianmax
Definition: debug.f90:63
io
input/output functions, partly depending on chosen solver
Definition: IO.f90:12
debug::debug_homogenization
integer, parameter, public debug_homogenization
Definition: debug.f90:32
debug::debug_levelbasic
integer, parameter, public debug_levelbasic
Definition: debug.f90:19
prec::preal
integer, parameter preal
number with 15 significant digits, up to 1e+-307 (typically 64 bit)
Definition: prec.f90:20
debug
Reading in and interpretating the debugging settings for the various modules.
Definition: debug.f90:12
debug::debug_spectralfftw
integer, parameter, public debug_spectralfftw
Definition: debug.f90:25
debug::debug_stressmin
real(preal), public debug_stressmin
Definition: debug.f90:63
io::io_isblank
logical pure function, public io_isblank(string)
identifies strings without content
Definition: IO.f90:160
debug::debug_math
integer, parameter, public debug_math
Definition: debug.f90:32
debug::debug_maxgeneral
integer, parameter, private debug_maxgeneral
Definition: debug.f90:23
debug::debug_levelextensive
integer, parameter, public debug_levelextensive
Definition: debug.f90:19
debug::debug_jacobianmin
real(preal), public debug_jacobianmin
Definition: debug.f90:63
io::io_intvalue
integer function, public io_intvalue(string, chunkPos, myChunk)
reads integer value at myChunk from string
Definition: IO.f90:252
debug::debug_spectral
integer, parameter, public debug_spectral
Definition: debug.f90:32
debug::debug_marc
integer, parameter, public debug_marc
Definition: debug.f90:32
debug::debug_stressmaxlocation
integer, dimension(2), public debug_stressmaxlocation
Definition: debug.f90:56
debug::debug_constitutive
integer, parameter, public debug_constitutive
stores debug level for constitutive part of DAMASK bitwise coded
Definition: debug.f90:32
debug::debug_e
integer, public, protected debug_e
Definition: debug.f90:51
debug::debug_maxntype
integer, parameter, private debug_maxntype
must be set to the maximum defined debug type
Definition: debug.f90:45
debug::debug_spectralpetsc
integer, parameter, public debug_spectralpetsc
Definition: debug.f90:25
debug::debug_spectralrotation
integer, parameter, public debug_spectralrotation
Definition: debug.f90:25
io::io_lc
pure character(len=len(string)) function, public io_lc(string)
changes characters in string to lower case
Definition: IO.f90:280
io::io_stringvalue
character(len=:) function, allocatable, public io_stringvalue(string, chunkPos, myChunk)
reads string value at myChunk from string
Definition: IO.f90:232
debug::debug_g
integer, public, protected debug_g
Definition: debug.f90:51
debug::debug_jacobianmaxlocation
integer, dimension(2), public debug_jacobianmaxlocation
Definition: debug.f90:56
debug::debug_debug
integer, parameter, public debug_debug
Definition: debug.f90:32
debug::debug_cpfem
integer, parameter, public debug_cpfem
Definition: debug.f90:32