JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2006

COMP-FORTRAN-90 2006

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: End of file errors using intrinsic function INDEX (3)

From:

Lewis Balfour <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Wed, 29 Mar 2006 12:26:52 +0200

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (490 lines)

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

SUBROUTINE icemRead( xc, yc, zc, r, imx, jmx, kmx, nblocks )

!    (* icemRead: reads in ICEM Multiblock grid
!		  and converts to geom format				*)

	IMPLICIT NONE
        INCLUDE 'symbolDefs'
        INCLUDE 'fileLibDefs'

!    (* arguments *)
	INTEGER imx(0:*), jmx(0:*), kmx(0:*), nblocks
	REAL	xc(1:*), yc(1:*), zc(1:*), r(0:DIMS,0:*)

!    (* locals *)
	INTEGER u, format, status, error, stringMax
        PARAMETER stringmax=88
	INTEGER I, J, K, IDIM, JDIM, KDIM, BLK, NPTS, XYZP, RP, NLEN
	INTEGER IMXB, JMXB, KMXB, N, PTR1, PTR2
	INTEGER IFACE1, JFACE1, KFACE1, IFACE2, JFACE2, KFACE2
	CHARACTER*(stringMax) STRING, FILE, message
	LOGICAL DONE

!    (* externals *)
	INTEGER fortOpen, fortClose, blockPtr, BLANKLEN
	EXTERNAL fortOpen, fortClose, blockPtr,fortAbort
format= FORTFORMAT
	status= FORTOLD
	WRITE(STDOUT,FMT='(A)') ' ICEM Multiblock topology file ?'
	READ(STDIN,FMT='(A)') infofile
	WRITE(STDOUT,*)

        u1=fortOpen(infofile, format, status )
        IF ( u1.LT. 0 ) THEN ! error
	  message= 'failed to open file '//infofile
          CALL fortAbort( 'icemRead', u1, message )
        END IF ! u1

        WRITE(STDOUT,*) ' reading ICEM Multiblock topology file...'
        WRITE(STDOUT,*) ' extracting topology info...'
	WRITE(STDOUT,*)

	format= FORTFORMAT
	status= FORTNEW
	error= querydbs('topology.file',topofile)
	IF (error.NE.0) THEN
	  WRITE(STDOUT,*) 'output topology file?'
	  READ(STDIN,FMT='(A)') topofile
	  WRITE(STDOUT,*)
	END IF
        u2=fortOpen(topofile, format, status )
        IF ( u2.LT. 0 ) THEN ! error
	  message= 'failed to open file '//topofile
          CALL fortAbort( 'icemRead', u2, message )
        END IF ! u2

	error= querydbs('bc.file',bcfile)
	IF (error.NE.0) THEN
	  WRITE(STDOUT,*) ' output boundary condition file?'
	  READ(STDIN,FMT='(A)') bcfile
	  WRITE(STDOUT,*)
	END IF
        u3=fortOpen(bcfile, format, status )
        IF ( u3.LT. 0 ) THEN ! error
	  message= 'failed to open file '//bcfile
          CALL fortAbort( 'icemRead', u3, message )
        END IF ! u3

	READ (u1,'(A88)') STRING
	READ (u1,'(A88)') STRING
	WRITE (u2,'(A18)') '# delta.V2.topfile'
	WRITE (u2,'(A9)') '# nblocks'

	READ (u1,'(A88)') STRING

	I=0
	DO WHILE (INDEX(STRING,'domain').EQ.1)
	  I=I+1
	  NLEN=TABLEN(STRING)
	  WKSTR=STRING(8:NLEN-1)
	  READ(WKSTR,*) BLKSRC
	  BLK(BLKSRC)=BLKSRC
	  WKSTR=STRING(NLEN+1:NLEN+6)
	  READ(WKSTR,'(I6)') IMIN(BLKSRC)
	  WKSTR=STRING(NLEN+8:NLEN+13)
	  READ(WKSTR,'(I6)') JMIN(BLKSRC)
	  WKSTR=STRING(NLEN+15:NLEN+20)
	  READ(WKSTR,'(I6)') KMIN(BLKSRC)
	  WKSTR=STRING(NLEN+22:NLEN+27)
	  READ(WKSTR,'(I6)') IMAX(BLKSRC)
	  WKSTR=STRING(NLEN+29:NLEN+34)
	  READ(WKSTR,'(I6)') JMAX(BLKSRC)
	  WKSTR=STRING(NLEN+36:NLEN+41)
	  READ(WKSTR,'(I6)') KMAX(BLKSRC)
	  READ (u1,'(A88)') STRING
	END DO

	NBLOCK=I
	WRITE(u2,'(I3)') NBLOCK

	DO I=1,NBLOCK
          I2= IMAX(I)-IMIN(I)+3
	  J2= JMAX(I)-JMIN(I)+3
	  K2= KMAX(I)-KMIN(I)+3
	  WRITE (u2,'(I3)') I
	  WRITE (u2,'(3I5)') I2,J2,K2
	END DO

	READ (u1,'(A88)') STRING
	WRITE (u2,'(A8)') '# region'

	I=0
	NCON=0

