Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Strange error with open sentence

Zorrilla__David
Beginner
1,332 Views

Hi, I'm using Visual Studio 2019 and fortran 2020 (and also fortran 2019) .

I have programming a subroutine to read ini files. I call this sub many times from the main program, but in one moment doesn't work. There no reason to crack because I call in the same way that in time before. The error is  in an open sentence at first of the subroutine:

MODULE INI
	IMPLICIT NONE
        CONTAINS

        FUNCTION LEERVALOR(FICHERO,SECCION,CLAVE)
		CHARACTER(LEN=:),ALLOCATABLE::LEERVALOR	
		CHARACTER(LEN=*),INTENT(IN)::FICHERO,SECCION,CLAVE
		CHARACTER(200):: LINEA,LINEA1,LINEAAUX,SECCIONAUX,CLAVEAUX
		INTEGER(4)::I=0,POS=0
   
		OPEN(10,FILE=FICHERO,STATUS='OLD')

		DO WHILE (.NOT. EOF(10))
                       ...
                          LEERVALOR=TRIM(LINEAAUX)
                       ...
                ENDDO
		CLOSE(10)
           ...

And I call this function:

USE INI
CHARACTER(:),ALLOCATABLE:: CADENA,CADENA1
...
CADENA=LEERVALOR("idioma.lng",IDIOMA,"1224")
...

where:

idioma.lng is a *.ini file, IDIOMA is a string, and "1224" is another string. The file exists and works correctly because, as I say before, I use many times in this program and in the same subroutine and works correctly.

The error is in the OPEN sentence: "ATO-UHF.exe ha desencadenado un punto de interrupción" -> "ATO-UHF.exe has make a breakpoint" (or something similar)

How can I check what is the real error and why crash?

Thanks in advanced and sorry for my english

 

0 Kudos
7 Replies
jimdempseyatthecove
Honored Contributor III
1,332 Views

>>ATO-UHF.exe has make a breakpoint

This error (and similar code breaking errors) are symptomatic of code corruption. In this case where the corruption appears to be a break point set where none is set. What makes this difficult to locate the error, is the error in coding occurs in code that is separate from where the symptoms appear.

I suggest you compile with full compile time diagnostics, fix any errors and warnings, then compile with full runtime diagnostics and then try to reproduce the error.

Jim Dempsey

0 Kudos
andrew_4619
Honored Contributor III
1,332 Views

On the open line Add iostat = istat  and/or IOMSG = GBUF to get the error number or error message  you can then do something like if ( istat /= 0 ) write(*,*) gbuf

Unexpected errors can be down to timing . If you are opening and closing files in windows there is sometime a delay and the file is locked, the answer to that is to have a short wait in the code and then retry the open command.

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,332 Views

When you see, in a Visual Studio debugging session, that the program triggered a breakpoint, look in the console window (which may be "behind" the debugger window) for the real message. You'll get this for things such as an array bounds error or reference to an uninitialized variable. Or, as is likely in this case, an error from the OPEN such as "file not found".

0 Kudos
Zorrilla__David
Beginner
1,332 Views

To jimdempseyatthecove (Blackbelt):

I have tried to recompile, clean solution and compile again, etc... and the problem persists.

To andrew_4619:

I'm trying to use IOMSG = GBUF but I get the error in the OPEN statement, so I cannot see what is the error. 

In the debugger mode, I pause the software in the OPEN statement and wait to run again the software and when I push F10 then crash. So I don't think that the problem is because the file is locked....

To Steve Lionel:

In the debugger window, I have no message (all black).

 

Pd: I send you the full code to see exactly what is the problem (it is not too big).

Thanks a lot

 

 

0 Kudos
andrew_4619
Honored Contributor III
1,332 Views

I opened your solution and built the exe (in debug)

On running I entered "p" I think because it then opens p.dat which you supplied.

I ran through and it gave an error around where you said. I then added a diagnostic line to get the open status and set a break point.

when I run now I get stack corruption errors. I think that is your problem, the error you see is a random consequence of an unrelated problem.

 

0 Kudos
Zorrilla__David
Beginner
1,332 Views

How can I see the stack errors to solve them? (How can I add a diagnostic line?)

or How can I solve these problems?

Thanks 

0 Kudos
gib
New Contributor II
1,332 Views

Have you tried turning on Fortran runtime error checking (and traceback information)?  

0 Kudos
Reply