At 11:46 am +0000 21/4/98, Malcolm Cohen wrote:
>There are two mistakes in your program.
>
>> program test
>> integer:: i=1
>> external funsub
>>
>> call testsub1(funsub,i)
>>
>> contains
>> subroutine testsub1(f,i,j)
>> integer:: i
>> integer,optional:: j(:)
>> external f
>>
>> call f(i,j)
>
>This call is only legal if J is PRESENT.
>It should read something like
> if (present(j)) then
> call f(i,j)
> else
> call f(i)
> end if
>
I don't believe that's illegal. According to "Fortran 90/95 explained"
it's legal to propagate absent arguments through any number of call
levels (see page 101). There is no need to put the if (present())
code in testsub1, but it would need to go in 'f' if 'f' intended
to do something with J.
But I agree with your other comments, f is wrongly declared with only
one argument and there should be an interface block in main for f.
Glenn
----
Dr. Glenn Carver, Senior Research Associate,
Centre for Atmospheric Science, Chemistry Dept., Cambridge University, UK
Email: [log in to unmask] Web: http://www.atm.ch.cam.ac.uk/
"Success is relative: It is what we can make of the mess we
have made of things". T.S. Eliot, The family reunion (1939).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|