From jgarcia at ija.csic.es  Tue Apr 13 12:42:46 2010
From: jgarcia at ija.csic.es (jgarcia at ija.csic.es)
Date: Tue, 13 Apr 2010 12:42:46 +0200 (CEST)
Subject: [Rd] .Fortran interface error
Message-ID: <48821.86.0.54.218.1271155366.squirrel@paleo.ija.csic.es>

Hi all,
I'm preparing a package which uses .Fortran to interface a Fortran 95
function. This F95 function simply receives the name of a file from R,
opens this file and forwards its content to a F95 module, which, in turn,
makes the real computation.  The F95 module is a pre-existing one and I'm
trying to use it in its actual state.

Thus, data transfer between R and this F95 module is made through scratch
system files (binary or ASCII), and R-F95 interface simply forwards a
pathed name to this module.

OS: openSUSE 10.3 (x86_64)
R version 2.10.1 (2009-12-14)

Then, I've put a demo which makes use of the function, but after model
execution (the F95 code) finishes correctly, and all output is read  back
properly by R (again through system files), R halts, and the following
message appears:

*** glibc detected *** /usr/local/lib64/R/bin/exec/R: free(): invalid
pointer: 0x00000000008a1aa0 ***

Could you give me any hint about where to look for errors?

Just to say that if instead of the R-f95 interface,

I compile the F95 code as executable "runhydro" an call it as:

>system(paste(bindirp,"runhydro",sep="/"))

everything is OK, while compilation as a dynamic library and access to the
F95 "big" module through the simple R-F95 interface:

>res <- .Fortran("runhydro",
                 runfile = as.character(mainfile[1]),
                 charsfile = nchar(mainfile[1]),
                 PACKAGE = "hydroarid"
               )

is what is giving the error (I could handle you the package)

Thanks and best regards,

Javier
---



[Rd] .Fortran interface error
jgarcia at ija.csic.es