DO WHILE (INDEX(STRING,'Connectivity').EQ.3
     & 		  .OR.INDEX(STRING,'domain').EQ.6)
!     &            .OR.INDEX(STRING,'domain').EQ.7)
	  READ (u1,'(A88)') STRING
	  DO WHILE (INDEX(STRING,'f').EQ.26
     &            .OR.INDEX(STRING,'f').EQ.27)
	    I=I+1
	    NCON=NCON+1
	    NLEN=BLANKLEN(STRING)
	    READ(STRING(13:NLEN-1),*) BLKSRC
	    IJKSTR1=STRING(17:22)
	    READ (STRING(29:34),*) BEG(1)
	    READ (STRING(36:41),*) BEG(2)
	    READ (STRING(43:48),*) BEG(3)
	    READ (STRING(50:55),*) END(1)
	    READ (STRING(57:62),*) END(2)
	    READ (STRING(64:69),*) END(3)

	    POS=INDEX(IJKSTR1,'i')
	    IF (IJKSTR1(POS-1:POS-1).EQ.'-') THEN
	      I1=END(POS/2)
	      I2=BEG(POS/2)
	    ELSE
	      I1=BEG(POS/2)
	      I2=END(POS/2)
	    END IF
	    POS=INDEX(IJKSTR1,'j')
	    IF (IJKSTR1(POS-1:POS-1).EQ.'-') THEN
	      J1=END(POS/2)
	      J2=BEG(POS/2)
	    ELSE
	      J1=BEG(POS/2)
	      J2=END(POS/2)
	    END IF
	    POS=INDEX(IJKSTR1,'k')
	    IF (IJKSTR1(POS-1:POS-1).EQ.'-') THEN
	      K1=END(POS/2)
	      K2=BEG(POS/2)
	    ELSE
	      K1=BEG(POS/2)
	      K2=END(POS/2)
	    END IF

	    IF ((I1-I2).EQ.0) THEN
	      PLANE=0
	      IF (I1.EQ.IMAX(BLKSRC)) THEN
		I1=I1-1
		I2=I2+1
	      END IF
	    ELSE IF ((J1-J2).EQ.0) THEN
	      PLANE=1
	      IF (J1.EQ.JMAX(BLKSRC)) THEN
		J1=J1-1
		J2=J2+1
	      END IF
	    ELSE IF ((K1-K2).EQ.0) THEN
	      PLANE=2
	      IF (K1.EQ.KMAX(BLKSRC)) THEN
		K1=K1-1
		K2=K2+1
	      END IF
	    END IF
	    I1=I1+1
	    J1=J1+1
	    K1=K1+1

	    READ (u1,'(A88)') STRING

	    NLEN=BLANKLEN(STRING)
	    READ(STRING(13:NLEN-1),*) BLKDST
	    IJKSTR2=STRING(17:22)

	    POS=INDEX(IJKSTR1,'i')
	    IF (IJKSTR2(POS:POS).EQ.'i') THEN
	       IORIENT=0
	    ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
	       IORIENT=1
	    ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
	       IORIENT=2
	    END IF
	    IF (IJKSTR1(POS-1:POS-1).EQ.IJKSTR2(POS-1:POS-1)) THEN
	      IF (PLANE.EQ.0) THEN
	        ISIGN='-1'
	      ELSE
	        ISIGN='+1'
	      END IF
	    ELSE
	      IF (PLANE.EQ.0) THEN
	        ISIGN='+1'
	      ELSE
	        ISIGN='-1'
	      END IF
	    END IF

	    POS=INDEX(IJKSTR1,'j')
	    IF (IJKSTR2(POS:POS).EQ.'i') THEN
	       JORIENT=0
	    ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
	       JORIENT=1
	    ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
	       JORIENT=2
	    END IF
	    IF (IJKSTR1(POS-1:POS-1).EQ.IJKSTR2(POS-1:POS-1)) THEN
	      IF (PLANE.EQ.1) THEN
	        JSIGN='-1'
	      ELSE
	        JSIGN='+1'
	      END IF
	    ELSE
	      IF (PLANE.EQ.1) THEN
	        JSIGN='+1'
	      ELSE
	        JSIGN='-1'
	      END IF
	    END IF

	    POS=INDEX(IJKSTR1,'k')
	    IF (IJKSTR2(POS:POS).EQ.'i') THEN
	       KORIENT=0
	    ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
	       KORIENT=1
	    ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
	       KORIENT=2
	    END IF
	    IF (IJKSTR1(POS-1:POS-1).EQ.IJKSTR2(POS-1:POS-1)) THEN
	      IF (PLANE.EQ.2) THEN
	        KSIGN='-1'
	      ELSE
	        KSIGN='+1'
	      END IF
	    ELSE
	      IF (PLANE.EQ.2) THEN
	        KSIGN='+1'
	      ELSE
	        KSIGN='-1'
	      END IF
	    END IF

	    IF (PLANE.EQ.0) THEN
	      POS=INDEX(IJKSTR1,'i')
	      IF (IJKSTR2(POS:POS).EQ.'i') THEN
		TOPLANE=0
	      ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
		TOPLANE=1
	      ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
		TOPLANE=2
	      END IF
	    ELSE IF (PLANE.EQ.1) THEN
	      POS=INDEX(IJKSTR1,'j')
	      IF (IJKSTR2(POS:POS).EQ.'i') THEN
		TOPLANE=0
	      ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
		TOPLANE=1
	      ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
		TOPLANE=2
	      END IF
	    ELSE IF (PLANE.EQ.2) THEN
	      POS=INDEX(IJKSTR1,'k')
	      IF (IJKSTR2(POS:POS).EQ.'i') THEN
		TOPLANE=0
	      ELSE IF (IJKSTR2(POS:POS).EQ.'j') THEN
		TOPLANE=1
	      ELSE IF (IJKSTR2(POS:POS).EQ.'k') THEN
		TOPLANE=2
	      END IF
	    END IF

	    IF (BLKDST.LT.10) THEN
	      FACEID(I)=BLKSRC*1000+PLANE*100+BLKDST*10+TOPLANE
	    ELSE IF (BLKDST.LT.100) THEN
	      FACEID(I)=BLKSRC*10000+PLANE*1000+BLKDST*10+TOPLANE
	    ELSE IF (BLKDST.LT.1000) THEN
	      FACEID(I)=BLKSRC*100000+PLANE*10000+BLKDST*10+TOPLANE
	    END IF

	    IF (BLKSRC.LT.10) THEN
	      TOFACEID(I)=BLKDST*1000+TOPLANE*100+BLKSRC*10+PLANE
	    ELSE IF (BLKSRC.LT.100) THEN
	      TOFACEID(I)=BLKDST*10000+TOPLANE*1000+BLKSRC*10+PLANE
	    ELSE IF (BLKSRC.LT.1000) THEN
	      TOFACEID(I)=BLKDST*100000+TOPLANE*10000+BLKSRC*10+PLANE
	    END IF

	    DO N=1,I-1
	      IF (FACEID(I).EQ.FACEID(N)) THEN
		NCON=NCON-1
		GOTO 40
	      END IF
	    END DO

	    WRITE(u2,10) '# face linkage information between block '
     &                   ,BLKSRC,' and ', BLKDST
	    WRITE(STDOUT,10)'# face linkage information between block '
     &                      ,BLKSRC,' and ', BLKDST
