Print

Print


frank_ouyang wrote:
>
> Hello:
>
> There is a example as follow:
>
> parameter(m=2,n=2)
> A(m,n)
> call BB(A,m,n)
> stop
> end
>
> subroutine BB(A,m,n)
> real A(*,*)
>      ^^^^^^? Corret?
No, this is incorrect.

The best thing is

    real A(m,n)

That exactly describes what you are doing here, it's standard
conforming and easy to use.

You could do
    real A(m,*)
but that doesn't tell the compiler exactly what you are doing.
Arrays dimensionsed with a * in the last dimension are called
assumed size arrays and are normally used when the array size
isn't very important.  For example, when you are only going to
use part of the last dimension.  In my opinion, it's usually a
mistake for a beginner to use an * for the last dimension of an
array.

If you want to use some of the new Fortran 90 features you can use
assumed shape arrays.  The syntax is

PROGRAM MAIN
> parameter(m=2,n=2)
> A(m,n)
> call BB(A)
> stop
    !move the end
>
CONTAINS
> subroutine BB(A)
> real A(:,:)
> return
> end
>
> end      !  end for MAIN goes here

In this case, the compiler will pass the dimensions of A by magic to
the INTERNAL subroutine BB.  You can get the same effect by putting
BB in a module and using BB.  But, from your question I don't think
you're using F90.  When you're ready to move up to F90 any good
book should tell you about modules.  They take a lot of the work
out of argument passing.

Dick Hendrickson

> While programming, I am told that It is wrong with A(*,*).However, A(m,*) is
> OK!
> How can I deal with it?
>
> Thanks
>
> --http://www.eyou.com
> --稳定可靠的免费电子信箱  语音邮件  移动书签  日历服务  网络存储...亿邮未尽