- Code: Select all
!$OMP END TASKWAIT
should be
- Code: Select all
!$OMP TASKWAIT
Regarding the Fortran code itself, gfortran 4.4.0 issues the following error when attempting to compile the recursive function as part of a simple program:
- Code: Select all
i = fib( n-1 )
1
Error: 'fib' at (1) is the name of a recursive function and so refers to the result variable. Use an explicit RESULT variable for direct recursion (12.5.2.1)
Sun Studio Express 3/09 issues a warning containing a similar message when invoked with "-ansi".
A more portable version of example A.13.4f:
- Code: Select all
RECURSIVE INTEGER FUNCTION fib(n) RESULT(res)
INTEGER n, i, j
IF ( n .LT. 2) THEN
res = n
ELSE
!$OMP TASK SHARED(i)
i = fib( n-1 )
!$OMP END TASK
!$OMP TASK SHARED(j)
j = fib( n-2 )
!$OMP END TASK
!$OMP TASKWAIT
res = i+j
END IF
END FUNCTION
--
Nathan Weeks
