[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Forget Fortran

Posted on 2004-11-12
4
Medium Priority
?
2,043 Views
Last Modified: 2013-11-08
Hi Experts,

I knew Fortran long time ago but forget it now. Can you correct following simple program for me?

PROGRAM Hello
  integer n=2
  double precision a(n,n)
  a = (/1.0,2.0,3.0,4.0/)       !Can we use two rows and two columns for input data to the array a ?
  CALL Test(a,n)
  print*,a(1,1)
END PROGRAM Hello  
 
SUBROUTINE Test(a,n)
double precision a(n,n)         !Can we detect the arrary size n instead pass it?
a(1,1)=a(1,1)+9.0
END SUBROUTINE Test
0
Comment
Question by:daveask
  • 3
4 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12568312
>>!Can we detect the arrary size n instead pass it?
In the FORTRANs I am familiar with NO.

>> !Can we use two rows and two columns for input data to the array a ?
Yes but it has to be in the declaration
double precision a(n,n) /1.0,2.0,3.0,4.0/

mlmcc
0
 

Author Comment

by:daveask
ID: 12568706
Thank you.

However, my code not works ! There was an error message:
error 773 - Variable N follows another operand (possible unexpected space?)
at the line
integer n=2

As for the assigning data to the array, what I hope is something like
a = 1.2, 1.3
      1.4, 1.5
or at least like this
a = 1.2, 1.3;  1.4, 1.5
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 450 total points
ID: 12571818
Try it like this

integer n
data n /2/
double precision a(n,n)
data a /1.0, 2.0, 3.0, 4.0/

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12638747
Glad i could help

mlmcc
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Introduction to Processes
Loops Section Overview
Suggested Courses
Course of the Month19 days, 3 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question