Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eror when reading list, Fortran 77

Status
Not open for further replies.

stenssok

Technical User
Jun 21, 2012
6
FR
Hello,

I'm trying to run a simulation program, written in Fortran 77 for the g77 compiler ( I use gcc version 3.4.6). I get the following error message when running the program:

invalid number: incomprehensible list input
apparent state: unit 3 named combin.fig
last format: list io
lately reading sequential formatted external IO
Aborted


The error is for the following READ statement:

Code:

Code:
READ(3,*) ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL)

and the list it is trying to read, from the file combin.fig (unit 3), looks like this:

-1, 0.625, 2, 0.625, 0, 1.625, 1, 1.625,
-1, -0.375, 0, -0.375, 1, -0.375, 2, -0.375
-1, 0.375, 2, 0.375, 0, -0.625, 1, -0.625,
-1, 1.375, 0, 1.375, 1, 1.375, 2, 1.375

Maybe I should also give you the values of the variables:

NABUR = 8 8 0 0
NL = 2

I'm not very experienced in Fortran (or programming) so please keep it simple.

My OS is 64-bit Ubuntu 11.10 Oneric, but I compile in a chroot (32-bit Ubuntu 10.04 Natty) because the program doesn't compile in a 64-bit OS. Normally I can run the program in both systems.

Thanks
Katarina
 
Did you declare XPOS and YPOS as real data?

Here is what I did

Code:
      program main
      implicit none
      integer            :: J, IL
      integer, parameter :: NABUR(4) = (/8, 8, 0, 0/)
      integer, parameter :: NL = 2
      real               :: XPOS(8,2), YPOS(8,2)

      open(unit=3, file='combin.fig')
        read(3,*) ( (XPOS(J,IL), YPOS(J,IL), J=1,NABUR(IL)), IL=1,NL )
        write(*,*) ( (XPOS(J,IL), YPOS(J,IL), J=1,NABUR(IL)), IL=1,NL )
      close(3)

      end program main

I compiled it with gfortran and it prints the following

Code:
 -1.00000000      0.62500000       2.0000000      0.62500000       0.0000000       1.6250000      1.00000000       1.6250000     -1.00000000     -0.37500000       0.0000000     -0.37500000      1.00000000     -0.37500000       2.0000000     -0.37500000     -1.00000000      0.37500000       2.0000000      0.37500000       0.0000000     -0.62500000      1.00000000     -0.62500000     -1.00000000       1.3750000       0.0000000       1.3750000      1.00000000       1.3750000       2.0000000       1.3750000

Gordon Shumway
 

This is where they are declared (I think):

Code:
      COMMON /COMFIG/ NL,NLS,NIND,NA,MODX,MODY,MODZ,APC(NLMAX),
     + NABUR(NLMAX),LATTICE,XPOS(NABURMAX,NLMAX),YPOS(NABURMAX,NLMAX),
     + DUNIT, XUNIT, YUNIT, ZPOS(NLMAX)

I never programmed in Fortran, all I've learnt is from searching for errors, so I don't really know what that means, but it's the only place I can find those variables.

Thanks
 
No sorry, I looked up what common blocks are and I found the variables:

Code:
 REAL APC,XPOS,YPOS,DUNIT,XUNIT,YUNIT,ZPOS,XATOM0,YATOM0,UZ,DUZ

So yes they are declared as real.

Katarina
 
stenssok:

From all the informations that you had given, I am able to read and print the data using f77 without any problem. I see the following options

1. Add the statement
Code:
REWIND(3)
just above the read statement and try again

2. Perhaps you can try to post the full code or more code segments

3. Wait for an old timer (may be in another few minutes) to figure out what is going on in your code and help you




Gordon Shumway
 

Yea, I think it's because everything is in different files and it uses these common blocks that seem a bit tricky. Here's the piece of code where the error occures:

Code:
C ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUBROUTINE COMBIN(NAME)
      SUBROUTINE COMBIN(NAME)
      CHARACTER*10 NAME
      CHARACTER*4 STARS
      CHARACTER*10 RNAME
C usage:  CALL COMBIN(NAME)
C READ COMMON BLOCK COMFIG FROM FILE combin.fig FOR THE CRYSTAL TYPE
C AND PROJECTION REQUESTED BY PARAMETER NAME.

      INCLUDE 'flux3com.for'

      OPEN(UNIT=3,FILE='combin.fig',STATUS='OLD')
      REWIND 3
  1   READ(3,2,END=1999) STARS,RNAME
  2   FORMAT(A4,A10)
      IF(STARS .NE. '****') GOTO 1
      IF(RNAME .NE. NAME) GOTO 1

      VERSION(6:15)=NAME
      READ(3,*) NL,NLS
	WRITE (*,*) NL,NLS
