[Rd] R crashes on calling a Fortran routine (PR#2728)

martyn.byng at nag.co.uk martyn.byng at nag.co.uk
Fri Apr 4 12:21:17 MEST 2003


Full_Name: martyn byng
Version: 1.6.2
OS: windows 2000 (professional)
Submission from: (NULL) (62.231.145.253)


I am having problems calling a fortran routine from within R. When the routine
is called, R exits with an application error:
"The instruction at 0x004a8b7d referenced memory at 0x200000015. The memory
could not be written".

The R code used to call the routine is:
.Fortran("GTEST",a=as.integer(1),b=as.integer(3),c=as.integer(-10),d=as.integer(0),e=as.integer(0))

The Fortran routine itself, is just a dummy routine, created to try and find out
why a more complex routine was causing R to crash, and consists of:

     SUBROUTINE GTEST_(A,B,C,D,E)
	INTEGER A,B,C,D,E

	!DEC$ ATTRIBUTES DLLEXPORT :: GTEST_
	!DEC$ ATTRIBUTES ALIAS:'GTEST_' :: GTEST_

      END

Where the !DEC commands are needed in Visual Fortran to create the DLL (I think
!, these were copied from an example file on the compaq web page).

The strange thing about this is that if I remove variable E from the subroutine
definition and recreate the DLL everything works as expected. The routine causes
R to crash only when it has more than 4 variables.

The Fortran code was compiled into a Windows 32bit DLL using Compaq Visual
Fortran Professional, edition 6.1.0



More information about the R-devel mailing list