- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried turning on Fortran runtime error checking (and traceback information)?
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page