Beginner fortran question - starting with a new slate

  • Fortran
  • Thread starter Moly
  • Start date
  • #1
21
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.
 

Answers and Replies

  • #2
Borek
Mentor
28,816
3,319
Unfortunately, there are no shortcuts. Set every variable to zero, use loops to initialize array.
 
  • #3
21
0
Thanks for the prompt reply Borek. I am glad I asked instead of banging my head against the screen until next week. Thanks again.
 

Related Threads on Beginner fortran question - starting with a new slate

  • Last Post
Replies
1
Views
889
  • Last Post
Replies
4
Views
2K
Replies
3
Views
2K
Replies
7
Views
2K
  • Last Post
2
Replies
37
Views
1K
Replies
2
Views
2K
Replies
1
Views
2K
  • Last Post
Replies
4
Views
3K
Replies
2
Views
1K
  • Last Post
Replies
1
Views
2K
Top