delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/05/21/12:05:06

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4BF6AF0F.90308@aol.com>
Date: Fri, 21 May 2010 09:04:31 -0700
From: Tim Prince <n8tm AT aol DOT com>
Reply-To: tprince AT computer DOT org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4
MIME-Version: 1.0
To: bo yu <enviyub2 AT hotmail DOT com>
CC: tprince AT computer DOT org, cygwin AT cygwin DOT com
Subject: Re: How to compile Fortran 90 subroutine under CYGWIN
References: <SNT129-W2E72156B2337B784EB72687E40 AT phx DOT gbl>,<4BF6803B DOT 2060103 AT aol DOT com> <SNT129-W506D793A069A9C8255888187E40 AT phx DOT gbl>
In-Reply-To: <SNT129-W506D793A069A9C8255888187E40@phx.gbl>
x-aol-global-disposition: G
X-AOL-SCOLL-SCORE: 0:2:415315808:93952408
X-AOL-SCOLL-URL_COUNT: 0
x-aol-sid: 3039ac1d29454bf6af1162c8
X-AOL-IP: 192.55.60.73
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

On 5/21/2010 8:21 AM, bo yu wrote:
> Tim,
>
> Thanks for your reply.
>
> 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.
>
> 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:
>
> Fortran 77 program:   runslhg.f , intrface.f
> Fortran 90 program:   swan_init.f90 ,  swan_loopstep.f90
> C Program:            slosh2.c ,  cstart.c etc.
>
> Step 1: I replace g77 with gfortran in 'makefile',
>
> #!/bin/make
> SHELL = /bin/sh
> CC = gcc
> F77 = gfortran
> STRIP = strip
> STD_FLAGS = -O3 -Wall -pedantic -ansi
> FFLAGS =
> LD_FLAGS = -Wl,--stack,8000000
> STD_DEF = -D_WINDOWS_ -D_GCC_
> STD_INC = -I.
> STD_LIB = -lg2c -L/usr/lib -lm
> PRJ_NAME = sloshDos
> TARGETS = $(PRJ_NAME)
> CFLAGS = $(STD_FLAGS) $(STD_DEF) $(STD_INC)
> ############################
> # FILES
> ############################
> H_SOURCES = slosh2.h \
>              pack.h \
>              myassert.h \
>              myutil.h \
>              savellx.h \
>              complex.h \
>              clock.h \
>              tendian.h \
>              tio3.h
> C_OBJECTS = slosh2.o \
>              pack.o \
>              myassert.o \
>              myutil.o \
>              savellx.o \
>              complex.o \
>              clock.o \
>              tendian.o \
>              tio3.o
> F_OBJECTS = runslhg.o \
>              intrface.o \
>              swan_init.o \
>              swan_loopstep.o
>
> C_MAIN = 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} $<
>
>
> Step 2: in cygwin, I ran makefile, The error message is
>
> gcc –c runslhg.f
> gcc –c intrface.f
> make: *** No rule to make target ‘swan_init.o’, needed by ‘sloshDos’. Stop
>
> 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
>
> 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'
>
>
> My Questions are
> (1) Does gfortran work for fortran 90 program only?
> (2) g77 compiler works for fortran 77 programs. Does g77 work for fortran 90 programs?
> (3) How to build C, FOR77 and For 90 programs together in cygwin? How to set the makefile, use seperate command for for77 and for 99?
>
>    
gfortran is intended to be a full replacement for g77, as well as 
supporting f95 and some f2003.
g77 might work for f77 code in .f90 source format, if you figured out 
the correct free form options.  It won't handle much f90 syntax.  It 
hasn't been maintained for about 5 years.
If you have set gfortran as your compiler, the .f90.o rule would look 
just like the .f.o rule.
You should persuade the Makefile to use the Fortran compiler rather than 
gcc for compiling and linking Fortran source code.  g77 and gfortran can 
handle .c files automatically.

-- 
Tim Prince


--
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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019