Please try running this under valgrind (see 'Writing R Extensions'). The most likely cause is that the Fortran code is corrupting its or R's memory. You may need a build of R set up to instrument R allocations (see the manual for details).

On Tue, 13 Apr 2010, jgar...@ija.csic.es wrote:

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
---

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to