Initializing variables and arrays in Fortran 77

2 replies · 4K views · last reply
Moly
Messages
20
Reaction score
0
Hi All

I am new to fortran and there are things that I believe fortran should do and don't know how to do it - I am using fortran 77.

1- I know how to declare variables, but i do not know how to make sure that i start out with zeros and not use old data that might have been stored by a previous program run or randomly assigned by the memory. (the equivalent of clear all in matlab)

2- If i declare a 3 by 3 matrix called A, and I want to assign the value 4 for each of the elements of the matrix, what is the simplest way of doing that? Setting A=4 did not work for me. I can put it in a loop but i feel there has to be an easier way if i am doing something as simple as this. [in MATLAB i would simply say A(:,:)=4]

Thanks for your help in advance.
 
Unfortunately, there are no shortcuts. Set every variable to zero, use loops to initialize array.
 
Thanks for the prompt reply Borek. I am glad I asked instead of banging my head against the screen until next week. Thanks again.