10	    FORMAT (A41,I4,A5,I4)
	    WRITE (u2,'(I10,I3)') FACEID(I),BLKSRC
	    WRITE (u2,'(I2)') PLANE
	    WRITE (u2,'(2I4)') I1,I2
	    WRITE (u2,'(2I4)') J1,J2
	    WRITE (u2,'(2I4)') K1,K2
	    WRITE (u2,'(I10,I3)') TOFACEID(I),BLKDST
	    WRITE (u2,'(I2,X,A2)') IORIENT,ISIGN
	    WRITE (u2,'(I2,X,A2)') JORIENT,JSIGN
	    WRITE (u2,'(I2,X,A2)') KORIENT,KSIGN

40	    READ (u1,'(A88)') STRING

  END DO
  READ (u1,'(A88)') STRING
END

        INTEGER FUNCTION TABLEN (STRING)

	CHARACTER *(*) STRING

	CHARACTER *1 TAB
	PARAMETER (TAB='	')
	INTEGER NEXT

	DO NEXT=1,LEN(STRING)
	  IF (STRING(NEXT:NEXT) .EQ. TAB) THEN
	    TABLEN=NEXT
	    RETURN
	  END IF
	END DO

	TABLEN=LEN(STRING)

	RETURN
	END



	INTEGER FUNCTION BLANKLEN (STRING)

	CHARACTER *(*) STRING

	CHARACTER *1 BLANK
	PARAMETER (BLANK=' ')
	INTEGER NEXT

	DO NEXT=6,LEN(STRING)
	  IF (STRING(NEXT:NEXT) .EQ. BLANK) THEN
	    BLANKLEN=NEXT
	    RETURN
	  END IF
	END DO

	BLANKLEN=LEN(STRING)

	RETURN
	END DO

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
*****************************************

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager