I am a student doing a research project at NIST, and as part of my project I have to run a series of simulations. My problem is this: I inherited the C code for the simulations from a previous student researcher who wrote it using Microsoft Visual C++ on a Linux operating system, and I am using Borland C++ BuilderX on an XP operating system. The code compiled and ran (after some minor changes, none of which are related to my current problem), but one variable (the one monitered to determine when to stop iterating through the simulation) is jumping all over the place, instead of the expected steady decrease. The program makes use of some very large arrays (some of which contain 27 million elements) and outputs two 80M text files, in case that might be a factor. Can you give me any tips about what the problem might be? (unfortunately, I am probably not allowed to post the code-government property and all that.)

Again, I made very few changes to the code (just some status output statements and a fix to the file reading)

wrote it using Microsoft Visual C++ on a Linux operating system,

Is this actually possible? MSVC runs on Linux? :eek:

but one variable (the one monitered to determine when to stop iterating through the simulation) is jumping all over the place, instead of the expected steady decrease.The program makes use of some very large arrays (some of which contain 27 million elements)

27 million = 27000000
What is the data type used for this variable? Maybe it can't hold 27000000. Most probably it starts back from 0 after being assigned it's maximum possible value.

Is this actually possible? MSVC runs on Linux? :eek:


27 million = 27000000
What is the data type used for this variable? Maybe it can't hold 27000000. Most probably it starts back from 0 after being assigned it's maximum possible value.

I gather that my predecessor
1. Was really good with computers and
2. Used a pirated version of Visual C++.

As for the second part, I should have been more specific. It's several 1,000,000-element arrays of pointers to 27 element arrays.

I gather that my predecessor
1. Was really good with computers and
2. Used a pirated version of Visual C++.

Oh, well. First time I have heard something like this.

As for the second part, I should have been more specific. It's several 1,000,000-element arrays of pointers to 27 element arrays.

Try using the debugger and see whether this variable jumping is random or not. Maybe you can find a pattern, and then you should be able to figure out the cause. Also check the maximum value that can be stored for this variable type. If it is less than 1,000,000 then that is the problem. A 32 bit integer should be able to hold 1,000,000 but make sure for your environment.

Oh, well. First time I have heard something like this.

Try using the debugger and see whether this variable jumping is random or not. Maybe you can find a pattern, and then you should be able to figure out the cause. Also check the maximum value that can be stored for this variable type. If it is less than 1,000,000 then that is the problem. A 32 bit integer should be able to hold 1,000,000 but make sure for your environment.

If there is a pattern, then I wouldn't be able to determine what it was--the sequence is always the same, but the variable is influenced by some very complex sequences of multiplications with some 4D and 5D arrays in addition to the aforementioned million-element pointer arrays. The variable is a double, so I doubt that it is going out of bounds(the variable is supposed to start around 1*10^10, and is monitored to end the simulation loop when it drops below 1*10^-20). However, none of the values I have seen thus far in the sequence have been negative.

I would also like to mention that the code runs just fine on the NIST Linux-using computers, as well as (of course) the computer used to write the code (which, I gather, was written quite a while ago), but not on the gaming laptop I bought last summer.

This article has been dead for over six months. Start a new discussion instead.