At 11:48 06-03-03 +0100, Roland Schilling wrote:
>On Thu, 6 Mar 2003, Michael Metcalf wrote:
>
> > If you want an optional mask, and you don't have too many FORALL
> statements,
> > then you can always use a structure like:
> >
> > SUBROUTINE S(........, MASK,...)
> > LOGICAL, OPTIONAL, DIMENSION(:) :: MASK
> > :
> > IF(PRESENT(MASK)) THEN
> > FORALL(..., MASK) ....
> > ELSE
> > FORALL(...) ...
> > END IF
>
>That's exactly what I'm doing. When first writing down this I stumbled
>across the points in question. My interest was mainly academic.
>
>Regards,
>Roland
A small, nevertheless essential, point Fortran gurus must have noticed already:
A Fortran 95 compiler probably rejects the above construct,
because MASK should be scalar :-()
I completed the subroutine as;
SUBROUTINE S( x, MASK)
LOGICAL, OPTIONAL, DIMENSION(:) :: MASK
real, dimension(:) :: x
IF(PRESENT(MASK)) THEN
FORALL(i = 1:12, MASK) x(i) = 3.3
ELSE
FORALL( i = 1: 22) x(i) = 5.5
END IF
end
Indeed, my Absoft compiler says:
cf90-1624 error on line 5 of mask.f95: The expression for the mask
expression of
a FORALL header must be a scalar logical expression.
Though Salford compiles it with NO ERRORS
\---
Support bacteria:
They're the only culture some people have.
Best regards,
Jan van Oosterwijk
Netherlands
mailto:Jan.vanOosterwijk<at>DTO.TUDelft.NL
http://huizen.dto<dot>tudelft.nl/vanOosterwijk/
|