2009-08-31 20:39:15 +05:30
|
|
|
!* $Id$
|
2007-03-20 19:25:22 +05:30
|
|
|
!##############################################################
|
|
|
|
MODULE IO
|
|
|
|
!##############################################################
|
|
|
|
|
|
|
|
CONTAINS
|
|
|
|
!---------------------------
|
|
|
|
! function IO_open_file(unit,relPath)
|
|
|
|
! function IO_open_inputFile(unit)
|
2007-03-21 22:34:10 +05:30
|
|
|
! function IO_hybridIA(Nast,ODFfileName)
|
|
|
|
! private function hybridIA_reps(dV_V,steps,C)
|
2007-04-10 16:51:34 +05:30
|
|
|
! function IO_stringPos(line,maxN)
|
2007-03-20 19:25:22 +05:30
|
|
|
! function IO_stringValue(line,positions,pos)
|
|
|
|
! function IO_floatValue(line,positions,pos)
|
|
|
|
! function IO_intValue(line,positions,pos)
|
2007-04-10 16:51:34 +05:30
|
|
|
! function IO_fixedStringValue(line,ends,pos)
|
|
|
|
! function IO_fixedFloatValue(line,ends,pos)
|
|
|
|
! function IO_fixedFloatNoEValue(line,ends,pos)
|
|
|
|
! function IO_fixedIntValue(line,ends,pos)
|
2009-04-02 18:32:25 +05:30
|
|
|
! function IO_continousIntValues(unit,maxN)
|
2007-04-10 16:51:34 +05:30
|
|
|
! function IO_lc(line)
|
|
|
|
! subroutine IO_lcInplace(line)
|
2007-03-20 19:25:22 +05:30
|
|
|
! subroutine IO_error(ID)
|
2009-03-31 14:51:57 +05:30
|
|
|
! subroutine IO_warning(ID)
|
2007-03-20 19:25:22 +05:30
|
|
|
!---------------------------
|
|
|
|
|
2009-08-31 20:39:15 +05:30
|
|
|
!********************************************************************
|
|
|
|
! output version number
|
|
|
|
!********************************************************************
|
2009-10-12 21:31:49 +05:30
|
|
|
subroutine IO_init ()
|
|
|
|
|
|
|
|
!$OMP CRITICAL (write2out)
|
|
|
|
write(6,*)
|
|
|
|
write(6,*) '<<<+- IO init -+>>>'
|
|
|
|
write(6,*) '$Id$'
|
|
|
|
write(6,*)
|
|
|
|
call flush(6)
|
|
|
|
!$OMP END CRITICAL (write2out)
|
|
|
|
|
2009-08-31 20:39:15 +05:30
|
|
|
return
|
2009-09-18 21:07:14 +05:30
|
|
|
endsubroutine
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! open existing file to given unit
|
|
|
|
! path to file is relative to working directory
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
logical function IO_open_file(unit,relPath)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character(len=*), parameter :: pathSep = achar(47)//achar(92) ! /, \
|
|
|
|
character(len=*) relPath
|
|
|
|
integer(pInt) unit
|
|
|
|
character(256) path
|
|
|
|
|
|
|
|
inquire(6, name=path) ! determine outputfile
|
|
|
|
open(unit,status='old',err=100,file=path(1:scan(path,pathSep,back=.true.))//relPath)
|
|
|
|
IO_open_file = .true.
|
|
|
|
return
|
|
|
|
100 IO_open_file = .false.
|
|
|
|
return
|
2007-03-21 22:34:10 +05:30
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! open FEM inputfile to given unit
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
logical function IO_open_inputFile(unit)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
use cpfem_interface
|
2007-03-20 19:25:22 +05:30
|
|
|
use prec, only: pReal, pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-07-22 21:37:19 +05:30
|
|
|
integer(pInt), intent(in) :: unit
|
|
|
|
integer(pInt) extPos
|
2007-03-20 19:25:22 +05:30
|
|
|
character(256) outName
|
|
|
|
character(3) ext
|
|
|
|
|
|
|
|
inquire(6, name=outName) ! determine outputfileName
|
|
|
|
extPos = len_trim(outName)-2
|
2009-10-12 21:31:49 +05:30
|
|
|
! if(outName(extPos:extPos+2)=='out') then
|
|
|
|
! ext='dat' ! MARC
|
|
|
|
! else
|
|
|
|
! ext='inp' ! ABAQUS
|
|
|
|
! endif
|
|
|
|
select case (FEsolver)
|
|
|
|
case ('Marc')
|
|
|
|
ext='dat'
|
|
|
|
case ('Abaqus')
|
|
|
|
ext='inp'
|
|
|
|
end select
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
open(unit,status='old',err=100,file=outName(1:extPos-1)//ext)
|
|
|
|
IO_open_inputFile = .true.
|
|
|
|
return
|
|
|
|
100 IO_open_inputFile = .false.
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2009-07-22 21:37:19 +05:30
|
|
|
!********************************************************************
|
|
|
|
! open (write) file related to current job
|
|
|
|
! but with different extension to given unit
|
|
|
|
!********************************************************************
|
|
|
|
logical function IO_open_jobFile(unit,newExt)
|
|
|
|
|
|
|
|
use prec, only: pReal, pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(pInt), intent(in) :: unit
|
|
|
|
character(*), intent(in) :: newExt
|
|
|
|
character(256) outName
|
|
|
|
|
|
|
|
inquire(6, name=outName) ! determine outputfileName
|
|
|
|
open(unit,status='replace',err=100,file=outName(1:len_trim(outName)-3)//newExt)
|
|
|
|
IO_open_jobFile = .true.
|
|
|
|
return
|
|
|
|
100 IO_open_jobFile = .false.
|
|
|
|
return
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2007-03-21 18:02:15 +05:30
|
|
|
!********************************************************************
|
|
|
|
! hybrid IA repetition counter
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function hybridIA_reps(dV_V,steps,C)
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
use prec, only: pReal, pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(pInt), intent(in), dimension(3) :: steps
|
|
|
|
integer(pInt) hybridIA_reps, phi1,Phi,phi2
|
|
|
|
real(pReal), intent(in), dimension(steps(3),steps(2),steps(1)) :: dV_V
|
|
|
|
real(pReal), intent(in) :: C
|
|
|
|
|
|
|
|
hybridIA_reps = 0_pInt
|
|
|
|
do phi1=1,steps(1)
|
|
|
|
do Phi =1,steps(2)
|
|
|
|
do phi2=1,steps(3)
|
|
|
|
hybridIA_reps = hybridIA_reps+nint(C*dV_V(phi2,Phi,phi1), pInt)
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! hybrid IA sampling of ODFfile
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function IO_hybridIA(Nast,ODFfileName)
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
use prec, only: pReal, pInt
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character(len=*) ODFfileName
|
|
|
|
character(len=80) line
|
|
|
|
character(len=*), parameter :: fileFormat = '(A80)'
|
2007-03-26 20:33:21 +05:30
|
|
|
integer(pInt) i,j,bin,Nast,NnonZero,Nset,Nreps,reps,phi1,Phi,phi2
|
|
|
|
integer(pInt), dimension(7) :: pos
|
2007-03-21 18:02:15 +05:30
|
|
|
integer(pInt), dimension(3) :: steps
|
|
|
|
integer(pInt), dimension(:), allocatable :: binSet
|
|
|
|
real(pReal) center,sum_dV_V,prob,dg_0,C,lowerC,upperC,rnd
|
|
|
|
real(pReal), dimension(3) :: limits,deltas
|
|
|
|
real(pReal), dimension(:,:,:), allocatable :: dV_V
|
2007-03-26 20:33:21 +05:30
|
|
|
real(pReal), dimension(3,Nast) :: IO_hybridIA
|
2007-03-21 18:02:15 +05:30
|
|
|
|
2009-08-27 21:00:40 +05:30
|
|
|
real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal
|
|
|
|
real(pReal), parameter :: inRad = pi/180.0_pReal
|
|
|
|
|
2007-03-21 18:02:15 +05:30
|
|
|
if (.not. IO_open_file(999,ODFfileName)) goto 100
|
|
|
|
|
|
|
|
!--- parse header of ODF file ---
|
|
|
|
!--- limits in phi1, Phi, phi2 ---
|
|
|
|
read(999,fmt=fileFormat,end=100) line
|
|
|
|
pos = IO_stringPos(line,3)
|
|
|
|
if (pos(1).ne.3) goto 100
|
|
|
|
do i=1,3
|
|
|
|
limits(i) = IO_intValue(line,pos,i)*inRad
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
!--- deltas in phi1, Phi, phi2 ---
|
|
|
|
read(999,fmt=fileFormat,end=100) line
|
|
|
|
pos = IO_stringPos(line,3)
|
|
|
|
if (pos(1).ne.3) goto 100
|
|
|
|
do i=1,3
|
|
|
|
deltas(i) = IO_intValue(line,pos,i)*inRad
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
steps = nint(limits/deltas,pInt)
|
|
|
|
allocate(dV_V(steps(3),steps(2),steps(1)))
|
|
|
|
|
|
|
|
!--- box boundary/center at origin? ---
|
|
|
|
read(999,fmt=fileFormat,end=100) line
|
|
|
|
if (index(IO_lc(line),'bound')>0) then
|
|
|
|
center = 0.5_pReal
|
|
|
|
else
|
|
|
|
center = 0.0_pReal
|
2009-06-15 18:41:21 +05:30
|
|
|
endif
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
!--- skip blank line ---
|
|
|
|
read(999,fmt=fileFormat,end=100) line
|
|
|
|
|
|
|
|
sum_dV_V = 0.0_pReal
|
|
|
|
dV_V = 0.0_pReal
|
|
|
|
dg_0 = deltas(1)*deltas(3)*2.0_pReal*sin(deltas(2)/2.0_pReal)
|
|
|
|
NnonZero = 0_pInt
|
|
|
|
|
|
|
|
do phi1=1,steps(1)
|
|
|
|
do Phi=1,steps(2)
|
|
|
|
do phi2=1,steps(3)
|
2008-03-12 19:23:00 +05:30
|
|
|
read(999,fmt=*,end=100) prob
|
2007-03-21 18:02:15 +05:30
|
|
|
if (prob > 0.0_pReal) then
|
|
|
|
NnonZero = NnonZero+1
|
|
|
|
sum_dV_V = sum_dV_V+prob
|
|
|
|
else
|
|
|
|
prob = 0.0_pReal
|
2009-06-15 18:41:21 +05:30
|
|
|
endif
|
2007-03-21 18:02:15 +05:30
|
|
|
dV_V(phi2,Phi,phi1) = prob*dg_0*sin((Phi-1.0_pReal+center)*deltas(2))
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2009-08-13 18:51:22 +05:30
|
|
|
|
2007-03-21 18:02:15 +05:30
|
|
|
dV_V = dV_V/sum_dV_V ! normalize to 1
|
|
|
|
|
|
|
|
!--- now fix bounds ---
|
|
|
|
Nset = max(Nast,NnonZero)
|
|
|
|
lowerC = 0.0_pReal
|
|
|
|
upperC = real(Nset, pReal)
|
|
|
|
|
|
|
|
do while (hybridIA_reps(dV_V,steps,upperC) < Nset)
|
|
|
|
lowerC = upperC
|
|
|
|
upperC = upperC*2.0_pReal
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
!--- binary search for best C ---
|
|
|
|
do
|
|
|
|
C = (upperC+lowerC)/2.0_pReal
|
|
|
|
Nreps = hybridIA_reps(dV_V,steps,C)
|
|
|
|
if (abs(upperC-lowerC) < upperC*1.0e-14_pReal) then
|
|
|
|
C = upperC
|
|
|
|
Nreps = hybridIA_reps(dV_V,steps,C)
|
|
|
|
exit
|
|
|
|
elseif (Nreps < Nset) then
|
|
|
|
lowerC = C
|
|
|
|
elseif (Nreps > Nset) then
|
|
|
|
upperC = C
|
|
|
|
else
|
|
|
|
exit
|
2009-06-15 18:41:21 +05:30
|
|
|
endif
|
|
|
|
enddo
|
2009-08-13 18:51:22 +05:30
|
|
|
|
2007-03-21 18:02:15 +05:30
|
|
|
allocate(binSet(Nreps))
|
|
|
|
bin = 0 ! bin counter
|
|
|
|
i = 1 ! set counter
|
|
|
|
do phi1=1,steps(1)
|
|
|
|
do Phi=1,steps(2)
|
|
|
|
do phi2=1,steps(3)
|
|
|
|
reps = nint(C*dV_V(phi2,Phi,phi1), pInt)
|
|
|
|
binSet(i:i+reps-1) = bin
|
|
|
|
bin = bin+1 ! advance bin
|
|
|
|
i = i+reps ! advance set
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
do i=1,Nast
|
|
|
|
if (i < Nast) then
|
|
|
|
call random_number(rnd)
|
2009-08-13 18:51:22 +05:30
|
|
|
j = nint(rnd*(Nreps-i)+i+0.5_pReal,pInt)
|
2007-03-21 18:02:15 +05:30
|
|
|
else
|
|
|
|
j = i
|
2009-06-15 18:41:21 +05:30
|
|
|
endif
|
2007-03-21 18:02:15 +05:30
|
|
|
bin = binSet(j)
|
|
|
|
IO_hybridIA(1,i) = deltas(1)*(mod(bin/(steps(3)*steps(2)),steps(1))+center) ! phi1
|
|
|
|
IO_hybridIA(2,i) = deltas(2)*(mod(bin/ steps(3) ,steps(2))+center) ! Phi
|
|
|
|
IO_hybridIA(3,i) = deltas(3)*(mod(bin ,steps(3))+center) ! phi2
|
|
|
|
binSet(j) = binSet(i)
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2007-03-21 18:02:15 +05:30
|
|
|
close(999)
|
|
|
|
return
|
|
|
|
|
|
|
|
! on error
|
2007-03-26 20:33:21 +05:30
|
|
|
100 IO_hybridIA = -1
|
2007-03-21 18:02:15 +05:30
|
|
|
close(999)
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 18:02:15 +05:30
|
|
|
|
|
|
|
|
2009-03-04 17:18:54 +05:30
|
|
|
!********************************************************************
|
|
|
|
! identifies lines without content
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_isBlank (line)
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! get tagged content of line
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_getTag (line,openChar,closechar)
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character(len=*), intent(in) :: line,openChar,closeChar
|
|
|
|
character(len=*), parameter :: sep=achar(32)//achar(9)//achar(10)//achar(13) ! whitespaces
|
|
|
|
character(len=len_trim(line)) IO_getTag
|
|
|
|
integer(pInt) left,right
|
|
|
|
|
|
|
|
IO_getTag = ''
|
|
|
|
left = scan(line,openChar)
|
|
|
|
right = scan(line,closeChar)
|
|
|
|
|
|
|
|
if (left == verify(line,sep) .and. right > left) & ! openChar is first and closeChar occurs
|
|
|
|
IO_getTag = line(left+1:right-1)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
|
|
|
|
!*********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function IO_countSections(file,part)
|
2009-03-04 17:18:54 +05:30
|
|
|
!*********************************************************************
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
!* Definition of variables
|
|
|
|
integer(pInt), intent(in) :: file
|
|
|
|
character(len=*), intent(in) :: part
|
|
|
|
integer(pInt) IO_countSections
|
|
|
|
character(len=1024) line
|
|
|
|
|
|
|
|
IO_countSections = 0
|
|
|
|
line = ''
|
|
|
|
rewind(file)
|
|
|
|
|
|
|
|
do while (IO_getTag(line,'<','>') /= part) ! search for part
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
enddo
|
|
|
|
|
|
|
|
do
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
if (IO_isBlank(line)) cycle ! skip empty lines
|
|
|
|
if (IO_getTag(line,'<','>') /= '') exit ! stop at next part
|
|
|
|
if (IO_getTag(line,'[',']') /= '') & ! found [section] identifier
|
|
|
|
IO_countSections = IO_countSections + 1
|
|
|
|
enddo
|
|
|
|
|
|
|
|
100 return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
|
|
|
|
!*********************************************************************
|
|
|
|
! return array of myTag counts within <part> for at most N[sections]
|
|
|
|
!*********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function IO_countTagInPart(file,part,myTag,Nsections)
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
!* Definition of variables
|
|
|
|
integer(pInt), intent(in) :: file, Nsections
|
|
|
|
character(len=*), intent(in) :: part, myTag
|
|
|
|
integer(pInt), dimension(Nsections) :: IO_countTagInPart, counter
|
|
|
|
integer(pInt), parameter :: maxNchunks = 1
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: positions
|
|
|
|
integer(pInt) section
|
|
|
|
character(len=1024) line,tag
|
|
|
|
|
|
|
|
counter = 0_pInt
|
|
|
|
section = 0_pInt
|
|
|
|
line = ''
|
|
|
|
rewind(file)
|
|
|
|
|
|
|
|
do while (IO_getTag(line,'<','>') /= part) ! search for part
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
enddo
|
|
|
|
|
|
|
|
do
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
if (IO_isBlank(line)) cycle ! skip empty lines
|
|
|
|
if (IO_getTag(line,'<','>') /= '') exit ! stop at next part
|
|
|
|
if (IO_getTag(line,'[',']') /= '') & ! found [section] identifier
|
|
|
|
section = section + 1
|
|
|
|
if (section > 0) then
|
|
|
|
positions = IO_stringPos(line,maxNchunks)
|
|
|
|
tag = IO_lc(IO_stringValue(line,positions,1)) ! extract key
|
|
|
|
if (tag == myTag) & ! match
|
|
|
|
counter(section) = counter(section) + 1
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
|
|
|
100 IO_countTagInPart = counter
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2009-03-04 17:18:54 +05:30
|
|
|
|
|
|
|
|
2009-04-03 16:00:18 +05:30
|
|
|
!*********************************************************************
|
|
|
|
! return array of myTag presence within <part> for at most N[sections]
|
|
|
|
!*********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function IO_spotTagInPart(file,part,myTag,Nsections)
|
2009-04-03 16:00:18 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
!* Definition of variables
|
|
|
|
integer(pInt), intent(in) :: file, Nsections
|
|
|
|
character(len=*), intent(in) :: part, myTag
|
|
|
|
logical, dimension(Nsections) :: IO_spotTagInPart
|
|
|
|
integer(pInt), parameter :: maxNchunks = 1
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: positions
|
|
|
|
integer(pInt) section
|
|
|
|
character(len=1024) line,tag
|
|
|
|
|
|
|
|
IO_spotTagInPart = .false. ! assume to nowhere spot tag
|
|
|
|
section = 0_pInt
|
|
|
|
line = ''
|
|
|
|
rewind(file)
|
|
|
|
|
|
|
|
do while (IO_getTag(line,'<','>') /= part) ! search for part
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
enddo
|
|
|
|
|
|
|
|
do
|
|
|
|
read(file,'(a1024)',END=100) line
|
|
|
|
if (IO_isBlank(line)) cycle ! skip empty lines
|
|
|
|
if (IO_getTag(line,'<','>') /= '') exit ! stop at next part
|
|
|
|
if (IO_getTag(line,'[',']') /= '') & ! found [section] identifier
|
|
|
|
section = section + 1
|
|
|
|
if (section > 0) then
|
|
|
|
positions = IO_stringPos(line,maxNchunks)
|
|
|
|
tag = IO_lc(IO_stringValue(line,positions,1)) ! extract key
|
|
|
|
if (tag == myTag) & ! match
|
|
|
|
IO_spotTagInPart(section) = .true.
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
|
|
|
100 return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2009-04-03 16:00:18 +05:30
|
|
|
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
!********************************************************************
|
|
|
|
! locate at most N space-separated parts in line
|
|
|
|
! return array containing number of parts found and
|
|
|
|
! their left/right positions to be used by IO_xxxVal
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_stringPos (line,N)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
2009-10-12 21:31:49 +05:30
|
|
|
character(len=*), parameter :: sep=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces
|
2009-01-20 00:40:58 +05:30
|
|
|
integer(pInt), intent(in) :: N
|
|
|
|
integer(pInt) part
|
2007-03-20 19:25:22 +05:30
|
|
|
integer(pInt) IO_stringPos(1+N*2)
|
2007-04-25 20:08:22 +05:30
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
IO_stringPos = -1
|
|
|
|
IO_stringPos(1) = 0
|
2007-04-25 20:08:22 +05:30
|
|
|
part = 1
|
2007-03-20 19:25:22 +05:30
|
|
|
do while ((N<1 .or. part<=N) .and. verify(line(IO_stringPos(part*2-1)+1:),sep)>0)
|
|
|
|
IO_stringPos(part*2) = IO_stringPos(part*2-1)+verify(line(IO_stringPos(part*2-1)+1:),sep)
|
|
|
|
IO_stringPos(part*2+1) = IO_stringPos(part*2)+scan(line(IO_stringPos(part*2):),sep)-2
|
|
|
|
part = part+1
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2007-03-20 19:25:22 +05:30
|
|
|
IO_stringPos(1) = part-1
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! read string value at pos from line
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_stringValue (line,positions,pos)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: positions(*),pos
|
2007-03-20 19:25:22 +05:30
|
|
|
character(len=1+positions(pos*2+1)-positions(pos*2)) IO_stringValue
|
2007-04-25 20:08:22 +05:30
|
|
|
|
|
|
|
if (positions(1) < pos) then
|
|
|
|
IO_stringValue = ''
|
2007-03-28 15:30:49 +05:30
|
|
|
else
|
2007-04-25 20:08:22 +05:30
|
|
|
IO_stringValue = line(positions(pos*2):positions(pos*2+1))
|
2007-03-28 15:30:49 +05:30
|
|
|
endif
|
2007-03-20 19:25:22 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
2007-03-21 20:19:21 +05:30
|
|
|
! read string value at pos from fixed format line
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_fixedStringValue (line,ends,pos)
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: ends(*),pos
|
2007-03-28 15:30:49 +05:30
|
|
|
character(len=ends(pos+1)-ends(pos)) IO_fixedStringValue
|
2007-03-21 20:15:03 +05:30
|
|
|
|
2007-03-28 15:30:49 +05:30
|
|
|
IO_fixedStringValue = line(ends(pos)+1:ends(pos+1))
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
!********************************************************************
|
|
|
|
! read float value at pos from line
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_floatValue (line,positions,pos)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: positions(*),pos
|
2009-01-20 00:40:58 +05:30
|
|
|
real(pReal) IO_floatValue
|
2007-03-20 19:25:22 +05:30
|
|
|
|
2009-06-19 12:39:39 +05:30
|
|
|
if (positions(1) < pos) then
|
|
|
|
IO_floatValue = 0.0_pReal
|
|
|
|
else
|
2007-04-25 20:08:22 +05:30
|
|
|
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_floatValue
|
2007-03-28 15:30:49 +05:30
|
|
|
endif
|
2009-06-19 12:39:39 +05:30
|
|
|
return
|
2007-04-26 18:10:06 +05:30
|
|
|
100 IO_floatValue = huge(1.0_pReal)
|
2007-03-20 19:25:22 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
2007-03-21 20:19:21 +05:30
|
|
|
! read float value at pos from fixed format line
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_fixedFloatValue (line,ends,pos)
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: ends(*),pos
|
2009-01-20 00:40:58 +05:30
|
|
|
real(pReal) IO_fixedFloatValue
|
2007-03-21 20:15:03 +05:30
|
|
|
|
2007-04-26 18:10:06 +05:30
|
|
|
read(UNIT=line(ends(pos-1)+1:ends(pos)),ERR=100,FMT=*) IO_fixedFloatValue
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
2007-04-26 18:10:06 +05:30
|
|
|
100 IO_fixedFloatValue = huge(1.0_pReal)
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
2007-03-21 20:19:21 +05:30
|
|
|
! read float x.y+z value at pos from format line line
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_fixedNoEFloatValue (line,ends,pos)
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
2009-01-20 00:40:58 +05:30
|
|
|
integer(pInt), intent(in) :: ends(*),pos
|
|
|
|
integer(pInt) pos_exp,expon
|
|
|
|
real(pReal) IO_fixedNoEFloatValue,base
|
2007-03-21 20:15:03 +05:30
|
|
|
|
2007-03-28 15:30:49 +05:30
|
|
|
pos_exp = scan(line(ends(pos)+1:ends(pos+1)),'+-',back=.true.)
|
2007-03-21 20:15:03 +05:30
|
|
|
if (pos_exp > 1) then
|
2008-03-12 19:23:00 +05:30
|
|
|
read(UNIT=line(ends(pos)+1:ends(pos)+pos_exp-1),ERR=100,FMT=*) base
|
|
|
|
read(UNIT=line(ends(pos)+pos_exp:ends(pos+1)),ERR=100,FMT=*) expon
|
2007-03-21 20:15:03 +05:30
|
|
|
else
|
2007-04-26 18:10:06 +05:30
|
|
|
read(UNIT=line(ends(pos)+1:ends(pos+1)),ERR=100,FMT=*) base
|
2007-03-21 22:34:10 +05:30
|
|
|
expon = 0_pInt
|
2007-03-21 20:15:03 +05:30
|
|
|
endif
|
|
|
|
IO_fixedNoEFloatValue = base*10.0_pReal**expon
|
|
|
|
return
|
2007-04-26 18:10:06 +05:30
|
|
|
100 IO_fixedNoEFloatValue = huge(1.0_pReal)
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
!********************************************************************
|
|
|
|
! read int value at pos from line
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_intValue (line,positions,pos)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: positions(*),pos
|
2009-01-20 00:40:58 +05:30
|
|
|
integer(pInt) IO_intValue
|
2007-03-20 19:25:22 +05:30
|
|
|
|
2009-06-19 12:39:39 +05:30
|
|
|
if (positions(1) < pos) then
|
|
|
|
IO_intValue = 0_pInt
|
|
|
|
else
|
2008-03-12 19:23:00 +05:30
|
|
|
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_intValue
|
2007-04-25 20:08:22 +05:30
|
|
|
endif
|
2009-06-19 12:39:39 +05:30
|
|
|
return
|
2007-04-26 18:10:06 +05:30
|
|
|
100 IO_intValue = huge(1_pInt)
|
2007-03-20 19:25:22 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2007-03-21 20:15:03 +05:30
|
|
|
!********************************************************************
|
|
|
|
! read int value at pos from fixed format line
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_fixedIntValue (line,ends,pos)
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character(len=*), intent(in) :: line
|
|
|
|
integer(pInt), intent(in) :: ends(*),pos
|
2009-01-20 00:40:58 +05:30
|
|
|
integer(pInt) IO_fixedIntValue
|
2007-03-21 20:15:03 +05:30
|
|
|
|
2008-03-12 19:23:00 +05:30
|
|
|
read(UNIT=line(ends(pos)+1:ends(pos+1)),ERR=100,FMT=*) IO_fixedIntValue
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
2007-04-26 18:10:06 +05:30
|
|
|
100 IO_fixedIntValue = huge(1_pInt)
|
2007-03-21 20:15:03 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-21 20:15:03 +05:30
|
|
|
|
|
|
|
|
2007-04-25 20:08:22 +05:30
|
|
|
!********************************************************************
|
|
|
|
! change character in line to lower case
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
pure function IO_lc (line)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-01-16 20:55:37 +05:30
|
|
|
character (len=*), intent(in) :: line
|
2007-03-21 18:02:15 +05:30
|
|
|
character (len=len(line)) IO_lc
|
2007-03-20 19:25:22 +05:30
|
|
|
integer(pInt) i
|
|
|
|
|
2007-03-21 18:02:15 +05:30
|
|
|
IO_lc = line
|
2007-04-25 20:08:22 +05:30
|
|
|
do i=1,len(line)
|
|
|
|
if(64<iachar(line(i:i)) .and. iachar(line(i:i))<91) IO_lc(i:i)=achar(iachar(line(i:i))+32)
|
|
|
|
enddo
|
2007-03-20 19:25:22 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
2007-03-21 18:02:15 +05:30
|
|
|
! in place change of character in line to lower case
|
2007-03-20 19:25:22 +05:30
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
subroutine IO_lcInplace (line)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character (len=*) line
|
2007-03-28 14:01:12 +05:30
|
|
|
character (len=len(line)) IO_lc
|
2007-03-20 19:25:22 +05:30
|
|
|
integer(pInt) i
|
|
|
|
|
2007-03-28 14:01:12 +05:30
|
|
|
IO_lc = line
|
2007-04-25 20:08:22 +05:30
|
|
|
do i=1,len(line)
|
|
|
|
if(64<iachar(line(i:i)) .and. iachar(line(i:i))<91) IO_lc(i:i)=achar(iachar(line(i:i))+32)
|
|
|
|
enddo
|
2007-03-28 14:01:12 +05:30
|
|
|
line = IO_lc
|
2007-03-20 19:25:22 +05:30
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endsubroutine
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2009-04-03 12:34:31 +05:30
|
|
|
!********************************************************************
|
|
|
|
! read on in file to skip (at least) N chunks (may be over multiple lines)
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
subroutine IO_skipChunks (unit,N)
|
2009-04-03 12:34:31 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(pInt) remainingChunks,unit,N
|
|
|
|
integer(pInt), parameter :: maxNchunks = 64
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: pos
|
|
|
|
character(len=300) line
|
|
|
|
|
|
|
|
remainingChunks = N
|
|
|
|
do while (remainingChunks > 0)
|
|
|
|
read(unit,'(A300)',end=100) line
|
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
remainingChunks = remainingChunks - pos(1)
|
2009-06-15 18:41:21 +05:30
|
|
|
enddo
|
2009-04-03 12:34:31 +05:30
|
|
|
100 return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endsubroutine
|
2009-04-03 12:34:31 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! extract value from key=value pair and check whether key matches
|
|
|
|
!********************************************************************
|
|
|
|
pure function IO_extractValue (line,key)
|
2009-04-03 12:34:31 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
character(len=*), intent(in) :: line,key
|
|
|
|
character(len=*), parameter :: sep = achar(61) ! '='
|
|
|
|
integer(pInt) pos
|
|
|
|
character(len=300) IO_extractValue
|
|
|
|
|
|
|
|
IO_extractValue = ''
|
|
|
|
|
|
|
|
pos = scan(line,sep)
|
|
|
|
if (pos > 0 .and. line(:pos-1) == key(:pos-1)) & ! key matches expected key
|
|
|
|
IO_extractValue = line(pos+1:) ! extract value
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2007-04-25 20:08:22 +05:30
|
|
|
!********************************************************************
|
2009-10-12 21:31:49 +05:30
|
|
|
! count lines containig data up to next *keyword
|
2007-10-15 19:25:52 +05:30
|
|
|
!********************************************************************
|
2009-10-12 21:31:49 +05:30
|
|
|
function IO_countDataLines (unit)
|
2007-10-15 19:25:52 +05:30
|
|
|
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
integer(pInt) IO_countDataLines,unit
|
|
|
|
integer(pInt), parameter :: maxNchunks = 64
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: pos
|
|
|
|
character(len=300) line,tmp
|
2007-10-15 19:25:52 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
IO_countDataLines = 0
|
2007-10-15 19:25:52 +05:30
|
|
|
do
|
|
|
|
read(unit,'(A300)',end=100) line
|
2009-10-12 21:31:49 +05:30
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
tmp = IO_lc(IO_stringValue(line,pos,1))
|
|
|
|
if (tmp(1:1) == '*' ) then ! found keyword
|
|
|
|
exit
|
2007-10-15 19:25:52 +05:30
|
|
|
else
|
2009-10-12 21:31:49 +05:30
|
|
|
IO_countDataLines = IO_countDataLines + 1_pInt
|
2007-10-15 19:25:52 +05:30
|
|
|
endif
|
|
|
|
enddo
|
2009-10-12 21:31:49 +05:30
|
|
|
100 backspace(unit)
|
|
|
|
return
|
|
|
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! count items in consecutive lines
|
|
|
|
! Marc: ints concatenated by "c" as last char or range of values a "to" b
|
|
|
|
! Abaqus: triplet of start,stop,inc
|
|
|
|
!********************************************************************
|
|
|
|
function IO_countContinousIntValues (unit)
|
|
|
|
|
|
|
|
use cpfem_interface
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(pInt) unit,i,j,l,count
|
|
|
|
integer(pInt) IO_countContinousIntValues
|
|
|
|
integer(pInt), parameter :: maxNchunks = 64
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: pos
|
|
|
|
character(len=300) line
|
|
|
|
|
|
|
|
IO_countContinousIntValues = 0_pInt
|
|
|
|
|
|
|
|
select case (FEsolver)
|
|
|
|
case ('Marc')
|
|
|
|
|
|
|
|
do
|
|
|
|
read(unit,'(A300)',end=100) line
|
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
if (IO_lc(IO_stringValue(line,pos,2)) == 'to' ) then ! found range indicator
|
|
|
|
IO_countContinousIntValues = 1 + IO_intValue(line,pos,3) - IO_intValue(line,pos,1)
|
|
|
|
exit ! only one single range indicator allowed
|
|
|
|
else
|
|
|
|
IO_countContinousIntValues = IO_countContinousIntValues+pos(1)-1 ! add line's count when assuming 'c'
|
|
|
|
if ( IO_lc(IO_stringValue(line,pos,pos(1))) /= 'c' ) then ! line finished, read last value
|
|
|
|
IO_countContinousIntValues = IO_countContinousIntValues+1
|
|
|
|
exit ! data ended
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
|
|
|
case('Abaqus')
|
|
|
|
|
|
|
|
count = IO_countDataLines(unit)
|
|
|
|
do l = 1,count
|
|
|
|
backspace(unit)
|
|
|
|
enddo
|
|
|
|
|
|
|
|
do l = 1,count
|
|
|
|
read(unit,'(A300)',end=100) line
|
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
IO_countContinousIntValues = IO_countContinousIntValues + 1 + & ! assuming range generation
|
|
|
|
(IO_intValue(line,pos,2)-IO_intValue(line,pos,1))/max(1,IO_intValue(line,pos,3))
|
|
|
|
enddo
|
|
|
|
|
|
|
|
endselect
|
|
|
|
|
2007-10-15 19:25:52 +05:30
|
|
|
100 return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-10-15 19:25:52 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
|
|
|
|
!********************************************************************
|
|
|
|
! return integer list corrsponding to items in consecutive lines
|
|
|
|
! Marc: ints concatenated by "c" as last char, range of a "to" b, or named set
|
|
|
|
! Abaqus: triplet of start,stop,inc or named set
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
function IO_continousIntValues (unit,maxN,lookupName,lookupMap,lookupMaxN)
|
2007-04-25 20:08:22 +05:30
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
use cpfem_interface
|
2007-04-25 20:08:22 +05:30
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
integer(pInt) unit,maxN,i,j,l,count,first,last
|
2007-04-25 20:08:22 +05:30
|
|
|
integer(pInt), dimension(1+maxN) :: IO_continousIntValues
|
2009-10-12 21:31:49 +05:30
|
|
|
integer(pInt), parameter :: maxNchunks = 64
|
|
|
|
integer(pInt), dimension(1+2*maxNchunks) :: pos
|
2007-10-23 18:38:27 +05:30
|
|
|
character(len=64), dimension(:) :: lookupName
|
|
|
|
integer(pInt) :: lookupMaxN
|
|
|
|
integer(pInt), dimension(:,:) :: lookupMap
|
2007-04-25 20:08:22 +05:30
|
|
|
character(len=300) line
|
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
IO_continousIntValues = 0
|
|
|
|
|
|
|
|
select case (FEsolver)
|
|
|
|
case ('Marc')
|
|
|
|
|
|
|
|
do
|
|
|
|
read(unit,'(A300)',end=100) line
|
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
if (verify(IO_stringValue(line,pos,1),"0123456789") > 0) then ! a non-int, i.e. set name
|
|
|
|
do i = 1,lookupMaxN ! loop over known set names
|
|
|
|
if (IO_stringValue(line,pos,1) == lookupName(i)) then ! found matching name
|
|
|
|
IO_continousIntValues = lookupMap(:,i) ! return resp. entity list
|
|
|
|
exit
|
|
|
|
endif
|
|
|
|
enddo
|
2007-10-23 18:38:27 +05:30
|
|
|
exit
|
2009-10-12 21:31:49 +05:30
|
|
|
else if (IO_lc(IO_stringValue(line,pos,2)) == 'to' ) then ! found range indicator
|
|
|
|
do i = IO_intValue(line,pos,1),IO_intValue(line,pos,3)
|
|
|
|
IO_continousIntValues(1) = IO_continousIntValues(1) + 1
|
|
|
|
IO_continousIntValues(1+IO_continousIntValues(1)) = i
|
|
|
|
enddo
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
do i = 1,pos(1)-1 ! interpret up to second to last value
|
|
|
|
IO_continousIntValues(1) = IO_continousIntValues(1) + 1
|
|
|
|
IO_continousIntValues(1+IO_continousIntValues(1)) = IO_intValue(line,pos,i)
|
|
|
|
enddo
|
|
|
|
if ( IO_lc(IO_stringValue(line,pos,pos(1))) /= 'c' ) then ! line finished, read last value
|
|
|
|
IO_continousIntValues(1) = IO_continousIntValues(1)+1
|
|
|
|
IO_continousIntValues(1+IO_continousIntValues(1)) = IO_intValue(line,pos,pos(1))
|
|
|
|
exit
|
|
|
|
endif
|
2007-10-23 18:38:27 +05:30
|
|
|
endif
|
|
|
|
enddo
|
2009-10-12 21:31:49 +05:30
|
|
|
|
|
|
|
case('Abaqus')
|
|
|
|
|
|
|
|
count = IO_countDataLines(unit)
|
|
|
|
do l = 1,count
|
|
|
|
backspace(unit)
|
2007-04-25 20:08:22 +05:30
|
|
|
enddo
|
2009-10-12 21:31:49 +05:30
|
|
|
|
|
|
|
do l = 1,count
|
|
|
|
read(unit,'(A300)',end=100) line
|
|
|
|
pos = IO_stringPos(line,maxNchunks)
|
|
|
|
if (verify(IO_stringValue(line,pos,1),"0123456789") > 0) then ! a non-int, i.e. set names follow on this line
|
|
|
|
do i = 1,pos(1) ! loop over set names in line
|
|
|
|
do j = 1,lookupMaxN ! look thru known set names
|
|
|
|
if (IO_stringValue(line,pos,i) == lookupName(j)) then ! found matching name
|
|
|
|
first = 2 + IO_continousIntValues(1) ! where to start appending data
|
|
|
|
last = first + lookupMap(1,j) - 1 ! up to where to append data
|
|
|
|
IO_continousIntValues(first:last) = lookupMap(2:1+lookupMap(1,j),j) ! add resp. entity list
|
|
|
|
IO_continousIntValues(1) = IO_continousIntValues(1) + lookupMap(1,j) ! count them
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
else ! assuming range generation
|
|
|
|
do i = IO_intValue(line,pos,1),IO_intValue(line,pos,2),max(1,IO_intValue(line,pos,3))
|
|
|
|
IO_continousIntValues(1) = IO_continousIntValues(1) + 1
|
|
|
|
IO_continousIntValues(1+IO_continousIntValues(1)) = i
|
|
|
|
enddo
|
|
|
|
endif
|
2007-04-25 20:08:22 +05:30
|
|
|
enddo
|
2009-10-12 21:31:49 +05:30
|
|
|
|
|
|
|
endselect
|
|
|
|
|
2007-04-25 20:08:22 +05:30
|
|
|
100 return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endfunction
|
2007-04-25 20:08:22 +05:30
|
|
|
|
|
|
|
|
2009-10-12 21:31:49 +05:30
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
!********************************************************************
|
|
|
|
! write error statements to standard out
|
|
|
|
! and terminate the Marc run with exit #9xxx
|
|
|
|
! in ABAQUS either time step is reduced or execution terminated
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
subroutine IO_error(ID,e,i,g,ext_msg)
|
2007-03-20 19:25:22 +05:30
|
|
|
|
2008-02-15 15:34:49 +05:30
|
|
|
use prec, only: pInt
|
2007-03-20 19:25:22 +05:30
|
|
|
implicit none
|
|
|
|
|
2009-03-04 17:18:54 +05:30
|
|
|
integer(pInt), intent(in) :: ID
|
|
|
|
integer(pInt), optional, intent(in) :: e,i,g
|
|
|
|
character(len=*), optional, intent(in) :: ext_msg
|
2007-03-20 19:25:22 +05:30
|
|
|
character(len=80) msg
|
|
|
|
|
|
|
|
select case (ID)
|
2009-03-04 17:18:54 +05:30
|
|
|
case (0)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Unable to open input file'
|
2009-07-22 21:37:19 +05:30
|
|
|
case (50)
|
|
|
|
msg = 'Error writing constitutive output description'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (100)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Error reading from configuration file'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (105)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Error reading from ODF file'
|
2008-02-15 15:34:49 +05:30
|
|
|
case (110)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'No homogenization specified via State Variable 2'
|
2008-02-15 15:34:49 +05:30
|
|
|
case (120)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'No microstructure specified via State Variable 3'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (130)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Homogenization index out of bounds'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (140)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Microstructure index out of bounds'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (150)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Phase index out of bounds'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (160)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Texture index out of bounds'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (170)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Sum of phase fractions differs from 1'
|
2007-03-20 19:25:22 +05:30
|
|
|
case (200)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Unknown constitution specified'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (201)
|
2009-06-08 18:58:00 +05:30
|
|
|
msg = 'Unknown homogenization specified'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (205)
|
2009-07-22 21:37:19 +05:30
|
|
|
msg = 'Unknown lattice structure encountered'
|
|
|
|
case (210)
|
|
|
|
msg = 'Negative initial resistance'
|
|
|
|
case (211)
|
|
|
|
msg = 'Non-positive reference shear rate'
|
|
|
|
case (212)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Non-positive stress exponent'
|
2009-07-22 21:37:19 +05:30
|
|
|
case (213)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Non-positive saturation stress'
|
2009-08-31 19:43:10 +05:30
|
|
|
case (214)
|
|
|
|
msg = 'Zero hardening exponent'
|
2009-03-05 21:36:01 +05:30
|
|
|
case (220)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Negative initial dislocation density'
|
2009-03-05 21:36:01 +05:30
|
|
|
case (221)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Negative Bugers vector'
|
2009-03-05 21:36:01 +05:30
|
|
|
case (222)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Negative activation energy for edge dislocation glide'
|
2009-03-05 21:36:01 +05:30
|
|
|
case (223)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Negative self diffusion energy'
|
2009-03-05 21:36:01 +05:30
|
|
|
case (224)
|
2009-07-22 21:37:19 +05:30
|
|
|
msg = 'Non-positive diffusion prefactor'
|
|
|
|
case (225)
|
|
|
|
msg = 'No slip systems specified'
|
2009-09-18 21:07:14 +05:30
|
|
|
case (226)
|
|
|
|
msg = 'Non-positive prefactor for dislocation velocity'
|
|
|
|
case (227)
|
|
|
|
msg = 'Non-positive prefactor for mean free path'
|
|
|
|
case (228)
|
|
|
|
msg = 'Non-positive minimum stable dipole distance'
|
|
|
|
case (229)
|
|
|
|
msg = 'Hardening interaction coefficients below one'
|
|
|
|
case (230)
|
|
|
|
msg = 'Non-positive atomic volume'
|
|
|
|
case (231)
|
|
|
|
msg = 'Non-positive prefactor for self-diffusion coefficient'
|
|
|
|
case (232)
|
|
|
|
msg = 'Non-positive activation energy for dislocation climb'
|
|
|
|
case (233)
|
|
|
|
msg = 'Non-positive relevant dislocation density'
|
2009-03-05 22:37:32 +05:30
|
|
|
case (240)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Non-positive Taylor factor'
|
2009-07-22 21:37:19 +05:30
|
|
|
case (241)
|
|
|
|
msg = 'Non-positive hardening exponent'
|
2009-09-18 21:07:14 +05:30
|
|
|
case (242)
|
|
|
|
msg = 'Non-positive relevant slip resistance'
|
2009-06-15 18:41:21 +05:30
|
|
|
case (260)
|
|
|
|
msg = 'Non-positive relevant strain'
|
|
|
|
case (261)
|
|
|
|
msg = 'Frequency for Stiffness update smaller than zero'
|
|
|
|
case (262)
|
|
|
|
msg = 'Frequency for Jacobian update of Lp residuum smaller than zero'
|
|
|
|
case (263)
|
|
|
|
msg = 'Non-positive perturbation value'
|
|
|
|
case (264)
|
|
|
|
msg = 'Limit for homogenization loop too small'
|
|
|
|
case (265)
|
|
|
|
msg = 'Limit for crystallite loop too small'
|
|
|
|
case (266)
|
2009-08-13 18:51:22 +05:30
|
|
|
msg = 'Limit for state loop too small'
|
2009-06-15 18:41:21 +05:30
|
|
|
case (267)
|
|
|
|
msg = 'Limit for stress loop too small'
|
|
|
|
case (268)
|
|
|
|
msg = 'Non-positive minimum substep size'
|
|
|
|
case (269)
|
|
|
|
msg = 'Non-positive relative tolerance for state'
|
|
|
|
case (270)
|
|
|
|
msg = 'Non-positive relative tolerance for stress'
|
|
|
|
case (271)
|
|
|
|
msg = 'Non-positive absolute tolerance for stress'
|
2009-07-31 17:32:20 +05:30
|
|
|
|
|
|
|
!* Error messages related to RGC numerical parameters <<<updated 31.07.2009>>>
|
2009-06-15 18:41:21 +05:30
|
|
|
case (272)
|
2009-07-31 17:32:20 +05:30
|
|
|
msg = 'Non-positive relative tolerance of residual in RGC'
|
2009-06-15 18:41:21 +05:30
|
|
|
case (273)
|
2009-07-31 17:32:20 +05:30
|
|
|
msg = 'Non-positive absolute tolerance of residual in RGC'
|
2009-06-15 18:41:21 +05:30
|
|
|
case (274)
|
2009-07-31 17:32:20 +05:30
|
|
|
msg = 'Non-positive relative maximum of residual in RGC'
|
2009-06-15 18:41:21 +05:30
|
|
|
case (275)
|
2009-07-31 17:32:20 +05:30
|
|
|
msg = 'Non-positive absolute maximum of residual in RGC'
|
|
|
|
case (276)
|
|
|
|
msg = 'Non-positive penalty perturbation in RGC'
|
|
|
|
case (277)
|
|
|
|
msg = 'Non-positive relevant mismatch in RGC'
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
case (300)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'This material can only be used with elements with three direct stress components'
|
2007-03-20 19:25:22 +05:30
|
|
|
case (500)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Unknown lattice type specified'
|
2007-03-20 19:25:22 +05:30
|
|
|
case (600)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Convergence not reached'
|
2009-03-04 17:18:54 +05:30
|
|
|
case (610)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Stress loop not converged'
|
2007-03-20 19:25:22 +05:30
|
|
|
case (700)
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Singular matrix in stress iteration'
|
2007-03-20 19:25:22 +05:30
|
|
|
case default
|
2009-03-31 14:51:57 +05:30
|
|
|
msg = 'Unknown error number...'
|
2007-03-20 19:25:22 +05:30
|
|
|
end select
|
2009-01-20 00:40:58 +05:30
|
|
|
|
2008-05-26 18:41:25 +05:30
|
|
|
!$OMP CRITICAL (write2out)
|
2009-03-31 14:51:57 +05:30
|
|
|
write(6,*)
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a38)') '+------------------------------------+'
|
|
|
|
write(6,'(a38)') '+ error +'
|
|
|
|
write(6,'(a38)') '+ +'
|
|
|
|
write(6,*) '+ ',msg
|
|
|
|
if (present(ext_msg)) write(6,*) '+ ',ext_msg
|
2009-03-04 17:18:54 +05:30
|
|
|
if (present(e)) then
|
|
|
|
if (present(i) .and. present(g)) then
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a12,x,i6,x,a2,x,i2,x,a5,x,i4,a2)') '+ at element',e,'IP',i,'grain',g,' +'
|
2009-03-04 17:18:54 +05:30
|
|
|
else
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a17,i6,a14)') '+ at ',e,' +'
|
2009-03-04 17:18:54 +05:30
|
|
|
endif
|
|
|
|
endif
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a38)') '+------------------------------------+'
|
2009-06-15 18:41:21 +05:30
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
call flush(6)
|
2007-05-16 20:06:03 +05:30
|
|
|
call quit(9000+ID)
|
2009-01-20 00:40:58 +05:30
|
|
|
!$OMP END CRITICAL (write2out)
|
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
! ABAQUS returns in some cases
|
|
|
|
return
|
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endsubroutine
|
2007-03-20 19:25:22 +05:30
|
|
|
|
|
|
|
|
2009-03-31 14:51:57 +05:30
|
|
|
!********************************************************************
|
|
|
|
! write warning statements to standard out
|
|
|
|
!********************************************************************
|
2009-06-15 18:41:21 +05:30
|
|
|
subroutine IO_warning(ID,e,i,g,ext_msg)
|
2009-03-31 14:51:57 +05:30
|
|
|
|
|
|
|
use prec, only: pInt
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
integer(pInt), intent(in) :: ID
|
|
|
|
integer(pInt), optional, intent(in) :: e,i,g
|
|
|
|
character(len=*), optional, intent(in) :: ext_msg
|
|
|
|
character(len=80) msg
|
|
|
|
|
|
|
|
select case (ID)
|
2009-05-07 21:57:36 +05:30
|
|
|
case (600)
|
2009-05-28 22:08:40 +05:30
|
|
|
msg = '+ Crystallite responds elastically +'
|
|
|
|
case (650)
|
|
|
|
msg = '+ Polar decomposition failed +'
|
2009-03-31 14:51:57 +05:30
|
|
|
case default
|
2009-05-28 22:08:40 +05:30
|
|
|
msg = '+ Unknown warning number... +'
|
2009-03-31 14:51:57 +05:30
|
|
|
end select
|
|
|
|
|
|
|
|
!$OMP CRITICAL (write2out)
|
|
|
|
write(6,*)
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a38)') '+------------------------------------+'
|
|
|
|
write(6,'(a38)') '+ warning +'
|
|
|
|
write(6,'(a38)') '+ +'
|
|
|
|
write(6,'(a38)') msg
|
|
|
|
if (present(ext_msg)) write(6,*) '+ ',ext_msg
|
2009-03-31 14:51:57 +05:30
|
|
|
if (present(e)) then
|
|
|
|
if (present(i) .and. present(g)) then
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a12,x,i6,x,a2,x,i2,x,a5,x,i4,a2)') '+ at element',e,'IP',i,'grain',g,' +'
|
2009-03-31 14:51:57 +05:30
|
|
|
else
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a17,i6,a14)') '+ at ',e,' +'
|
2009-03-31 14:51:57 +05:30
|
|
|
endif
|
|
|
|
endif
|
2009-05-28 22:08:40 +05:30
|
|
|
write(6,'(a38)') '+------------------------------------+'
|
2009-03-31 14:51:57 +05:30
|
|
|
|
2009-06-15 18:41:21 +05:30
|
|
|
endsubroutine
|
2009-03-31 14:51:57 +05:30
|
|
|
|
2007-03-20 19:25:22 +05:30
|
|
|
END MODULE IO
|