This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: How to compile Fortran 90 subroutine under CYGWIN


--- Ven 21/5/10, bo yu  ha scritto:

> 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

gfortran can handle F90 and F77, but in your makefile
you have no rule for ".f90" extension


> 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

Why gcc is invoked for Fortran ??
See "10.7 Old-Fashioned Suffix Rules" of info make

> make: *** No rule to make target âswan_init.oâ, needed
> by âsloshDosâ. 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 
and see what happens 

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

during the linking you need to add the 
"-lgfortranbegin -lgfortran"

>  
> My Questions are
> (1) Does gfortran work for fortran 90 program only? 

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. 
You should read the make documentation.

>  
>  
> I would appreciate any suggestion what should I look at.
>  
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]