Thanks . It works now. But I thought all you do here are 1) add
implicit none 2) move function into the program 3) use the word
'contains'
you didn't change the RMSE function.
Could you explain more about :
You are trying to initialize a variable to a non-constant value. That
can't be done
Thanks
Richard
On Jan 10, 2006, at 5:18 PM, [log in to unmask] wrote:
>>
>> I am new to Fortran. I can not understand why the following code
>> produce strange result : The print out N is always 0, no matter the
>> what size the array b is ( I thought it should be 3, in this case)
>>
>> Can anyone give me a reason? Thanks.
>>
> You are trying to initialize a variable to a non-constant value. That
> can't be done. Further, for assumed shape arrays to work correctly,
> you
> need an explicit interface. Also, all debugging is easier in the
> presence of an implicit none statement. Note, too, that real*8 is
> widely
> accepted but is non-standard.
>
> Corrected code follows.
>
> Hope that helps,
>
> Mike Metcalf
>
> program test
> implicit none
> real*8, dimension(3) :: b
> real*8 :: e
> e=RMSE(b)
>
> contains
>
> function RMSE(Integral)result(e)
>
> real*8, dimension(:), intent(in) :: Integral
> real*8 :: e
> integer :: N
> N = size(Integral)
> e=1.
> print*, N
>
> end function RMSE
>
> end program
|