- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Friends:
I am about to complete a large mixed language project (C++,Fortran legacy code; I asked silly and not so silly questions before) with lots of bad/risky ingredients like lots of COMMON statement shared by C++. I am now testing the resulting program. It is running bit I have a very strange problem.
In one of the legacy FORTRAN Subroutines I have a local 4x4 matrix. The variable name is SSXY(4,4). I initially included a debug WRITE statement to watch its content. It seemed like all was working. When I deleted the debug statement, the program gives very strange results. When I include a very simple WRITE statement like:
WRITE(7,7015) SSXY(1,1) 7015 FORMAT(' ROD: SSXY(1,1) = ',E15.7)
Anywhere. It runs OK. If I put an IF block around it does go back to faulty mode.
I am now going through all the commons shared with C++ code to make sure there is no misalignment. Strange thing is the code is very stable. It never crashes either way.
I am posting this message to ask your wisdom on possible reasons and how I should go about chasing it.
Regards;
I. Konuk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problems that appear when you remove (or add) seemingly unrelated statements are usually due to memory corruption issues, such as mismatched arguments or writing past the end of an array. There are many other possibilities. Often the cause of the error is far removed from where it appears.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problems that appear when you remove (or add) seemingly unrelated statements are usually due to memory corruption issues, such as mismatched arguments or writing past the end of an array. There are many other possibilities. Often the cause of the error is far removed from where it appears.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Ret.) (Blackbelt) wrote:Problems that appear when you remove (or add) seemingly unrelated statements are usually due to memory corruption issues, such as mismatched arguments or writing past the end of an array. There are many other possibilities. Often the cause of the error is far removed from where it appears.
Steve:
Thank you very much again. Your advice was indeed very helpful. I am going through all CALLs. I already found one mistyping(!). The subroutine CALL is expecting a matrix. Misspelling means a scalar being passed. Just like you described.
Thank you.
Merry Christmas and happy holidays to all.
I. Konuk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler has a feature, on by default in a Debug Visual Studio configuration, that helps with this. From the command line it is /warn:interfaces and in Visual Studio, Fortran > Diagnostics > Check routine interfaces.
You should also get in the habit of adding IMPLICIT NONE in every program unit - this will help you find misspelled variable names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
I will do the first one right away. I have plans to do the IMPLICIT in the future as it would be too much work right now to make legacy code type safe. My goal is first to finish the full size prototype. I will try it in the future or I may just code some units (slowly) in C++.
By the way, it seems like the one and only error which I reported earlier was the culprit. Thank you again for all your valuable suggestions.
Happy holidays.
I. Konuk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was wrong! The compiler found a second one. I learned and benefited from this Forum, especially you so much. I owe much gratitude. THANK YOU!
I. Konuk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
I am running vs community edition 2017 with IVF 19 update 5. I do not have a Fortran menu off of the main menu and under project properties I do not have a diagnostics menu. I am interested in turning on the interface checking.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
My only option is compile time diagnostics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That property page is long - did you scroll it? The screen shot I showed has it scrolled to the end.
Show a screen shot of what you are seeing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I get the options when I set diagnostics to custom. So I am good now.
Thanks.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page