Skip to main content

Posts

Showing posts from November, 2007

How to use Fortran95 code in R

Aim: Write a small test subroutine in Fortran using basic functionality and some calls to the International Mathematics and Statistics Library (IMSL) - compile a dll and call the subroutine from R taking some memory allocation problems into account.

Prerequisites: A working installation of Microsoft Visual Studio and Intel Fortran Compiler v.10 w. IMSL and R 2.6
This link may also be useful.

Save the following code as test.f90 in C:\Fortrancode

!---begin code---

subroutine test(M,N,S1,V,NU,S2,D,INVX)

!DEC$ ATTRIBUTES DLLEXPORT :: test
!Routines necessary for BSKS,
!used in calculation of
!modified Bessel Function of second kind
use BSKS_INT
use UMACH_INT

!We use linear_operators for elegant
!basic linear algebra syntax
use linear_operators

implicit none

!input:
!V vector with values used as input in Bessel fct.
!M number of numbers in vector V
!XDUM matrix with dimensions (M,N)
!D dimension of dummy square matrix MX
!NU fractional order used in calculation of
!value of Bessel fct. modulo 1. Must be positiv…