+ Responder tema
Resultados 1 al 2 de 2

Tema: Error compilando con gfortran

  1. #1
    Senior Member Ontureño es un faro de luz gloriosa Ontureño es un faro de luz gloriosa Ontureño es un faro de luz gloriosa Ontureño es un faro de luz gloriosa Ontureño es un faro de luz gloriosa Avatar de Ontureño
    Fecha de ingreso
    03 ago, 05
    Ubicación
    Murcia
    Mensajes
    3,713
    Agradecimientos

    Error compilando con gfortran

    Buenas, a ver si me podéis echar una mano. Quiero hacer un bucle que vaya leyendo filas de un archivo, y que termine cuando se acabe el archivo.

    Yo siempre hago eso con esta estructura que funciona bien:

    Código:
    i=0
    do while(.NOT.EOF(10))
      i=i+1
      read(10)variable(i)
    enddo
    donde 10 es la unidad del archivo. Pues bien, esta estructura se compila perfectamente con Intel Fortran Compiler, pero no con gfortran. Me sale este error:


    $ gfortran -FR -o kk.x kk.f90
    kk.f90:23.20:

    do while(.NOT.EOF(10))
    1
    Error: Function 'eof' at (1) has no IMPLICIT type
    Imagino que gfortran no reconoce EOF.

    La pregunta básicamente es: ¿conocéis otra manera de recorrer el bucle leyendo del arhivo hasta que éste se acabe?

    PD: no me vale que digáis que le pase el número de líneas como parámetro al programa, que eso ya lo sé hacer yo .
    «Dios no juega a los dados, usa /dev/random»

    Mi chuletario on line

  2. #2
    Senior Member oph será famoso muy pronto oph será famoso muy pronto
    Fecha de ingreso
    07 jul, 06
    Mensajes
    664
    Agradecimientos

    Re: Error compilando con gfortran

    Cita Iniciado por Ontureño
    Buenas, a ver si me podéis echar una mano. Quiero hacer un bucle que vaya leyendo filas de un archivo, y que termine cuando se acabe el archivo.

    Yo siempre hago eso con esta estructura que funciona bien:

    Código:
    i=0
    do while(.NOT.EOF(10))
      i=i+1
      read(10)variable(i)
    enddo
    donde 10 es la unidad del archivo. Pues bien, esta estructura se compila perfectamente con Intel Fortran Compiler, pero no con gfortran. Me sale este error:


    $ gfortran -FR -o kk.x kk.f90
    kk.f90:23.20:

    do while(.NOT.EOF(10))
    1
    Error: Function 'eof' at (1) has no IMPLICIT type
    Imagino que gfortran no reconoce EOF.

    La pregunta básicamente es: ¿conocéis otra manera de recorrer el bucle leyendo del arhivo hasta que éste se acabe?

    PD: no me vale que digáis que le pase el número de líneas como parámetro al programa, que eso ya lo sé hacer yo .
    No uso el gfortran, pero el g95 dice esto:

    do while(.NOT.EOF(10))
    1
    Error: Operand of .NOT. operator at (1) is REAL(4)

    No reconoce EOF(10) como fin de archivo (que sería una variable lógica), sino como una variable real.

    Encontré esto en un foro de Fortran:

    Tom Paris....

    Hi,
    I am using Digital Visual Fortran 5.0 on Windows NT.
    I am trying to read text format data files. The problem is
    that if the last line of the file ends with spaces, the
    EOF function will not return .true. and I end up with
    "end-of-file during read" error. I tried the following
    sample program directly from the help documents:

    REAL x, total
    INTEGER count
    OPEN (1, FILE = 'TEST.DAT')
    DO I = 1, 20
    CALL RANDOM(x)
    WRITE (1, *) x * 100.0
    END DO
    CLOSE(1)
    total = 0
    count = 0
    OPEN (1, FILE = 'TEST.DAT')
    DO WHILE (.NOT. EOF(1))
    count = count + 1
    READ (1, *) value
    total = total + value
    END DO
    IF ( count .GT. 0) THEN
    WRITE (*,*) 'Average is: ', total / count
    ELSE
    WRITE (*,*) 'Input file is empty '
    END IF
    END

    It didn't work and it gave me the exact same "end-of-file
    during read" error. Any help please?






    Richard Maine....


    tom.pa...@voyager.ssh (Tom Paris) writes:
    > I am using Digital Visual Fortran 5.0 on Windows NT.
    > I am trying to read text format data files. The problem is
    > that if the last line of the file ends with spaces, the
    > EOF function will not return .true. and I end up with
    > "end-of-file during read" error....
    > It didn't work and it gave me the exact same "end-of-file
    > during read" error. Any help please?

    I'd suggest not using the EOF function. Its a nonstandard extension
    anyway. I'd not actually recalled thet DVF supports it (though I
    believe you if you say that it does). I recall the EOF function as a
    non-standard extension used on some systems in the Fortran 66 days.
    It basically became obsolete with the advent of f77, which provided a
    standard and portable way to handle the same issues. Use the standard
    Fortran facilities (EOF= or IOSTAT= in the READ statement) instead.

    --
    Richard Maine
    ma...@altair.dfrc.nasa.gov

+ Responder tema

Temas similares

  1. Error en TikZ
    Por lartkma en el foro LaTeX
    Respuestas: 8
    Último mensaje: 04/10/2011, 18:43
  2. Respuestas: 1
    Último mensaje: 24/08/2011, 04:15
  3. Respuestas: 6
    Último mensaje: 28/06/2010, 17:58
  4. Diferencias compilando en win y en linux
    Por JWolf en el foro LaTeX
    Respuestas: 4
    Último mensaje: 18/04/2010, 21:01
  5. Error absoluto y error relativo (3º ESO)
    Por Mig21 en el foro Física clásica
    Respuestas: 2
    Último mensaje: 22/09/2009, 12:39

Etiquetas para este tema

Permisos de publicación

  • No puedes crear nuevos temas
  • No puedes responder temas
  • No puedes subir archivos adjuntos
  • No puedes editar tus mensajes