Array bounds exceeded using higher compilers

Array bounds exceeded using higher compilers

I am working on a model which name is DAYCENT. I will make some modifications for this model (I need to change some source codes). The source codes of this model were written in mixed languages of Microsoft Fortran PowerStation v4.0 and Visual C++4.0. All files can pass compile and link, and can build the executable file under the above two compilers. The executable file can run smoothly, without any errors. However, this model was developed in another university. I received all source code files, but I don't have the above version of compilers. I use Compaq Visual Fortran v6.0 and Microsoft Visual C++ 6.0. When I used these two higher version of compilers , I could pass the compile, link and build the executable file without errors. But when I ran the executable file which was built under the higher version of compilers, I met the array bounds exceeded eorrors like this:

forrtl: severe (161): Program Exception - array bounds exceeded

I assume this problem was caused by using higher compilers. It's very hard to fix the array bounds exceeded errors. Do you have any ideas to fixed this problem? Could this problem be fixed by change the project setting?

Your help would be highly appreciated.

17 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

MS Fortran didn't do array bounds checking by default - CVF does when you build as a Debug configuration. You can turn this off in Project..Settings..Fortran..Run-Time - uncheck the "Array and strings bounds" box.

Note that a Release configuration does not enable this option.

I hope that you are certain that your program is providing correct results.

Steve

Steve - Intel Developer Support

Hi Steve,

Thanks for your reply. Yes, I did turn off in Project..Settings..Fortran..Run-Time - uncheck the "Array and strings bounds" box. After I turned off this option, The program passed the link and got the excutable file. But when I ran this excutable file,
the error of (161) appreaed: Program Exception - array bounds exceeded. Could this problem be fixed by change the project setting? It's hard to fix it in the source codes.

I am quite sure this program is providing correct results because it has been widely tested and used.

Yong

That can't be. Either
- You ran the wrong executable, or
- You set the option for a wrong configuration. VS Project settings dialog is tricky -- make sure that "all configurations" is selected in the top left combo.

If I recall correctly, changing that option would cause VS to offer to rebuild all sources, not just to relink. Did it happen?

Jugoslav

Jugoslav
www.xeffort.com

Hi Jugoslav,

Your analysis sounds reseanable. But what did you mean:
make sure that "all configurations" is selected in the top left combo? How to do that?

Thank you.

Yong

When you create a fresh project, you normally get two configurations: "Debug", with debug info, no optimization, and array bounds checking on, and "Release", with no debug info, optimized, and bounds checking off. You set the active configuration (the one you're building) from Build/Set Active Configuration menu, or from "Build" toolbar (View/Toolbars/Build). Corresponding .exes end up in .Debug and .Release folders.

In Project Settings dialog, there's "Settings For" combo above the tree view on the left side, where you select for which configuration you change options. It normally contains "Win32 Debug", "Win32 Release", and "All configurations" items.

So, a part of the solution is to just build Release configuration. If you need to debug it as well, you have to switch off bounds checking for Debug configuration, i.e. when you switch off the checkbox make sure that either "Debug" or "All configurations" is selected. Normally, after you close the dialog, you will be asked to rebuild necessary sources so that the change takes effect.

Jugoslav

Jugoslav
www.xeffort.com

Hi Steve,

Thanks for your reply. I did turn off in Project..Settings..Fortran..Run-Time - . After I unchecked the "Array and strings bounds" box option, The program passed the link and got the excutable file. When I ran this excutable file, no error message was displayed this time, but the running stopped at the same location with the executable file checked the "Array and strings bounds" box.

I am quite sure this program is providing correct results because it has been widely tested and used. I used the same data and parameter data, and used the excutable file that formed from the earlier version compilers, it ran well and I received the correct results.

This means it will not fix my problem if I change the "Array and strings bounds" option. Are there any other solutions for this problem?

Yong

If you unchecked the box and rebuilt the application, you will never get the array bounds error.

First, look at the Project Options box under Project..Settings..Fortran. Do you see /check:bounds listed? If so, you haven't turned off the option. Once it is turned off, do Build..Rebuild All. Then make sure you are running the executable you just built and not a copy somewhere else.

Steve

Steve - Intel Developer Support

Hi Steve,

Yes, there was no array bounds error when the excutable file ran. But it stopped running without completing the program. The stopped location is right the location that when I ran the executable file from checked "array bounds check" option.

I ran the same data set with the executable file that was formed from earlier version of compilers. It completed the running successfully.

I contacted the original programmer, and I was told that all the source code files are exact same as that she used under the earlier compilers.

Are there any other solutions for this problem?

Thanks a lot!

Yong

You say it "stopped running". What happened at that point? Did you get an error message? If so, what was it? If not, then your program exited normally and you'll need to figure out why, if that's not what you want.

Steve

Steve - Intel Developer Support

Yes, it "stopped running". No error message was displayed on the screen. The executable file just quit without completing the execution.

When the same source code files are used to build the executable file, and I ran the executable file with the same data set. The execution is successful. Why? Where is the problem from? I guess one of the possibilities is that compatibility between the compilers. When using the Microsoft Visual Fortran PowerStation 4.0 and Visual C++ 4.0, it works well. When using the Compaq Visual Fortran 6.6 and Microsoft Visual C++ 6.0, I have the above problem.

How do you think?

Yong

I support an in-house application that doesn't work unless array bounds checking is turned off. It does some special memory management this way. In general, though, I would never write a program in any language that deliberately exceeded array boundaries. It's a recipe for disaster.

Such programs can be specific to certain compilers or CPUs. If you can identify why your program is doing this, then I highly recommend that you fix it.

Mike

In the original Fortran (I go back to IBM Fortran II 1962), all arrays had to be explicity dimension eg a(2). In order to write routines that had variable dimensions, it was common practice to dimension the array to be of length 1 and to pass the actual length as another argument. So of course the array dimension was almost always exceeded.

By the time the Fortran 77 standard was written, the practice Bill mentions had become common, so the notation (*) was introduced to provide a portable alternative. For a time, a few compilers assumed by default that was what was meant by (1). Others always required an option equivalent to CVF /nocheck to accept the obsolete usage.

Intel compilers through 7.1 have a specific option (-WB)to permit the pre-77 usage. This may not continue. It's time to use an alternative which fits the standard.

If there is no error message, your program is choosing to exit at that point. Please create a ZIP archive of the project and data and send it along with an explanatory message to vf-support@compaq.com - we'll look at it.

Steve

Steve - Intel Developer Support

Hello Steve,

I already sent you my project codes and input data. Please let me know if you will received it and will fix the problem for me. Thank you.

Yong

I sent you more details from vf-support, but the basic problem was that you had a mismatch in calling conventions between the Fortran and C routines, which led to stack corruption. The array bounds error was a side-effect of this.

Steve

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today