fixed flaws in fixedFormat number extraction

This commit is contained in:
William Counts 2007-03-28 10:00:49 +00:00
parent d121fbc9dd
commit 6d3155efcb
1 changed files with 23 additions and 15 deletions

View File

@ -278,7 +278,11 @@
integer(pInt) positions(*),pos integer(pInt) positions(*),pos
character(len=1+positions(pos*2+1)-positions(pos*2)) IO_stringValue 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)) IO_stringValue = line(positions(pos*2):positions(pos*2+1))
endif
return return
END FUNCTION END FUNCTION
@ -294,9 +298,9 @@
character(len=*) line character(len=*) line
integer(pInt) ends(*),pos integer(pInt) ends(*),pos
character(len=ends(pos)-ends(pos-1)) IO_fixedStringValue character(len=ends(pos+1)-ends(pos)) IO_fixedStringValue
IO_fixedStringValue = line(ends(pos-1)+1:ends(pos)) IO_fixedStringValue = line(ends(pos)+1:ends(pos+1))
return return
END FUNCTION END FUNCTION
@ -314,8 +318,10 @@
real(pReal) IO_floatValue real(pReal) IO_floatValue
integer(pInt) positions(*),pos integer(pInt) positions(*),pos
if (positions(1) >= pos) then
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT='(F)') IO_floatValue read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT='(F)') IO_floatValue
return return
endif
100 IO_floatValue = -1.0_pReal 100 IO_floatValue = -1.0_pReal
return return
@ -354,12 +360,12 @@
real(pReal) IO_fixedNoEFloatValue,base real(pReal) IO_fixedNoEFloatValue,base
integer(pInt) ends(*),pos,pos_exp,expon integer(pInt) ends(*),pos,pos_exp,expon
pos_exp = scan(line(ends(pos-1)+1:ends(pos)),'+-',back=.true.) pos_exp = scan(line(ends(pos)+1:ends(pos+1)),'+-',back=.true.)
if (pos_exp > 1) then if (pos_exp > 1) then
read(UNIT=line(ends(pos-1)+1:ends(pos-1)+pos_exp-1),ERR=100,FMT='(F)') base read(UNIT=line(ends(pos)+1:ends(pos)+pos_exp-1),ERR=100,FMT='(F)') base
read(UNIT=line(ends(pos-1)+pos_exp:ends(pos)),ERR=100,FMT='(I)') expon read(UNIT=line(ends(pos)+pos_exp:ends(pos+1)),ERR=100,FMT='(I)') expon
else else
read(UNIT=line(ends(pos-1)+1:ends(pos)),ERR=100,FMT='(F)') base read(UNIT=line(ends(pos)+1:ends(pos+1)),ERR=100,FMT='(F)') base
expon = 0_pInt expon = 0_pInt
endif endif
IO_fixedNoEFloatValue = base*10.0_pReal**expon IO_fixedNoEFloatValue = base*10.0_pReal**expon
@ -382,8 +388,10 @@
integer(pInt) IO_intValue integer(pInt) IO_intValue
integer(pInt) positions(*),pos integer(pInt) positions(*),pos
if (positions(1) >= pos) then
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT='(I)') IO_intValue read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT='(I)') IO_intValue
return return
endif
100 IO_intValue = -1_pInt 100 IO_intValue = -1_pInt
return return
@ -402,7 +410,7 @@
integer(pInt) IO_fixedIntValue integer(pInt) IO_fixedIntValue
integer(pInt) ends(*),pos integer(pInt) ends(*),pos
read(UNIT=line(ends(pos-1)+1:ends(pos)),ERR=100,FMT='(I)') IO_fixedIntValue read(UNIT=line(ends(pos)+1:ends(pos+1)),ERR=100,FMT='(I)') IO_fixedIntValue
return return
100 IO_fixedIntValue = -1_pInt 100 IO_fixedIntValue = -1_pInt
return return