Link to home
Start Free TrialLog in
Avatar of daveask
daveask

asked on

Forget Fortran

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
Avatar of Mike McCracken
Mike McCracken

>>!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
Avatar of daveask

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad i could help

mlmcc