Fortran 77 Interface with gfortran 4.2.2 (Cantera 1.7.0)

131 views
Skip to first unread message

emil

unread,
Jan 22, 2010, 5:15:50 AM1/22/10
to Cantera User's Group
Maybe somebody finds this usefull:
Just an observation for the old Fortran 77 interface

The demo of the interface can be found in the directory /templates/
f77.

in the Makefile demo.mak you have to add
-L/usr/lib -lgfortran
to the linkflags

I renamed demo.mak to Makefile then the demo can be compiled by the 2
commands
gfortran - c demo.f
make -f demo.mak

Regards
emil

Copy Paste the changed Makefile in case you need it
------------------------------------------------------------------------

#!/bin/sh

# This Makefile builds a Fortran 77 application that uses Cantera. By
# default, the main program file is 'demo.f,' which prints out some
# properties of a reacting gas mixture. It uses the library
# 'demo_ftnlib.cpp,' which contains Fortran-callable functions that
# are implemented with C++ calls to Cantera.

# To build program 'demo', simply type 'make', or 'make -f <this
# file>' if this file is named something other than 'Makefile.'

# Once you have verified that the demo runs, edit this file to replace
# object file 'demo.o' with your own object file or files. You may
# continue to use 'demo_ftnlib' if it serves your needs, or else
# replace it with a different interface library.


#------------------------ edit this block
---------------------------------

# the name of the executable program to be created
PROG_NAME = demo

# the object files to be linked together.
OBJS = $(PROG_NAME).o demo_ftnlib.o

# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = -L/usr/lib -lgfortran


#---------------------------------------------------------------------------
# You probably don't need to edit anything below.


# the Fortran compiler
FORT = gfortran

# Fortran compile flags
FORT_FLAGS = -O3

# Fortran libraries
FORT_LIBS =

# the C++ compiler
CXX = g++

# C++ compile flags
CXX_FLAGS = -O3 -Wall

# external libraries
EXT_LIBS = -luser -loneD -lzeroD -lcaThermo -ltransport -lcantera -
lsundials_cvodes -lsundials_nvecserial -lctlapack -lctblas -lctmath -
ltpx -lctf2c -lconverters -lctcxx

# the directory where the Cantera libraries are located
CANTERA_LIBDIR=/usr/local/cantera/lib

# the directory where Cantera include files may be found.
CANTERA_INCDIR=/usr/local/cantera/include

# flags passed to the C++ compiler/linker for the linking step
LCXXFLAGS = -L$(CANTERA_LIBDIR) -L/root/my-applications/Cantera/
cantera-1.7.0/build/lib/i686-pc-linux-gnu -L/usr/local/lib

# how to compile C++ source files to object files
.cpp.o:
$(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS) -L/usr/lib -lgfortran

# how to compile Fortran source files to object files
.f.o:
$(FORT) -c $< $(FORT_FLAGS) -L/usr/lib -lgfortran

PROGRAM = $(PROG_NAME)$(EXE_EXT)

DEPENDS = $(OBJS:.o=.d)

all: $(PROGRAM)

$(PROGRAM): $(OBJS)
$(CXX) -v -o $(PROGRAM) $(OBJS) $(LCXXFLAGS) $(CANTERA_LIBS) $
(LINK_OPTIONS) $(EXT_LIBS) $(FORT_LIBS)

%.d:
$(CXX) -v -MM $*.cpp > $*.d

clean:
$(RM) $(OBJS) $(PROGRAM)

depends: $(DEPENDS)
cat *.d > .depends
$(RM) $(DEPENDS)

TAGS:
etags *.h *.cpp

ifeq ($(wildcard .depends), .depends)
include .depends
endif

Thomas PEDOT

unread,
Jan 22, 2010, 8:21:45 AM1/22/10
to canter...@googlegroups.com
Hi,
when you install cantera you have to specify which compiler you want ot use for F77.

In root directory, change in preconfig file the line 431 into
F77=${F77:=gfortran}
(line 151in F90=${F90:="gfortran"} if you want to use f90 with gfortran compiler)
and recompile Cantera with ./preconfig

For the "template/f77" makefile, change the line
FORT = g77
into
FORT = gfortran

then type make or make -f demo.mak (if you didnot change the name of the makefile).
I works fine for me (cantera 1.7 and 1.8beta).

Thanks a lot for Cantera! (It lacks some interfaced function but it fine :)
Have a nice week-end.

-----------------------------------------
PEDOT Thomas
PhD student
CERFACS - CFD Team
42 avenue Gaspard Coriolis
31057 Toulouse Cedex 1
(+33) (0)5.61.19.31.37
-----------------------------------------
 

2010/1/22 emil <emil.w...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Cantera User's Group" group.
To post to this group, send email to canter...@googlegroups.com.
To unsubscribe from this group, send email to cantera-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cantera-users?hl=en.


emil

unread,
Jan 22, 2010, 8:34:28 AM1/22/10
to Cantera User's Group
Hello Thomas,
thank you, you are right - I had the wrong compiler installed!
regards
emil

> 2010/1/22 emil <emil.widm...@gmail.com>

> > cantera-user...@googlegroups.com<cantera-users%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages