Beginner fortran question - starting with a new slate

  • Context: Fortran 
  • Thread starter Thread starter Moly
  • Start date Start date
  • Tags Tags
    Beginner Fortran
Click For Summary
SUMMARY

The discussion centers on the challenges faced by a beginner using Fortran 77, specifically regarding variable initialization and matrix assignment. The user seeks methods to ensure variables start at zero and to efficiently assign values to a 3x3 matrix. It is established that Fortran 77 does not provide built-in functions for these tasks, requiring manual initialization of variables and the use of loops for matrix assignments. The community emphasizes the necessity of these approaches in Fortran programming.

PREREQUISITES
  • Understanding of Fortran 77 syntax and structure
  • Familiarity with variable declaration and initialization concepts
  • Basic knowledge of array manipulation in programming
  • Experience with programming loops for repetitive tasks
NEXT STEPS
  • Research Fortran 77 variable initialization techniques
  • Learn about array handling and manipulation in Fortran 77
  • Explore the use of loops for matrix operations in Fortran
  • Investigate best practices for transitioning from MATLAB to Fortran
USEFUL FOR

Beginner Fortran programmers, educators teaching Fortran 77, and developers transitioning from MATLAB to Fortran.

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.
 
Technology news on Phys.org
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K