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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused - Application runs sometimes but sometimes does not!!

Status
Not open for further replies.

snkp

Programmer
Sep 6, 2013
2
US
Hello dear FORTRAN users,
I am having a strange problem with my FORTRAN application. Here are some details about my application:
- Uses ALLOCATABLE Data structures to hold information
- Interfaces with a C++ dll which returns an array pointer. Interface uses the iso_c_binding standard. I convert the C++ array pointer to FORTRAN pointer using the intrinsic method c_f_pointer
- Reads from an XML file and writes outputs to an XML file, and two text files.

The application builds without any problem. I am using gfortran compiler with "Simply FORTRAN" IDE. After I built it, I tried it in debug mode within the IDE and it runs. So today morning I just thought I will double click the application EXE and see that such a launch will work. In doing so, I found out that the application is not responding. I had to go to Task manager and kill the program. I tried multiple times and everytime that happened. So just randomly, I deleted the output files created by the application and gmon.out and again double clicked the EXE. Voila, the program runs again.
It might run a few times and randomly it will freeze. Then I repeat the above process and sometimes it brings the application back to life and other times not. I am really lost what is the problem here. Is it a process of bad memory management? Is it something to do with how the C++ pointer and FORTRAN pointer is handled?
I thought it could be a problem with the debug version, so I changed the project to options to no include Debug variables. The problem however exists.
Any ideas/help/suggestion is much appreciated.

Regards
Sankar
 
I deleted the output files created by the application and ..... the program runs again.
Look how you open the output files. If you open them with status="new", try to change it in status="unknown"

I am really lost what is the problem here. Is it a process of bad memory management? Is it something to do with how the C++ pointer and FORTRAN pointer is handled?
Everything is possible. To find the problem, you need to debug the program.
 
Instead of double clicking, open up a cmd prompt and run the program. What happens?

Do you have a cmd /k on the default cmd prompt? If so, what does it do?

Are the paths set up correctly?

Does the program load up any data files? Is it possible to print in a fixed file what data files it thinks it is loading (full pathname).
 
Yes, it could all those things...bad memory management, bad attempt to open file, etc.

Since you mention that you are interfacing Fortran and C++, one piece of information that I have read is to NOT to write out from both languages, just from one of them...file management is different.

And, yes, it's time to do some debugging...at the worst, with stubborn bugs, I some times re-start the program with chunks of code at a time until the bug appears again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top