diff --git a/LICENSE b/LICENSE
index feb750016..2b8bdcc46 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,14 +1,14 @@
-Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
+Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
diff --git a/README b/README
index 698bdc83d..a9cd73ac1 100644
--- a/README
+++ b/README
@@ -1,8 +1,8 @@
-CONTACT INFORMATION
-
-Max-Planck-Institut für Eisenforschung GmbH
-Max-Planck-Str. 1
-40237 Düsseldorf
-Germany
-
+CONTACT INFORMATION
+
+Max-Planck-Institut für Eisenforschung GmbH
+Max-Planck-Str. 1
+40237 Düsseldorf
+Germany
+
DAMASK@mpie.de
\ No newline at end of file
diff --git a/code/DAMASK_spectral_interface.f90 b/code/DAMASK_spectral_interface.f90
index d8f8b814c..714ff98c1 100644
--- a/code/DAMASK_spectral_interface.f90
+++ b/code/DAMASK_spectral_interface.f90
@@ -127,7 +127,6 @@ subroutine DAMASK_interface_init()
loadcaseParameter = '' ! should be empty
loadcaseParameter(1:length)=commandLine(start:start+length)
- print*, loadcaseParameter
do i=1,len(commandLine) ! remove capitals
if(64 4 &
.and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then
- write(6,'(a,f10.8,a,f10.8,a)') '<< CRYST >> winding forward from ', &
+ write(6,'(a,f12.8,a,f12.8,a)') '<< CRYST >> winding forward from ', &
crystallite_subFrac(g,i,e),' to current crystallite_subfrac ', &
crystallite_subFrac(g,i,e)+crystallite_subStep(g,i,e),' in crystallite_stressAndItsTangent'
write(6,*)
@@ -637,7 +637,7 @@ do while (any(crystallite_subStep(:,:,FEsolving_execELem(1):FEsolving_execElem(2
#ifndef _OPENMP
if (debug_verbosity > 4_pInt &
.and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then
- write(6,'(a,f10.8)') '<< CRYST >> cutback step in crystallite_stressAndItsTangent with new crystallite_subStep: ',&
+ write(6,'(a,f12.8)') '<< CRYST >> cutback step in crystallite_stressAndItsTangent with new crystallite_subStep: ',&
crystallite_subStep(g,i,e)
write(6,*)
endif
diff --git a/code/makefile b/code/makefile
index 1e848fd46..fbb6b8aa0 100644
--- a/code/makefile
+++ b/code/makefile
@@ -182,7 +182,6 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
-fall-intrinsics\
-pedantic\
-Warray-bounds\
- -Wunused-parameter\
-Wampersand\
-Wno-tabs\
-Wcharacter-truncation\
@@ -190,9 +189,14 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
-Waliasing\
-Wconversion\
-Wsurprising\
- -Wunused-value\
- -Wunderflow
-
+ -Wunderflow\
+ -Wswitch\
+ -Wstrict-overflow\
+ -Wextra\
+ -Wattributes\
+ -Wunsafe-loop-optimizations\
+ -Wunused
+
#-xf95-cpp-input: preprocessor
#-ffree-line-length-132: restrict line length to the standard 132 characters
#-fno-range-check: disables checking if result can be represented by variable. Needs to be set to enable DAMASK_NaN
@@ -200,7 +204,6 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
#-fall-intrinsics:
#-pedantic: more strict on standard, enables some of the warnings below
#-Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime
-#-Wunused-parameter: find usused variables with "parameter" attribute
#-Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line
#-Wno-tabs: do not allow tabs in source
#-Wcharacter-truncation: warn if character expressions (strings) are truncated
@@ -209,14 +212,20 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
#-Wconversion: warn about implicit conversions between different type
#-Wsurprising: warn when "suspicious" code constructs are encountered. While technically legal these usually indicate that an error has been made.
#-Wunused-value:
+#-Wunused-parameter: find usused variables with "parameter" attribute
#-Wunderflow: produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation
-#
+#-Wswitch: warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that
+# enumeration. (The presence of a "default" label prevents this warning.) "case" labels outside the enumeration range also provoke
+# warnings when this option is used (even if there is a "default" label)
+#-Wstrict-overflow
+#-Wattributes Warn about inappropriate attribute usage
+# -Wunsafe-loop-optimizations Warn if the loop cannot be optimized due to nontrivial assumptions.
###################################################################################################
#OPTIONS FOR GFORTRAN 4.6
#-Wsuggest-attribute=const:
#-Wsuggest-attribute=noreturn:
#-Wsuggest-attribute=pure:
-#
+#-Wreal-q-constant: Warn about real-literal-constants with 'q' exponent-letter
#MORE OPTIONS FOR DEBUGGING DURING COMPILING
#-Wline-truncation: too many warnings because we have comments beyond character 132
#-Wintrinsic-std: warnings because of "flush" is not longer in the standard, but still an intrinsic fuction of the compilers:
diff --git a/copyright header.txt b/copyright header.txt
index 567973306..9ffb4ec34 100644
--- a/copyright header.txt
+++ b/copyright header.txt
@@ -1,19 +1,19 @@
-! Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH
-!
-! This file is part of DAMASK,
-! the Düsseldorf Advanced MAterial Simulation Kit.
-!
-! DAMASK is free software: you can redistribute it and/or modify
-! it under the terms of the GNU General Public License as published by
-! the Free Software Foundation, either version 3 of the License, or
-! (at your option) any later version.
-!
-! DAMASK is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-! GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License
-! along with DAMASK. If not, see .
-!
-!##############################################################
+! Copyright 2011,2012 Max-Planck-Institut für Eisenforschung GmbH
+!
+! This file is part of DAMASK,
+! the Düsseldorf Advanced MAterial Simulation Kit.
+!
+! DAMASK is free software: you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation, either version 3 of the License, or
+! (at your option) any later version.
+!
+! DAMASK is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with DAMASK. If not, see .
+!
+!##############################################################
diff --git a/processing/post/addCalculation.py b/processing/post/addCalculation.py
index b0809e7d7..b28e3ee5b 100755
--- a/processing/post/addCalculation.py
+++ b/processing/post/addCalculation.py
@@ -42,7 +42,6 @@ parser.add_option('-f','--formula', dest='formulas', action='extend', type='stri
parser.set_defaults(labels= [])
parser.set_defaults(formulas= [])
-parser.set_defaults(counter= False)
(options,filenames) = parser.parse_args()
diff --git a/processing/post/spectral_parseLog.py b/processing/post/spectral_parseLog.py
index 871b20058..5e7ad970b 100755
--- a/processing/post/spectral_parseLog.py
+++ b/processing/post/spectral_parseLog.py
@@ -35,18 +35,18 @@ parsing = [ \
['error_stress', r'^error stress = [ +-eE0123456789.]+ \( ([+-eE0123456789.]+)'],
['crit_divergence', r'^error divergence = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'],
['crit_stress', r'^error stress = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'],
- ['max(sym(deltaF))', r'^max symmetrix correction of deformation: ([ +-eE0123456789.]+)'],
- ['max(skew(deltaF))', r'^max skew correction of deformation: ([ +-eE0123456789.]+)'],
- ['max(sym/skew(avg(deltaF)))', r'^max sym/skew of avg correction: ([ +-eE0123456789.]+)'],
- ['det(Fbar)', r'^determinant of new deformation: ([ +-eE0123456789.]+)'],
- ['max(det(F))', r'^max determinant of deformation:([ +-eE0123456789.]+)'],
- ['min(det(F))', r'^min determinant of deformation:([ +-eE0123456789.]+)'],
+ ['max(sym(deltaF))', r'^max symmetrix correction of deformation = ([ +-eE0123456789.]+)'],
+ ['max(skew(deltaF))', r'^max skew correction of deformation = ([ +-eE0123456789.]+)'],
+ ['max(sym/skew(avg(deltaF)))', r'^max sym/skew of avg correction = ([ +-eE0123456789.]+)'],
+ ['det(Fbar)', r'^determinant of new deformation = ([ +-eE0123456789.]+)'],
+ ['max(det(F))', r'^max determinant of deformation = ([ +-eE0123456789.]+)'],
+ ['min(det(F))', r'^min determinant of deformation = ([ +-eE0123456789.]+)'],
['div_FT_max', r'^error divergence FT max = ([ +-eE0123456789.]+)'],
['div_Real_RMS', r'^error divergence Real RMS = ([ +-eE0123456789.]+)'],
['div_Real_max', r'^error divergence Real max = ([ +-eE0123456789.]+)'],
- ['real(error_FT)', r'^max FT relative error ([ +-eE0123456789.]+) [ +-eE0123456789.]+'],
- ['img(error_FT)', r'^max FT relative error [ +-eE0123456789.]+ ([ +-eE0123456789.]+)'],
- ['real(error_iFT)', r'^max iFT relative error ([ +-eE0123456789.]+)'],
+ ['real(error_FT)', r'^max FT relative error = ([ +-eE0123456789.]+) [ +-eE0123456789.]+'],
+ ['img(error_FT)', r'^max FT relative error = [ +-eE0123456789.]+ ([ +-eE0123456789.]+)'],
+ ['real(error_iFT)', r'^max iFT relative error = ([ +-eE0123456789.]+)'],
['error_postProc', r'^max deviat. from postProc =([ +-eE0123456789.]+)'],
['loadcase', r'^Loadcase (\d+) Increment \d+/\d+ @ Iteration \d+/\d+']
]
diff --git a/processing/pre/FromEBSD/Hex2Cub.cpp b/processing/pre/FromEBSD/Hex2Cub.cpp
index e0ec3f581..0458e68a3 100644
--- a/processing/pre/FromEBSD/Hex2Cub.cpp
+++ b/processing/pre/FromEBSD/Hex2Cub.cpp
@@ -1,205 +1,205 @@
-#include
-#include
-#include
-#include
-#include
-
-struct
-{
- float phi1, Phi, phi2;
- float ci, iq, fit, avgIQ;
- int phase, ds;
-} data[3000][3000];
-
-int round2( double x )
-{
- double fl, ce;
-
- fl = floor( x );
- ce = ceil( x );
- if( fabs( fl-x ) < fabs( ce-x ) )
- return fl;
- else
- return ce;
-}
-
-char lineBuffer[200];
-
-int ReadFileInfo(FILE *oimStream, int *xmax, int *ymax, double *stepSize )
-{
- double x, y, dxmax;
- long count;
-
- *stepSize = 0;
- dxmax = 0;
- *xmax = 0;
-
- while( fgets( lineBuffer, 200, oimStream ) != NULL )
- {
- if( lineBuffer[0] == '#' )
- {
- if( strcmp( lineBuffer, "# GRID: SqrGrid" ) == 0 )
- {
- printf("\nThe file is already a square grid file.\nProgram terminated.");
- return 0;
- }
- count = 0;
- continue;
- }
- if( sscanf( lineBuffer, "%*lf %*lf %*lf %lf %lf %*lf %*lf %*i %*i %*lf %*lf", &x, &y ) != 2 )
- return 0;
- if( *stepSize == 0 && x != 0 )
- *stepSize = x;
- if( x > dxmax )
- {
- dxmax = x;
- (*xmax)++;
- }
- count++;
- }
- (*xmax)++;
- *ymax = (int)(count / *xmax );
-
- return 1;
-}
-
-
-int main(int argc, char* argv[])
-{
- int xx, yy, zz, xlimit, ylimit, zlimit, xlimitOut, xOut;
- double stepSize;
- char zFilename[50], zOutFilename[50], filename[50];
- FILE *inStream, *outStream;
- int zStartNumber, zEndNumber;
-
- printf( "\nFilenames must have the format ""root_xxx.ang"""
- "\nwith xxx indicating a 3-digit integer"
- "\nEnter oim map filename-root, the start integer and the end integer number of the files: " );
-
- scanf( "%s %i %i", filename, &zStartNumber, &zEndNumber );
- zlimit = zEndNumber-zStartNumber+1;
-
- //read the first data file and get all necessary start data
- sprintf( zFilename, "%s_%03i.ang", filename, zStartNumber );
- if( (inStream = fopen( zFilename, "r" )) == NULL )
- {
- printf( "\nCan't open %s", zFilename );
- exit( 1 );
- }
- if( ReadFileInfo( inStream, &xlimit, &ylimit, &stepSize ) == 0 )
- {
- printf( "\nWrong file format in %s", filename );
- exit( 1 );
- }
- fclose( inStream );
-
- for( zz=0; zz
+#include
+#include
+#include
+#include
+
+struct
+{
+ float phi1, Phi, phi2;
+ float ci, iq, fit, avgIQ;
+ int phase, ds;
+} data[3000][3000];
+
+int round2( double x )
+{
+ double fl, ce;
+
+ fl = floor( x );
+ ce = ceil( x );
+ if( fabs( fl-x ) < fabs( ce-x ) )
+ return fl;
+ else
+ return ce;
+}
+
+char lineBuffer[200];
+
+int ReadFileInfo(FILE *oimStream, int *xmax, int *ymax, double *stepSize )
+{
+ double x, y, dxmax;
+ long count;
+
+ *stepSize = 0;
+ dxmax = 0;
+ *xmax = 0;
+
+ while( fgets( lineBuffer, 200, oimStream ) != NULL )
+ {
+ if( lineBuffer[0] == '#' )
+ {
+ if( strcmp( lineBuffer, "# GRID: SqrGrid" ) == 0 )
+ {
+ printf("\nThe file is already a square grid file.\nProgram terminated.");
+ return 0;
+ }
+ count = 0;
+ continue;
+ }
+ if( sscanf( lineBuffer, "%*lf %*lf %*lf %lf %lf %*lf %*lf %*i %*i %*lf %*lf", &x, &y ) != 2 )
+ return 0;
+ if( *stepSize == 0 && x != 0 )
+ *stepSize = x;
+ if( x > dxmax )
+ {
+ dxmax = x;
+ (*xmax)++;
+ }
+ count++;
+ }
+ (*xmax)++;
+ *ymax = (int)(count / *xmax );
+
+ return 1;
+}
+
+
+int main(int argc, char* argv[])
+{
+ int xx, yy, zz, xlimit, ylimit, zlimit, xlimitOut, xOut;
+ double stepSize;
+ char zFilename[50], zOutFilename[50], filename[50];
+ FILE *inStream, *outStream;
+ int zStartNumber, zEndNumber;
+
+ printf( "\nFilenames must have the format ""root_xxx.ang"""
+ "\nwith xxx indicating a 3-digit integer"
+ "\nEnter oim map filename-root, the start integer and the end integer number of the files: " );
+
+ scanf( "%s %i %i", filename, &zStartNumber, &zEndNumber );
+ zlimit = zEndNumber-zStartNumber+1;
+
+ //read the first data file and get all necessary start data
+ sprintf( zFilename, "%s_%03i.ang", filename, zStartNumber );
+ if( (inStream = fopen( zFilename, "r" )) == NULL )
+ {
+ printf( "\nCan't open %s", zFilename );
+ exit( 1 );
+ }
+ if( ReadFileInfo( inStream, &xlimit, &ylimit, &stepSize ) == 0 )
+ {
+ printf( "\nWrong file format in %s", filename );
+ exit( 1 );
+ }
+ fclose( inStream );
+
+ for( zz=0; zz0)
- left = right + verify(line(right+1:),sep)
- right = left + scan(line(left:),sep) - 2
- if ( IO_stringPos(1)'
- format1 = '(A, I'//trim(N_Digits)//'.'//trim(N_Digits)//', A)'
- format2 = '(A, I'//trim(N_Digits)//', A)'
- do i = 1, N_Seeds
- write(20, trim(format1)), '[Grain', i, ']'
- write(20, '(A)'), 'crystallite 1'
- write(20, trim(format2)), '(constituent) phase 1 texture ', i, ' fraction 1.0'
- end do
-
-! get random euler angles for every grain, store them in grainEuler and write them to the material.config file
- format2 = '(6(A, F10.6))'
- write(20, '(/, A)'), ''
- do i = 1, N_Seeds
- write(20, trim(format1)), '[Grain', i, ']'
- write(20, trim(format2)), '(gauss) phi1 ', grainEuler(i,1), ' Phi ', grainEuler(i,2), &
- &' Phi2 ', grainEuler(i,3), ' scatter 0.0 fraction 1.0'
- end do
- close(20)
- print*, 'material.config done.'
-
-!write header of geom file
- open(20, file = ((trim(output_name))//'.geom'))
- open(21, file = ((trim(output_name))//'.spectral'))
- write(20, '(A)'), '3 header'
- write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', resolution(1), ' b ', resolution(2), ' c ', resolution(3)
- write(20, '(A, g17.10, A, g17.10, A, g17.10)'), 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3)
- write(20, '(A)'), 'homogenization 1'
-
- format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format
- format2 = '(3(tr2, f6.2), 3(tr2,g10.5), I10, a)' ! spectral (Lebensohn) format
-
-
-! perform voronoi tessellation and write result to files
- do i = 0, resolution(1)*resolution(2)*resolution(3)-1
- minDist = geomdim(1)*geomdim(1)+geomdim(2)*geomdim(2)+geomdim(3)*geomdim(3) ! diagonal of rve
- do j = 1, N_Seeds
- delta(1) = step(1)*(mod(i , resolution(1))+0.5_pReal) - seeds(j,1)
- delta(2) = step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal) - seeds(j,2)
- delta(3) = step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal) - seeds(j,3)
- do k = -1, 1 ! left, me, right image
- do l = -1, 1 ! front, me, back image
- do m = -1, 1 ! lower, me, upper image
- theDist = ( geomdim(1) * ( delta(1)-real(k,pReal) ) )**2 + &
- ( geomdim(2) * ( delta(2)-real(l,pReal) ) )**2 + &
- ( geomdim(3) * ( delta(3)-real(m,pReal) ) )**2
- if (theDist < minDist) then
- minDist = theDist
- theGrain = j
- endif
- enddo
- enddo
- enddo
- enddo
- grainCheck(theGrain) = .true.
- write(20, trim(format1)), theGrain
- write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), &
- geomdim(1)*step(1)*(mod(i , resolution(1))+0.5_pReal), &
- geomdim(2)*step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal), &
- geomdim(3)*step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal), &
- theGrain, ' 1'
- enddo
- close(20)
- close(21)
- print*, 'voronoi tesselation done.'
- if (all(grainCheck)) then
- print*, 'all grains mapped!'
- else
- print*, 'only',count(grainCheck),'grains mapped!'
- endif
-
-end program voronoi
+!prec.f90 407 2009-08-31 15:09:15Z MPIE\f.roters
+!##############################################################
+ MODULE prec
+!##############################################################
+
+ implicit none
+
+! *** Precision of real and integer variables ***
+ integer, parameter :: pReal = selected_real_kind(15,300) ! 15 significant digits, up to 1e+-300
+ integer, parameter :: pInt = selected_int_kind(9) ! up to +- 1e9
+ integer, parameter :: pLongInt = 8 ! should be 64bit
+
+ END MODULE prec
+
+!IO.f90 693 2010-11-04 18:18:01Z MPIE\c.kords
+!##############################################################
+ MODULE IO
+!##############################################################
+
+ CONTAINS
+!********************************************************************
+! identifies lines without content
+!********************************************************************
+ pure function IO_isBlank (line)
+
+ use prec, only: pInt
+ implicit none
+
+ character(len=*), intent(in) :: line
+ character(len=*), parameter :: blank = achar(32)//achar(9)//achar(10)//achar(13) ! whitespaces
+ character(len=*), parameter :: comment = achar(35) ! comment id '#'
+ integer(pInt) posNonBlank, posComment
+ logical IO_isBlank
+
+ posNonBlank = verify(line,blank)
+ posComment = scan(line,comment)
+ IO_isBlank = posNonBlank == 0 .or. posNonBlank == posComment
+
+ return
+
+ endfunction
+
+!********************************************************************
+! read string value at pos from line
+!********************************************************************
+ pure function IO_stringValue (line,positions,pos)
+
+ use prec, only: pReal,pInt
+ implicit none
+
+ character(len=*), intent(in) :: line
+ integer(pInt), intent(in) :: positions(*),pos
+ character(len=1+positions(pos*2+1)-positions(pos*2)) IO_stringValue
+
+ if (positions(1) < pos) then
+ IO_stringValue = ''
+ else
+ IO_stringValue = line(positions(pos*2):positions(pos*2+1))
+ endif
+ return
+
+ endfunction
+
+!********************************************************************
+! read float value at pos from line
+!********************************************************************
+ pure function IO_floatValue (line,positions,pos)
+
+ use prec, only: pReal,pInt
+ implicit none
+
+ character(len=*), intent(in) :: line
+ integer(pInt), intent(in) :: positions(*),pos
+ real(pReal) IO_floatValue
+
+ if (positions(1) < pos) then
+ IO_floatValue = 0.0_pReal
+ else
+ read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_floatValue
+ endif
+ return
+100 IO_floatValue = huge(1.0_pReal)
+ return
+
+ endfunction
+
+!********************************************************************
+! read int value at pos from line
+!********************************************************************
+ pure function IO_intValue (line,positions,pos)
+
+ use prec, only: pReal,pInt
+ implicit none
+
+ character(len=*), intent(in) :: line
+ integer(pInt), intent(in) :: positions(*),pos
+ integer(pInt) IO_intValue
+
+ if (positions(1) < pos) then
+ IO_intValue = 0_pInt
+ else
+ read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_intValue
+ endif
+ return
+100 IO_intValue = huge(1_pInt)
+ return
+
+ endfunction
+
+!********************************************************************
+! change character in line to lower case
+!********************************************************************
+ pure function IO_lc (line)
+
+ use prec, only: pInt
+ implicit none
+
+ character (len=*), intent(in) :: line
+ character (len=len(line)) IO_lc
+ integer(pInt) i
+
+ IO_lc = line
+ do i=1,len(line)
+ if(640)
+ left = right + verify(line(right+1:),sep)
+ right = left + scan(line(left:),sep) - 2
+ if ( IO_stringPos(1)'
+ format1 = '(A, I'//trim(N_Digits)//'.'//trim(N_Digits)//', A)'
+ format2 = '(A, I'//trim(N_Digits)//', A)'
+ do i = 1, N_Seeds
+ write(20, trim(format1)), '[Grain', i, ']'
+ write(20, '(A)'), 'crystallite 1'
+ write(20, trim(format2)), '(constituent) phase 1 texture ', i, ' fraction 1.0'
+ end do
+
+! get random euler angles for every grain, store them in grainEuler and write them to the material.config file
+ format2 = '(6(A, F10.6))'
+ write(20, '(/, A)'), ''
+ do i = 1, N_Seeds
+ write(20, trim(format1)), '[Grain', i, ']'
+ write(20, trim(format2)), '(gauss) phi1 ', grainEuler(i,1), ' Phi ', grainEuler(i,2), &
+ &' Phi2 ', grainEuler(i,3), ' scatter 0.0 fraction 1.0'
+ end do
+ close(20)
+ print*, 'material.config done.'
+
+!write header of geom file
+ open(20, file = ((trim(output_name))//'.geom'))
+ open(21, file = ((trim(output_name))//'.spectral'))
+ write(20, '(A)'), '3 header'
+ write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', resolution(1), ' b ', resolution(2), ' c ', resolution(3)
+ write(20, '(A, g17.10, A, g17.10, A, g17.10)'), 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3)
+ write(20, '(A)'), 'homogenization 1'
+
+ format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format
+ format2 = '(3(tr2, f6.2), 3(tr2,g10.5), I10, a)' ! spectral (Lebensohn) format
+
+
+! perform voronoi tessellation and write result to files
+ do i = 0, resolution(1)*resolution(2)*resolution(3)-1
+ minDist = geomdim(1)*geomdim(1)+geomdim(2)*geomdim(2)+geomdim(3)*geomdim(3) ! diagonal of rve
+ do j = 1, N_Seeds
+ delta(1) = step(1)*(mod(i , resolution(1))+0.5_pReal) - seeds(j,1)
+ delta(2) = step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal) - seeds(j,2)
+ delta(3) = step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal) - seeds(j,3)
+ do k = -1, 1 ! left, me, right image
+ do l = -1, 1 ! front, me, back image
+ do m = -1, 1 ! lower, me, upper image
+ theDist = ( geomdim(1) * ( delta(1)-real(k,pReal) ) )**2 + &
+ ( geomdim(2) * ( delta(2)-real(l,pReal) ) )**2 + &
+ ( geomdim(3) * ( delta(3)-real(m,pReal) ) )**2
+ if (theDist < minDist) then
+ minDist = theDist
+ theGrain = j
+ endif
+ enddo
+ enddo
+ enddo
+ enddo
+ grainCheck(theGrain) = .true.
+ write(20, trim(format1)), theGrain
+ write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), &
+ geomdim(1)*step(1)*(mod(i , resolution(1))+0.5_pReal), &
+ geomdim(2)*step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal), &
+ geomdim(3)*step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal), &
+ theGrain, ' 1'
+ enddo
+ close(20)
+ close(21)
+ print*, 'voronoi tesselation done.'
+ if (all(grainCheck)) then
+ print*, 'all grains mapped!'
+ else
+ print*, 'only',count(grainCheck),'grains mapped!'
+ endif
+
+end program voronoi