On 24/03/2011 12:35 PM, Daniel Fuka wrote:
Howdy,

I am having a problem with a library compiled from some legacy fortran
code. I can call the library, it runs as it should, returns a list,
and gives a ">" prompt, but then locks up the R session. Functions
typed in return nothing. ctrl-c results in a new prompt that is still
locked up, and R overwhelms the processor. This happens on Mac,
Windows, and Linux exactly the same. I close all open files and
confirm nothing is still open with unix lsof. I also have added a
routine to deallocate all allocated variables.

Does anyone have any suggestions in how I might be able to debug this
further? I have included output from the R session, top -o CPU, and R
CMD INSTALL below.

I would guess that the Fortran is trying to do some Fortran-style I/O; that often causes problems. See Writing R Extensions for alternatives (dblepr etc.). Or it might be some other bug.

The best way to debug something like this is with gdb or gdb plus a front end like Insight, Xcode, Eclipse, etc., but if you haven't used them before, they are somewhat daunting. If you're doing this on Windows you'll need to rebuild your library with the environment variable DEBUG set to T to get the debugging information compiled into it. Not sure if you need to do anything on the other systems.

Duncan Murdoch

Thanks for your time on my behalf!
dan

Ouput from R session with library "swat" and subroutine "junk":
>  library.dynam("swat","EcoHydrology")
>  .Fortran("junk")
                 SWAT2005
       Soil&  Water Assessment Tool
                PC Version
  Program reading from file.cio . . . executing

list()
>
^C
>  q("n")
^C
>  obejcts()


^C
>  q()

^C
>  ^Z
[1]+  Stopped                 r
DRF28:~/cornell/ecohydrology/swat_example/SJ_R_test_mac/Scenarios/Default/TxtInOut_R
dan$ killall R
[1]+  Terminated              r


Output from top during lockup:
   PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
40750 R           96.6%  1:56.07   1    17     87   15M  1384K-   19M    49M

Output from R CMD INSTALL:
114 mirage5:fuka% R CMD INSTALL EcoHydrology
* installing to library
‘/glade/home/fuka/R/x86_64-unknown-linux-gnu-library/2.12’
* installing *source* package ‘EcoHydrology’ ...
** libs
** arch -
Makefile:123: warning: overriding commands for target `.f.o'
/fs/local/apps/R-2.12.1/lib64/R/etc/Makeconf:132: warning: ignoring
old commands for target `.f.o'
gfortran -fPIC -g -O2   -c modparm.f
gfortran -fPIC -g -O2   -c addh.f
---SNIP successful gfortran output----
gfortran -fPIC -g -O2   -c zeroini.f
gfortran -fPIC -g -O2   -c closefiles.f
gfortran -shared  -o swat.so modparm.o addh.o albedo.o
allocate_parms.o alph.o analyse.o anfert.o apex_day.o apply.o ascrv.o
---SNIP successful link output----
writeaa.o writed.o writem.o writeswatfile.o writeswatmain.o xisquare.o
xiunc.o xmon.o ysed.o zero0.o zero1.o zero2.o zeroini.o closefiles.o
installing to 
/glade/home/fuka/R/x86_64-unknown-linux-gnu-library/2.12/EcoHydrology/libs
** R
** data
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (EcoHydrology)

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

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

Reply via email to