c      READ(3,*) ( (IP(J,K),J=1,3), K=1,2),
c     + NIND, MODX, MODY, MODZ,
c     + (APC(IL),IL=1,NL), (NABUR(IL),IL=1,NL), LATTICE,
c     + ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL),
c     + XUNIT, YUNIT, DUNIT,
c     + (ZPOS(IL),IL=1,NL),
c     + ((IATOM(K,IL),K=0,MODZ-1),IL=1,NL),
c     +    (XATOM0(I),YATOM0(I),I=1,NIND)

C read/write sequence for debugging:
      READ(3,*) ( (IP(J,K),J=1,3), K=1,2)
      WRITE(*,*) ( (IP(J,K),J=1,3), K=1,2)
      READ(3,*) NIND, MODX, MODY, MODZ
      WRITE(*,*)NIND, MODX, MODY, MODZ
      READ(3,*) (APC(IL),IL=1,NL) 
      WRITE(*,*)(APC(IL),IL=1,NL)
      READ(3,*) (NABUR(IL),IL=1,NL)
      WRITE(*,*)(NABUR(IL),IL=1,NL)
      READ(3,*) LATTICE
      WRITE(*,*)LATTICE
      READ(3,*) ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL)
      WRITE(*,*) ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL)
      READ(3,*) XUNIT, YUNIT, DUNIT
      WRITE(*,*) XUNIT, YUNIT, DUNIT
      READ(3,*) (ZPOS(IL),IL=1,NL)
      WRITE(*,*) (ZPOS(IL),IL=1,NL)
      READ(3,*) ((IATOM(K,IL),K=0,MODZ-1),IL=1,NL)
      WRITE(*,*) ((IATOM(K,IL),K=0,MODZ-1),IL=1,NL)
      READ(3,*) (XATOM0(I),YATOM0(I),I=1,NIND)
      WRITE(*,*) (XATOM0(I),YATOM0(I),I=1,NIND)

      CLOSE(3)

And this is where the COMMON block is:

Code:
C  NAMAX is the maximum number of lattice parameters in the crystal
C  1<=IA<=NAMAX will be the actual value during the run
      PARAMETER(NAMAX=2)
C  NABURMAX is the maximum number of neighbouring rows/atom species for the force field      
      PARAMETER(NABURMAX=16)
C  MAXIATOM+1 is the maximum number of atoms within the z-unit cell
      PARAMETER(MAXIATOM=23)
C  NANGMAX is the maximum number of angles in one simulation run
      PARAMETER(NANGMAX=10000)
      CHARACTER*28 VERSION
      CHARACTER*70 INFILE,OUTFILE,EFILE,STATFILE,YLDFILE,LOGFILE
      CHARACTER*5 C_SYMM
      COMMON /COMVRS/ VERSION
C NIND  : number of different sites where collisions occur
C MODX,MODY,MODZ : period of X,Y,Z in units XUNIT,YUNIT,DUNIT
C APC(L): atoms per (3-dimensional) unit cell of kind L.
C NABUR(L): number of surrounding atom rows to take along.
C LATTICE : a flag used in subroutine BBLOOP, to identify the lattice
C XPOS,YPOS : the coordinates of the surrounding atom rows
C XUNIT,YUNIT,DUNIT: units for X,Y,Z (in units of the lattice constant)
C ZPOS(L): spacing between atoms of kind L in the atom rows
C IATOM(J,L): if non-zero an atom of kind L is present at Z=J
C             its x,y coordinates are stored in
C XATOM(k),YATOM(k), where k=IATOM(J,L)
C
      COMMON /COMFIG/ NL,NLS,NIND,NA,MODX,MODY,MODZ,APC(NLMAX),
     + NABUR(NLMAX),LATTICE,XPOS(NABURMAX,NLMAX),YPOS(NABURMAX,NLMAX),
     + DUNIT, XUNIT, YUNIT, ZPOS(NLMAX),
     +    IATOM(0:MAXIATOM,1:NLMAX),
     + XATOM0(NPMAX), YATOM0(NPMAX), IP(3,2) , NFX, NFY, C_SYMM

      COMMON /ESPEC/TF0,TM,ZVAL(NLMAX),AVZVAL,TAPC,UCVOL,E0,ES,RENRGY,
     +    ICRATE(0:2048),LOSS
      COMMON /FILES/INFILE,OUTFILE,EFILE,STATFILE,YLDFILE,LOGFILE
      COMMON /LUNITS/LU(3),LU1,LU2
      COMMON /STATUS/NSTART,NRSTART,KREP

And finaly, where the variables XPOS and YPOS are declared (this file is in another directory):

Code:
C NLS(L) is number of atom species as read from file COMBIN.FIG
C NLA(L) is the actual number of atom species in layer L
C     (these may be different e.g. GaAs structure for Si: NLB=2 NLA=1)
C NIND  : number of different sites where collisions occur
C MODX,MODY,MODZ : period of X,Y,Z in units XUNIT,YUNIT,DUNIT
C APC(L): atoms per (3-dimensional) unit cell of kind L.
C NABUR(L): number of surrounding atom rows to take along.
C LATTICE : a flag used in subroutine BBLOOP, to identify the lattice
C XPOS,YPOS : the coordinates of the surrounding atom rows
C DUNIT,XUNIT,YUNIT: units for Z,X,Y (in units of the lattice constant)
C ZPOS(L): spacing between atoms of kind L in the atom rows
C IATOM(J,L): if non-zero an atom of kind L is present at Z=J
C             its x,y coordinates are stored in
C XATOM(k),YATOM(k), where k=IATOM(J,L)
C NLC is number of lattice constants (1 for cubic, 2 for hexagonal)
C UZ(L): z coordinates for MODZ+1 planes from z=0 to z=1
C DUZ(L): MODZ steps between consecutive  planes from z=0 to z=UD

      INTEGER NABURMAX, MAXIATOM, MAXIND,MODZMAX
      PARAMETER (NABURMAX=50,MAXIATOM=50,MAXIND=50,MODZMAX=50)

      CHARACTER*10 CONFIGID, CSYMM
      COMMON /CONFIG/ CONFIGID(NLAYER), CSYMM(NLAYER)

      INTEGER NLS, NLC,NLZ
      INTEGER NIND,MODX,MODY,MODZ,NABUR,LATTICE,IATOM,IP
      REAL APC,XPOS,YPOS,DUNIT,XUNIT,YUNIT,ZPOS,XATOM0,YATOM0,UZ,DUZ
      COMMON /COMFIG/ 
     + NLS(NLAYER),NLC(NLAYER),NLZ(NLAYER),
     + IP(3,2,NLAYER),
     + NIND(NLAYER),MODX(NLAYER),MODY(NLAYER),MODZ(NLAYER),
     + APC(NL,NLAYER),NABUR(NL,NLAYER),LATTICE(NLAYER),
     + XPOS(NABURMAX,NL,NLAYER),YPOS(NABURMAX,NL,NLAYER),
     + XUNIT(3,NLAYER), YUNIT(3,NLAYER),DUNIT(3,NLAYER),
     + ZPOS(NL,NLAYER),
     + IATOM(0:MAXIATOM,1:NL,NLAYER),
     + XATOM0(MAXIND,NLAYER), YATOM0(MAXIND,NLAYER),
     + UZ(0:MODZMAX,NLAYER),DUZ(0:MODZMAX,NLAYER)

The program is originally written in 1987, So yea, let's hope for the old timers :)

Thank you anyway
Katarina
 
stenssok:

It is still not clear where the error lies.

can you also post the full input from "combin.fig"

In your first post you said that the error lies in the following statement

Code:
READ(3,*) ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL)

Did u arrive at this conclusion b'coz only at this line your WRITE statement prints wrong values?

Did u WRITE all the data that you READ also before this line. Can u check if the code WRITEs correct data.

Why not WRITE all the data including the following and check if everything else is READ correctly.

Code:
READ(3,2,END=1999) STARS,RNAME

Code:
c READ(3,*) ( (IP(J,K),J=1,3), K=1,2), c + NIND, MODX, MODY, MODZ, c + (APC(IL),IL=1,NL), (NABUR(IL),IL=1,NL), LATTICE, c + ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL), c + XUNIT, YUNIT, DUNIT, c + (ZPOS(IL),IL=1,NL), c + ((IATOM(K,IL),K=0,MODZ-1),IL=1,NL), c + (XATOM0(I),YATOM0(I),I=1,NIND)



Gordon Shumway
 

I've written out the 6 lines before this one and they're all correct (that's how I found in what statement the error occured).

Actually I think I might have found the problem. The XPOS, YPOS variables are not declared in the same way in the 2 different files:

Code:
      COMMON /COMFIG/ NL,NLS,NIND,NA,MODX,MODY,MODZ,APC(NLMAX),
     + NABUR(NLMAX),LATTICE,XPOS(NABURMAX,NLMAX),YPOS(NABURMAX,NLMAX),

versus

Code:
      COMMON /COMFIG/ 
     + NLS(NLAYER),NLC(NLAYER),NLZ(NLAYER),
     + IP(3,2,NLAYER),
     + NIND(NLAYER),MODX(NLAYER),MODY(NLAYER),MODZ(NLAYER),
     + APC(NL,NLAYER),NABUR(NL,NLAYER),LATTICE(NLAYER),
     + XPOS(NABURMAX,NL,NLAYER),YPOS(NABURMAX,NL,NLAYER),

Probably because I'm using an older version of one of the programs in the package (it's the only version that gives the output format I need), and the common block is changed in the newer version.

Thanks for your help.
 
You are right, I missed it. This is most likely the source of error.

Gordon Shumway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top