Hi, I've stripped all the code, and it seems that any simple attempt to open/close a file from fortran is the cause of the error, and the error appears in f77 as well as in f95 code. Please, find attached a foo package that reproduce the errors, it should build/check/install without any problem (it does in my computer). If the code
OPEN( UNIT=5, FILE=runfile, STATUS='OLD', ACTION='READ', & IOSTAT=status) WRITE (*,*) 'status: ', status IF ( status == 0 ) THEN READ(5,'(A)') modelsel READ(5,'(A)') modelfile READ(5,'(A)') datdirpid CLOSE(5) WRITE (*,*) 'selected model: ', modelsel WRITE (*,*) 'model input file: ', modelfile WRITE (*,*) 'datdirpid: ', datdirpid ELSE WRITE (*,1002) status 1002 FORMAT (1X,'open runfile failed--status = ', I6) STOP END IF is commented out in any of the two sources files (the f77 or the f95 one), none of the two corresponding wrappers (as they appear in the examples) give an error. Thus it seems clear that the operation causing it is the OPEN/CLOSE. Without commenting out these pieces of code, everything seems to work right but R halts after a call to the wrapper functions. I cannot find any comment about this in the documentation. Please, could you tell me if this is a known error? Thanks, Javier --- > 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 >
foofortran.tar.gz
Description: GNU Zip compressed data
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel