Lewis,
The operation,
DO WHILE (INDEX(STRING,'Connectivity').EQ.3
& .OR.INDEX(STRING,'domain').EQ.6
& .OR.INDEX(STRING,'domain').EQ.7)
causes the program to fail because of logic contained in the do-while
loop that is not able to specify the correct columns of data for those
lines that have a four-digit line number (1000 or greater). If the
"INDEX(STRING,'domain').EQ.7" test is not included, then those lines are
simply not processed by the loop and the error is avoided. For example,
it appears that the line,
READ(STRING(13:NLEN-1),*) BLKSRC
expects the period after "domain" to be in column 12, but with a
four-digit line number, that period will be in column 13 (according to
your input file sample), causing an error in the read, assuming that
BLKSRC is an integer.
In this situation, I tend to use unformatted reads as much as possible
and without trying to specify the individual column location of each
value. For example, you could isolate the part of STRING that contains
the values that you want to read in and then read that portion of STRING
with an unformatted read. Something like:
position = index(STRING," f ",back=.true.)
if(position.ne.0)then
read(STRING(position+3:),*) BEG(1),BEG(2),BEG(3),END(1),END(2),END(3)
endif
Steve Rowles
Naval Surface Warfare Center
Dahlgren VA
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf
Of Lewis Balfour
Sent: Wednesday, March 29, 2006 5:27 AM
To: [log in to unmask]
Subject: Re: End of file errors using intrinsic function INDEX (3)
Hi
Ok, a little more information about my problem. I am converting a
multiblock structred mesh from an ICEMCFD format (MULTIBLOCK-INFO) to a
format used for an in-house code DELTA. The original conversion routine
was not written by me, but works perfectly in most circumstances, and
converts the grid topology from the ICEM format to that required by
DELTA.
The mesh I wish to use is a stuctured grid with 50 blocks and
approximately 1.5 million cells. The topology file outputted by ICEM is
approximately 7000 lines long. The problem with my conversion routine
is that it assumes that there will be less than 1000 connectivities
between the blocks i.e. the mesh has less then approximately 25 blocks.
The lines in the code as follows
DO WHILE (INDEX(STRING,'Connectivity').EQ.3
& .OR.INDEX(STRING,'domain').EQ.6)
decide the types of operation that are performed on the file. If this
is not the case the operations on the block dimensions or boundary
conditions are performed. If there are more than 999 connectivties then
the Fortran routine does not 'see' the extra connectivites and moves
onto the next part of the routine.
# Connectivity for domain.16
967 domain.16 -j k-i f 33 1 1 1 122
1
967 domain.18 -j k i f 33 1 25 1 122
25
968 domain.16 k i-j f 1 1 1 122 17
1
968 domain.17 k i j f 1 13 12 122 29
12
969 domain.16 k i j f 1 1 33 122 17
33
969 domain.15 k i-j f 1 13 1 122 29
1
970 domain.16 i-j-k f 1 33 1 17 1
1
970 domain.9 i-j k f 1 33 15 17 1
15
<snip>
991 domain.16 i j k e 1 33 122 17 33
122
991 domain.22 i-j-k e 13 1 1 29 1
1
992 domain.16 i j k e 1 33 122 17 33
122
992 domain.23 i j-k e 1 33 1 17 33
1
993 domain.16 i j k e 1 33 122 17 33
122
993 domain.15 i-j k e 13 1 122 29 1
122
994 domain.16 -j i-k e 33 17 1 24 17
1
994 domain.9 -j i k e 33 17 15 24 17
15
995 domain.16 -j i-k e 24 17 1 10 17
1
995 domain.47 -j-i k e 15 1 15 1 1
15
996 domain.16 -j i-k e 24 17 1 10 17
1
996 domain.9 -j i k e 24 17 15 10 17
15
997 domain.16 -j i-k e 10 17 1 1 17
1
997 domain.9 -j i k e 10 17 15 1 17
15
998 domain.16 k-j i e 1 1 17 52 1
17
998 domain.17 k j i e 1 12 29 52 12
29
999 domain.16 k-j i e 52 1 17 94 1
17
999 domain.17 k j i e 52 12 29 94 12
29
1000 domain.16 k-j i e 94 1 17 122 1
17
1000 domain.17 k j i e 94 12 29 122 12
29
1001 domain.16 i-j k e 1 1 122 17 1
122
1001 domain.24 i j-k e 13 12 1 29 12
1
1002 domain.16 i-j k e 1 1 122 17 1
122
1002 domain.23 i-j-k e 1 1 1 17 1
1
1003 domain.16 i-j k e 1 1 122 17 1
122
1003 domain.17 i j k e 13 12 122 29 12
122
1004 domain.16 -j i k e 33 17 122 24 17
122
1004 domain.23 -j i-k e 33 17 1 24 17
1
1005 domain.16 -j i k e 24 17 122 10 17
122
1005 domain.23 -j i-k e 24 17 1 10 17
1
1006 domain.16 -j i k e 10 17 122 1 17
122
1006 domain.23 -j i-k e 10 17 1 1 17
1
1007 domain.16 i j k v 1 33 1 1 33
1
1007 domain.8 i j k v 13 1 15 13
1 15
1008 domain.16 i j k v 1 33 1 1 33
1
1008 domain.9 i j k v 1 33 15 1
33 15
1009 domain.16 i j k v 1 33 1 1 33
1
1009 domain.11 i j k v 25 33 15 25 33
15
1010 domain.16 i j k v 1 33 1 1 33
1
<snip>
1041 domain.16 i j k v 17 1 122 17 1
122
1041 domain.24 i j k v 29 12 1 29 12
1
1042 domain.16 i j k v 17 24 122 17 24
122
1042 domain.23 i j k v 17 24 1 17 24
1
# Connectivity for domain.17
1043 domain.17 j k-i f 1 1 1 12 122
1
etc.
Here is the Majority of the routine
<snipped>
The EXTERNALS are routines that return values such as 0 or 1 depending
on the existance or otherwise of files.
In Summary. The file is opened as unit u1
u1=fortOpen(infofile, format, status )
Then a line is read in
READ (u1,'(A88)') STRING
Then operations are performed on it.
I'd like to re-emphasise that the routine works perfectly where the
number of connectivities are less than 1000. Other parts of the routine
need re-writing eg the line
READ (STRING(29:34),*) BEG(1)
Will probably need to be adjusted to be
READ (STRING(30:35),*) BEG(1)
But the original question stands: why does the operation
DO WHILE (INDEX(STRING,'Connectivity').EQ.3
& .OR.INDEX(STRING,'domain').EQ.6
& .OR.INDEX(STRING,'domain').EQ.7)
fail? The error given
Input/Output Error 153: Input file ended
In Procedure: topobcwrite
At Line: 249
Statement: List-Directed READ
Unit: Internal File
Record Number: Floating point exception
Suggests that the file has ended, but there are approximately 4000 lines
remaining. And line 249 in the code is the DO WHILE statement, not a
read. The string read in has 88 spaces, wheras the longest line is 84
characters long.
Many thanks
Lewis
*****************************************
l.j.balfour at lboro.ac.uk
Research Student
Rolls-Royce UTC in Combustor Aerodynamics
Loughborough University
*****************************************
|