! File=Elemental.f90 ! Suggestions by Mike Metcalf. ! For rules see: ! http://www-1.ibm.com/support/docview.wss?uid=swg27010224 ! or ! http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlf101l.doc/xlflr/elmntproc.htm real, dimension(2,3) :: x real, dimension(2,3,4) :: y x=1.5 y=2.6 ! The elemental function (foo) suports array arguments of 8 ranks: ! 0,1,2,... 7. ! If there were two arguments there would be 22 combinatinons of ! Intent(in) arguments supported: ! see Fortran 95/2003 Explained, Metcalf, et al, page 115. ! 0-0, 0-1, 1-0, 1-1, 0-2, 2-0, 2-2, ... 0-7, 7-0, 7-7. print *, foo(x(1,2)) print *, foo(x(1,:)) print *, foo(x) print *, foo(y) contains elemental function foo(x) real, intent(in) :: x foo = x + 1. ! write(*,*)"x = ", x end function foo end