1
votes

The program is used in the context of MPI.It's a MPI implementation of fortran. I declare an array within a module.like

module var
 real,save ::arr(8)
end module

Then use a subroutine like init to initialize the array arr. In the main program unit,first call init to initialize the array arr.And then call another subroutine like algo to do some computations.At the beginning of subroutine algo,the value of arr is correct.During the process of computation,the value of arr changed weirdly on some processors though there is no code changing the value of arr while on the other processors the value is correct. I check the code and I am pretty sure no code change the value of arr during computation. By the way,numbers of variables declared within the module var are numerous.

2
I've had a few situations before where I wrote past the end of an array and changed the value of other variables. Could that be happening here? - pattivacek
actually the variable got its correct value when entering the subroutine which means the initialization is correct.And the process of the subroutine algo involves changing other variables which have no connection with arr.The value I need is within the range of the variable arr. - witrus
Post some working example and enable bounds checking and other available error checks of your example. @patrickvacek may be right. - Vladimir F
@witrus MWE stands for Minimum Working Example; you should provide a piece of code that is fully running and which reproduces your error to help the others to pin down your problem. - MBR
If your compiler can do that, tell it to compile with array bound checks. At least it should eliminate one possible reason for failure. And try to track all places in your program where your array is modified (you could put some "print" around them to see what happens at run time). Alternately, debuggers have often a way to do some task upon variable modification, you could try that. - user1220978

2 Answers

0
votes

Thanks for all of you who give suggestions.The error is due to the access of array element out of boundary.In my program there is a line of code accessing the index 0 element in array like arr(0)=... which is beyond the range of fortran array.And this code leads to the value of another variable in the module to be changed which is quite unexpected to me.arr(0)=.. leads to the change of another variable like parm defined in the module.

0
votes

Since you are using MPI, you must also broadcast the variable to all processors if the initialization is being done only on one processor