Re: [R] Compiling a FORTRAN program under Windows 7

From: Clint Bowman <clint_at_ecy.wa.gov>
Date: Thu, 05 May 2011 09:28:27 -0700 (PDT)

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.
>
______________________________________________ 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.
Received on Thu 05 May 2011 - 16:30:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 16:40:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive