For Programmers: Free Programming Magazines  


Home > Archive > Fortran > July 2004 > passing an allocatable matrix in a subroutine to the main program









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author passing an allocatable matrix in a subroutine to the main program
joel GUERRERO

2004-07-31, 3:56 am

Can anybody help me with this.
I need to pass an allocatable matrix in a subroutine to the main
program or to another subroutine. How can I do?
I always get an error that I cannot do this.

:\MSDEV\Mis proyectos\allocate\readmesh.f90(10): error FOR3435: symbol
XC is a dummy argument - cannot be ALLOCATABLE detected between XC and
,
Error executing fl32.exe.
allocate.exe - 1 error(s), 0 warning(s)
beliavsky@aol.com

2004-07-31, 3:56 am


joegi.geo@yahoo.com (joel GUERRERO) wrote:
>Can anybody help me with this.
>I need to pass an allocatable matrix in a subroutine to the main
>program or to another subroutine. How can I do?
>I always get an error that I cannot do this.
>
>:\MSDEV\Mis proyectos\allocate\readmesh.f90(10): error FOR3435: symbol
>XC is a dummy argument - cannot be ALLOCATABLE detected between XC and
>,
>Error executing fl32.exe.
>allocate.exe - 1 error(s), 0 warning(s)


ALLOCATABLE subroutine arguments (ASA) are not part of the Fortran 95 standard
but were added in a Technical Report and will be part of Fortran 2003. Many
Fortran 95 compilers already support ASA.

Your compilation command is 'fl32.exe', which on my PC refers to the Compaq
Visual Fortran compiler (I always use df.exe to invoke it). CVF 6.6 does
support ASA, and the following program does compile and run. Maybe you are
using an earlier version of CVF that does not support ASA or perhaps 'fl32.exe'
refers to Microsoft Fortran Powerstation, an old Fortran 90 compiler that
I would not expect to support ASA. Which compiler are you using?

module xmod
contains
subroutine foo(xx,n)
real, allocatable :: xx(:)
integer, intent(in) :: n
integer :: i
allocate (xx(n))
do i=1,n
xx(i) = real(i)
end do
end subroutine foo
end module xmod

program xmain
use xmod, only: foo
real, allocatable :: yy(:)
call foo(yy,5)
print*,yy
end program xmain



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jugoslav Dujic

2004-07-31, 8:56 am

beliavsky@aol.com wrote:
| joegi.geo@yahoo.com (joel GUERRERO) wrote:
|| Can anybody help me with this.
|| I need to pass an allocatable matrix in a subroutine to the main
|| program or to another subroutine. How can I do?
|| I always get an error that I cannot do this.
||
|| :\MSDEV\Mis proyectos\allocate\readmesh.f90(10): error FOR3435: symbol
|| XC is a dummy argument - cannot be ALLOCATABLE detected between XC and
|| ,
|| Error executing fl32.exe.
|| allocate.exe - 1 error(s), 0 warning(s)
|
| Your compilation command is 'fl32.exe', which on my PC refers to the Compaq
| Visual Fortran compiler (I always use df.exe to invoke it).

Yes, but that's purely for compatibility with MS Fortran PowerStation4,
whose compiler name was fl32.exe, and whose default installation directory
is C:\MSDEV..., and that had FORxxxx nomenclature of error codes...

I'd strongly suggest to Joel to ditch that buggy & unsupported compiler.
(It does not support ALLOCATABLE dummies.)

Joel, you do know that you need ALLOCATABLE attribute for a dummy argument
only if you intend to do (de)allocation within the subroutine, don't you?
Otherwise, (if you allocate it in the caller) you don't need it at all,
as it will be treated as a normal static array within the subroutine.
If you do need it, you can declare the matrix POINTER in both caller and
callee and get by with that.

--
Jugoslav
___________
www.geocities.com/jdujic

Please reply to the newsgroup.
You can find my real e-mail on my home page above.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com