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!

problem with read instruction

Status
Not open for further replies.

arminius85

Programmer
Dec 20, 2009
3
IT
Hi all
I have a problem with a simple read instruction, for the sake of
clarity I write a dummy program ion which the problem persist. I
don't know if there are some limitation about the read instruction.

The program is as the follow:
Code:
 program usrfun
        USE lettura_risultati_da_f06
        INTEGER*8 :: CALLS, INTERO
        DOUBLE PRECISION :: MASSA,                      &
                                                MAX_ROD_STR,    &
                                                MIN_ROD_STR,    &
                                                MAX_CQUAD_STR,  &
                                                ANGLEA,         &
                                                ELEV,           &
                                                MAX_DISP,       &
                                                MAX_DAMPING,    &
                                                ACC_MFT,        &
                                                Freq_MAX_calcolata
        DOUBLE PRECISION, DIMENSION(3)::F
        CHARACTER(18) :: NOME_FILE
        CHARACTER*100 :: COMMAND
 DO
        CALLS=CALLS+1
        write(*,*) '---------------------------------'
        write(*,*) '  ITERAZIONE NUMERO', calls
        write(*,*) '---------------------------------'
        NOME_FILE='template_112.f06'
        CALL sol_112_stress(NOME_FILE)
 END DO
 stop
 end program usrfun
-----------------------------------------------------------------------------------------------
in another file
Code:
 MODULE lettura_risultati_da_f06
 CONTAINS
 SUBROUTINE sol_112_stress(NOME_FILE)
 IMPLICIT NONE
        CHARACTER*18, INTENT(IN)          :: NOME_FILE
        INTEGER::               &
                UNIT_FILE,      & 
                ISTATUS
        CHARACTER*132 ::        stringa,        &
                                RIGA,           &
                                NOME_VINCOLO
        CHARACTER*18  ::        VAR1
        INTEGER :: ID, ID_MAX_STR, ID_MIN_STR, ID_MAX_CQUAD_STR, INTERO, CALLS_FLAG
        DOUBLE PRECISION :: TIME1, AX_STR1, TOR_STR1, TIME2, AX_STR2, TOR_STR2, &
                            FIB_DIS, NX, NY, TXY, ANGLE, MAJ, MIN, VONM,        &
                            TIME_MAX_STR, TIME_MIN_STR, TIME_MAX_CQUAD
        UNIT_FILE=112
    OPEN(UNIT=UNIT_FILE, FILE=NOME_FILE, IOSTAT=ISTATUS, STATUS='OLD', ACTION='READ', ERR=800)
        REWIND(UNIT_FILE)
        DO
          READ(UNIT_FILE,"(A132)",IOSTAT=ISTATUS) RIGA
          IF (ISTATUS<0) EXIT
        END DO
        CLOSE(UNIT_FILE)
        RETURN
 !       ERROR
        800 WRITE(*,*) 'ERROR OPEN FILE ',NOME_FILE
        STOP
        900 WRITE(*,*) 'Error in READ line 191, ISTATUS =',ISTATUS
        STOP
 END SUBROUTINE sol_112_stress
after 12936 iteration it stopped without any message as those labeled
in "800" or "900" but "Press
any key to continue", as you can see in attachment.

The file named as "template_112.f06", with a dimension of 2.988.214
byte, contains 332024 lines of the word "PROVA x", where x is a
number.

Any help is greatly appreciated

Immagine.jpg
 
How are you getting the output? Are you leaving it to scroll on the screen or are you piping it into a file?

If you are piping it into a file, how big is the file when the program stops?

Also, is this on *nix or on Windows?
 
The output is getting from scrolling the DOS command prompt. The OS is Windows Xp, and compiler is a compaq visual fortran 6.6.
 
Does it stop in as many iterations if you pipe it to a file?
 
Code:
...
IF (ISTATUS<0) EXIT
...
It's a "loop forever" on most of error conditions.
The IOSTAT referenced variable is NON-ZERO (negative OR positive) on error...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top