1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Beginner fortran question - starting with a new slate

  1. Sep 26, 2008 #1
    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.
     
  2. jcsd
  3. Sep 26, 2008 #2

    Borek

    User Avatar

    Staff: Mentor

    Unfortunately, there are no shortcuts. Set every variable to zero, use loops to initialize array.
     
  4. Sep 26, 2008 #3
    Thanks for the prompt reply Borek. I am glad I asked instead of banging my head against the screen until next week. Thanks again.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Beginner fortran question - starting with a new slate
  1. Beginner Fortran Help (Replies: 4)

Loading...