[R] Compiling a FORTRAN program under Windows 7

Clint Bowman clint at ecy.wa.gov
Thu May 5 18:28:27 CEST 2011


You are compiling a subroutine not a program and you compile line 
should read:

gfortran testit.f -c testit.o

You then reference that object code testit.o in your final loading 
stage after compiling other routiens and the main program.

-- 
Clint Bowman			INTERNET:	clint at ecy.wa.gov
Air Quality Modeler		INTERNET:	clint at math.utah.edu
Department of Ecology		VOICE:		(360) 407-6815
PO Box 47600			FAX:		(360) 407-7534
Olympia, WA 98504-7600


         USPS:           PO Box 47600, Olympia, WA 98504-7600
         Parcels:        300 Desmond Drive, Lacey, WA 98503-1274


On Thu, 5 May 2011, Mikael Anderson wrote:

> Hi,
>
> I am trying to compile a FORTRAN program to call from R under Windows 7 but
> I am having problem in the compiling step. To demonstrate this is the
> program testit.f:
>
> ------------------------------------------
>      subroutine TESTIT(x,n,m)
>      dimension x(n)
>      do 10 i=1,n
> 10      x(i)=x(i)**m
>      end
> --------------------------------------------
>
> When I compile it with gfortran I get the following error:
>
> --------------------------------------------------
> c:\MinGW\programs>gfortran testit.f -o testit.o
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.tex
> t+0xd2): undefined reference to `WinMain at 16'
> collect2: ld returned 1 exit status.
> ----------------------------------------------------
>
> I should add that a program like the following hello.f compiles with no
> problem.
>
> ------------------------------------------
>         READ (*, *) YOURNAME
>         WRITE (*, 200) YOURNAME
> 200     FORMAT(//,' Hello ',A/)
>         STOP
>         END
> ------------------------------------------
>
> I realize that this is not directly a question about R but I guess there are
> some people here who have compiled FORTRAN programs under Windows 7 to call
> from R. I appreciate any help to fix the problem.
>
> /Mikael
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list