Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tempory matrix parameter saving 1

Status
Not open for further replies.

synhedionn

Programmer
Oct 22, 2008
9
FR

hi,
I wondered how to declare a tempory matrix saving variable: must it have same intent() parameters than the parent one it's related to?

For instance:
"program paramMat

! gfortran paraMatrix.f90 -o paraMatrix
implicit none
integer, parameter :: dim = 4

real, dimension(dim,dim) ::a


call initialisation
call morphMatrix(a)





contains
subroutine morphMatrix(Matrix)
real,intent(in), dimension(dim,dim) ::Matrix
real, dimension(size(Matrix,1),size(Matrix,2)) ::mat


mat=Matrix !temp saving var before modifying Matrix

end subroutine morphMatrix


subroutine initialisation
a = reshape( (/ 1., 1., 1., 1., &
& 1., 0., 1., 0., &
& 0., 1., 0., 1., &
& 1. ,0., 0., 1. /), (/dim,dim/)
end subroutine initialisation




end program paramMat

"

But I ve errors:
"

gfortran paraMatrix.f90 -o paraMatrix
In file paraMatrix.f90:32

& 1. ,0., 0., 1. /), (/dim,dim/)
1
Error: Syntax error in argument list at (1)

Compilation exited abnormally with code 1

"
What is wrong?
 
In the reshape statement is missing the right most closing parenthesis: "[red])[/red]"
Correct it to
Code:
a = reshape( (/ 1., 1., 1., 1., &
& 1., 0., 1., 0., &
& 0., 1., 0., 1., &
& 1. ,0., 0., 1. /), (/dim,dim/))
and it compiles fine with
Code:
$ gfortran paramatrix.f90 -o paramatrix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top