[Rd] Fortran with OpenMP
Fabio Mathias Corrêa
fabio.ufla at yahoo.com.br
Sun Oct 18 02:53:26 CEST 2009
I wrote a code in Fortran using OpenMP. When testing the code in Fortran it was working. However, changing the code for the R, it does not indicate the use of threads, it should indicate.
I know that the R accepts the directives of OpenMP, but I can not use them correctly in R.
Below is a small sample code that should work with the use of OpenMP, but does not work when I use the R.
SUBROUTINE A1(N, A, B)
INTEGER :: I, N
DOUBLE PRECISION, DIMENSION(N) :: B(N), A(N)
LOGICAL :: OMP_IN_PARALLEL
!$OMP PARALLEL DO
B(I) = (A(I) + A(I-1)) / 2.0
!$OMP END DO
!$OMP END PARALLEL
END SUBROUTINE A1
R CMD SHLIB teste.f95 -o teste.so -fopenmp
# Output of the R
a <- rnorm(10)
b <- rnorm(10)
N <- length(a)
.Fortran("A1", as.integer(n), as.double(a),as.double(b))
F ######### Should return TRUE and not FALSE
 -1.0885364 0.4170852 -0.4627566 0.5662825 -1.9792053 1.0347733
 1.1615486 1.1752779 1.4337560 -0.2803431
 -0.52768479 -0.33572564 -0.02283571 0.05176294 -0.70646140 -0.15066979
 -0.82335438 1.20606866 -1.65533309 1.04965146
Somebody to say would know me where is the error?
Thank you very much!
Fábio Mathias Corrêa
Estatística e Experimentação Agropecuária/UFLA
Veja quais são os assuntos do momento no Yahoo! +Buscados
More information about the R-devel