Mail Archives: cygwin/2010/05/21/12:11:10
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-SWARE-Spam-Status: | No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE
|
X-Spam-Check-By: | sourceware.org
|
Message-ID: | <188887.5301.qm@web25505.mail.ukl.yahoo.com>
|
Date: | Fri, 21 May 2010 16:10:04 +0000 (GMT)
|
From: | Marco Atzeri <marco_atzeri AT yahoo DOT it>
|
Subject: | RE: How to compile Fortran 90 subroutine under CYGWIN
|
To: | cygwin AT cygwin DOT com, bo yu <enviyub2 AT hotmail DOT com>
|
In-Reply-To: | <SNT129-W506D793A069A9C8255888187E40@phx.gbl>
|
MIME-Version: | 1.0
|
X-IsSubscribed: | yes
|
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm
|
List-Id: | <cygwin.cygwin.com>
|
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
|
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com>
|
List-Archive: | <http://sourceware.org/ml/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
|
Sender: | cygwin-owner AT cygwin DOT com
|
Mail-Followup-To: | cygwin AT cygwin DOT com
|
Delivered-To: | mailing list cygwin AT cygwin DOT com
|
--- Ven 21/5/10, bo yu ha scritto:
> Tim,
>=20=20
> Thanks for your reply.
>=20=20
> I have the new version of cygwin installed in my computer,
> in which the g77, g++, gcc, gfortran, C++ compiler are in
> C:\cygwin\bin.
>=20
> Firstly, I use cygwin build C programs and For77 programs.
> It works very well. Now, I add two For90 programs and want
> to build following program together in cygwin:
>=20=20
> Fortran 77 program:=C2=A0=C2=A0=C2=A0runslhg.f , intrface.f
>=20
> Fortran 90 program:=C2=A0=C2=A0=C2=A0swan_init.f90 ,=C2=A0
> swan_loopstep.f90
gfortran can handle F90 and F77, but in your makefile
you have no rule for ".f90" extension
> C Program:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
> slosh2.c ,=C2=A0 cstart.c etc.
>=20=20
> Step 1: I replace g77 with gfortran in 'makefile',=20
>=20=20
> #!/bin/make
> SHELL =3D /bin/sh
> CC =3D gcc
> F77 =3D gfortran
> STRIP =3D strip
> STD_FLAGS =3D -O3 -Wall -pedantic -ansi
> FFLAGS =3D
> LD_FLAGS =3D -Wl,--stack,8000000
> STD_DEF =3D -D_WINDOWS_ -D_GCC_
> STD_INC =3D -I.
> STD_LIB =3D -lg2c -L/usr/lib -lm
> PRJ_NAME =3D sloshDos
> TARGETS =3D $(PRJ_NAME)
> CFLAGS =3D $(STD_FLAGS) $(STD_DEF) $(STD_INC)
> ############################
> # FILES
> ############################
> H_SOURCES =3D slosh2.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pack.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 myassert.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 myutil.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 savellx.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 complex.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 clock.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tendian.h \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tio3.h
> C_OBJECTS =3D slosh2.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pack.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 myassert.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 myutil.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 savellx.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 complex.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 clock.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tendian.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tio3.o
> F_OBJECTS =3D runslhg.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 intrface.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 swan_init.o \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 swan_loopstep.o
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=20
> C_MAIN =3D cstart.c
> ############################
> # TARGETS
> ############################
> all: $(TARGETS)
> @echo ""
> $(PRJ_NAME): $(C_OBJECTS) $(F_OBJECTS) $(C_MAIN)
> $(LIB_DEPENDS) $(H_SOURCES)
> $(CC) $(C_MAIN) $(CFLAGS) $(LD_FLAGS) $(C_OBJECTS)
> $(F_OBJECTS) $(STD_LIB) -o $(PRJ_NAME)
> $(STRIP) -s $(PRJ_NAME).exe
> install:
> cp *.exe ../../bin
> clean:
> rm -f *.o *.bak *.BAK
> ############################
> # SUFFIXES
> ############################
> .c.o : $(H_SOURCES)
> $(CC) -c $(CFLAGS) $<
> .f.o:
> ${F77} -c ${FFLAGS} $<
>=20=20
>=20
> Step 2: in cygwin, I ran makefile, The error message is
>=20=20
> gcc =E2=80=93c runslhg.f
> gcc =E2=80=93c intrface.f
Why gcc is invoked for Fortran ??
See "10.7 Old-Fashioned Suffix Rules" of info make
> make: *** No rule to make target =E2=80=98swan_init.o=E2=80=99, needed
> by =E2=80=98sloshDos=E2=80=99. Stop
The message is clear. You gave no indication how to make
swan_init.o from swan_init.f90
Try to copy/rename the swan_init.f90 to swan_init.f=20
and see what happens=20
>=20=20
> Step 3: To test if gfortran compiler wotk for For77
> program, I try to build C program and For70 programs only
> using gfortran, I ran makefile, The error message is
>=20=20
> runslhg.o:runslhg.f:,.text+0x4f>: undefined reference to
> '__gfortran_st_read'
> runslhg.o:runslhg.f:,.text+0x6d>: undefined reference to
> '__gfortran_transfer_character'
> runslhg.o:runslhg.f:,.text+0x7b>: undefined reference to
> '__gfortran_st_read_done'
>=20=20
during the linking you need to add the=20
"-lgfortranbegin -lgfortran"
>=20=20
> My Questions are
> (1) Does gfortran work for fortran 90 program only?=20
No. it compiles also F77
> (2) g77 compiler works for fortran 77 programs. Does g77
> work for fortran 90 programs?
I doubt
> (3) How to build C, FOR77 and For 90 programs together in
> cygwin? How to set the makefile, use separete command for
> for77 and for 99?
This is not really a cygwin problem.=20
You should read the make documentation.
>=20=20
>=20=20
> I would appreciate any suggestion what should I look at.
>=20=20
> Thanks again,
> Bo
Regards
Marco
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -