-----Original Message-----
From: Jaehoon Seol [mailto:[log in to unmask]]
Sent: Wednesday, February 02, 2000 10:52 AM
To: [log in to unmask]
Subject: calling fortran 77 from fortran 90
1. Can anyone tell me why the ouput of the array content a in testGSolver
is different from that of the array content a in dgeco.
See below: at and a are not the same array
2. I also appreciate if you can tell me what difference there is between
double precision a(lda,1)
and
double precision a(lda,n)
Sequence Association:
---------------------
Fortran allows sequence association where storage sequence properties
(assume linear memory model) are used to identify the values of the dummy
argument.
Without assumed shape arrays in f77, the library writer used sequence
association to declare arrays as a(lda,1) or a(lda,*)
Fortran 90 allows one to declare arrays as a(:,:) and to away with linear
memory model assumption.
Thanks.
========= calling program testSolver.f90 in fortran 90 =========
!! In this program, we are solving the following system
!! Ax = b
!! using Gaussian Elimination
program testGSolver
implicit none
integer, parameter :: dp = kind(1.0d0), &!
d = 2
real(kind=dp),dimension(d,d) :: a
real(kind=dp),dimension(d) :: extras
real(kind=dp) :: cond_num
integer,dimension(d) :: pivot_info
integer :: nrow
a = reshape((/1,2,3,5/),(/2,2/)) ! initialization of the array
nrow = d
call dgeco(at,nrow,nrow,pivot_info,cond_num,extras)
==
>>>> at and a are not the same array!!! <<<<
print *, a(1,:)
print *, a(2,:)
print *, "pivot information: ", pivot_info
print *, "condition number : ", cond_num
end program testGSolver
=========== called program dgeco.f in fortran 77 ===============
subroutine dgeco(a,lda,n,ipvt,rcond,z)
integer lda,n,ipvt(1)
! double precision a(lda,1),z(1)
double precision a(lda,n),z(1)
double precision rcond
print *,"dgeco : lda = ", lda
print *,"dgeco : n = ", n
print *,"dgeco : shape of a =: ",shape(a)
a = 10
a(1,1) = 11
print *,"dgeco : ",a(1,:)
print *,"dgeco : ",a(2,:)
return
end
=========== output result ====================
dgeco : lda = 2
dgeco : n = 2
dgeco : shape of a = 2 2
dgeco : 11.0 10.0
dgeco : 10.0 10.0
1.0 3.0
2.0 5.0
pivot information: 0 0
condition number : 0.0
-----------------------------------------------------------
Jaehoon,Seol e-mail : [log in to unmask]
www : http://www.math.uiowa.edu/~seol
Only the person born without mother can be free.
-----------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|