From drf28 at cornell.edu  Thu Mar 24 17:35:07 2011
From: drf28 at cornell.edu (Daniel Fuka)
Date: Thu, 24 Mar 2011 12:35:07 -0400
Subject: [Rd] .Fortran successful, R locks up.
Message-ID: <AANLkTikgcW_L1kYER3bDZJCsD8xC7BwJpMhRKUX8Xt8N@mail.gmail.com>

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.

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)



[Rd] .Fortran successful, R locks up.
Daniel Fuka