Error while running cantera program in fortran

648 views
Skip to first unread message

Amrinder Singh

unread,
Jan 8, 2013, 4:44:01 PM1/8/13
to canter...@googlegroups.com
I am trying to run a simple cantera program in fortran but getting error. 

Errors:

ex.f90(3): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [CANTERA]
use cantera

ex.f90(4): error #6457: This derived type name has not been declared.   [MIXTURE_T]
type(mixture_t) mix

Command I am using to run program:

ifort -o program_name  program_name.f90 

Program
use cantera
type(mixture_t) mix
character*10 elnames(5), spnames(53)
character*20 rxn
mix = GRIMech30()
write(*,*) nElements(mix), nSpecies(mix), nReactions(mix)
call getElementNames(mix, elnames)
write(*,*) ’elements: ’
write(*,*) (elnames(m),m=1,nElements(mix))
call getSpeciesNames(mix, spnames)
write(*,*) ’species: ’
write(*,*) (spnames(k),k=1,nSpecies(mix))
write(*,*) ’first 10 reactions:’
do i = 1,10
call getReactionString(mix, i, rxn)
write(*,*) rxn
end do

I dont know how to inlude path. Kindly help me 

thanks 
Amrinder Singh 

Amrinder Singh

unread,
Jan 9, 2013, 10:49:58 AM1/9/13
to canter...@googlegroups.com
Hello 

After doing some research i found out that i m missing catera.mod but do not know why, 
Does cantera.mod should have been created while installing cantera ? if yes why it did not happen?

Regards
Amrinder Singh


Amrinder Singh

unread,
Jan 9, 2013, 12:48:58 PM1/9/13
to canter...@googlegroups.com
Hello 

 After doing some more research i found that there are fortran files in canter/src/fortran which can be compiled to make mod file using 

ifort -c cantera_xml.f90 
ifort -c fctxml_interface.f90 
ifort -c cantera_xml.f90 
ifort -c fct_interface.f90 
ifort -c cantera_thermo.f90 
ifort -c cantera_transport.f90 
ifort -c cantera_kinetics.f90 
ifort -c cantera_iface.f90 
ifort -c cantera_funcs.f90 
ifort -c cantera.f90 

now I am left with these errors 

ex.f90(4): error #6457: This derived type name has not been declared.   [MIXTURE_T]
type(mixture_t) mix

ex.f90(8): error #6284: There is no matching specific function for this generic function reference.   [NELEMENTS]
write(*,*) nElements(mix), nSpecies(mix), nReactions(mix)

ex.f90(8): error #6284: There is no matching specific function for this generic function reference.   [NSPECIES]
write(*,*) nElements(mix), nSpecies(mix), nReactions(mix)

ex.f90(8): error #6284: There is no matching specific function for this generic function reference.   [NREACTIONS]
write(*,*) nElements(mix), nSpecies(mix), nReactions(mix)

ex.f90(11): error #6284: There is no matching specific function for this generic function reference.   [NELEMENTS]
write(*,*) (elnames(m),m=1,nElements(mix))
---------------------------^
ex.f90(14): error #6284: There is no matching specific function for this generic function reference.   [NSPECIES]
write(*,*) (spnames(k),k=1,nSpecies(mix))

ex.f90(17): error #6285: There is no matching specific subroutine for this generic subroutine call.   [GETREACTIONSTRING]
call getReactionString(mix, i, rxn)

compilation aborted for ex.f90 (code 1)

i dont know what this means...

regards
Amrinder Singh

Ray Speth

unread,
Jan 14, 2013, 10:15:41 AM1/14/13
to canter...@googlegroups.com
Amrinder,

The ".mod" files for Cantera should be automatically built if you compile Cantera with the option for the Fortran 90 interface (either use the f90_interface=y option to SCons, or it should be built automatically if SCons can find a working F90 compiler). When you install Cantera, the ".mod" files will be copied to the "include" directory, e.g. /usr/local/include/cantera.

The errors you are getting now is because the functions you are calling do not exist in the current Fortran 90 interface. I'm not sure where you got those function names (I've seen them referenced in the obsolete documentation for Cantera 1.2, but nothing more recent), but I would suggest looking at the sample Fortran 90 program in the samples/f90 directory and at the source code in the src/fortran directory to see what functions are actually available. 

I would also note that the F90 interface is not very well maintained, and is missing a lot of things that are present in the C++ and Python interfaces to Cantera. If you can use either of those instead, you will probably be much better off.

Regards,
Ray

Amrinder Singh

unread,
Jan 14, 2013, 3:12:04 PM1/14/13
to canter...@googlegroups.com
Hello Ray

   You are right about cantera1.2, this is from where i was trying to run the fortran cantera.  Actually i have CFD simulation software Kiva for which coding is written in fortran thats why i was intersted in fortran module.

 I do have module files in /usr/local/inlcude/cantera 
 and i tried running demo.f90 using this command gfortran demo.f90 -o demo -fintrinsic-modules-path /usr/local/include/cantera  and gave the folowwing errors .

emo.f90:(.text+0x1c5): undefined reference to `__cantera_thermo_MOD_ctthermo_temperature'
demo.f90:(.text+0x208): undefined reference to `__cantera_thermo_MOD_ctthermo_pressure'
demo.f90:(.text+0x24b): undefined reference to `__cantera_thermo_MOD_ctthermo_density'
demo.f90:(.text+0x28e): undefined reference to `__cantera_thermo_MOD_ctthermo_enthalpy_mole'
demo.f90:(.text+0x2d1): undefined reference to `__cantera_thermo_MOD_ctthermo_entropy_mole'
demo.f90:(.text+0x314): undefined reference to `__cantera_thermo_MOD_ctthermo_cp_mole'
demo.f90:(.text+0x370): undefined reference to `__cantera_thermo_MOD_ctthermo_equilibrate'
demo.f90:(.text+0x42c): undefined reference to `__cantera_thermo_MOD_ctthermo_temperature'
demo.f90:(.text+0x46f): undefined reference to `__cantera_thermo_MOD_ctthermo_pressure'
demo.f90:(.text+0x4b2): undefined reference to `__cantera_thermo_MOD_ctthermo_density'
demo.f90:(.text+0x4f5): undefined reference to `__cantera_thermo_MOD_ctthermo_enthalpy_mole'
demo.f90:(.text+0x538): undefined reference to `__cantera_thermo_MOD_ctthermo_entropy_mole'
demo.f90:(.text+0x57b): undefined reference to `__cantera_thermo_MOD_ctthermo_cp_mole'
demo.f90:(.text+0x5cd): undefined reference to `__cantera_kinetics_MOD_ctkin_nreactions'
demo.f90:(.text+0x5e6): undefined reference to `__cantera_kinetics_MOD_ctkin_getfwdratesofprogress'
demo.f90:(.text+0x5fc): undefined reference to `__cantera_kinetics_MOD_ctkin_getrevratesofprogress'
demo.f90:(.text+0x612): undefined reference to `__cantera_kinetics_MOD_ctkin_getnetratesofprogress'
demo.f90:(.text+0x652): undefined reference to `__cantera_kinetics_MOD_ctkin_getreactionstring'
demo.f90:(.text+0x799): undefined reference to `__cantera_transport_MOD_ctrans_viscosity'
demo.f90:(.text+0x7bb): undefined reference to `__cantera_transport_MOD_ctrans_thermalconductivity'
demo.f90:(.text+0x7e4): undefined reference to `__cantera_transport_MOD_ctrans_getmixdiffcoeffs'
demo.f90:(.text+0x8e5): undefined reference to `__cantera_thermo_MOD_ctthermo_nspecies'
demo.f90:(.text+0x928): undefined reference to `__cantera_thermo_MOD_ctthermo_getspeciesname'
/tmp/cc2UQ5PP.o: In function `MAIN__':
demo.f90:(.text+0xb24): undefined reference to `__cantera_funcs_MOD_ctfunc_importphase'
demo.f90:(.text+0xb89): undefined reference to `__cantera_thermo_MOD_ctstring_setstate_tpx'
demo.f90:(.text+0xb95): undefined reference to `__cantera_thermo_MOD_ctthermo_nspecies'
demo.f90:(.text+0xba4): undefined reference to `__cantera_kinetics_MOD_ctkin_nreactions'
collect2: error: ld returned 1 exit status

thanks
Amrinder Singh

Kevin Holst

unread,
Jun 17, 2013, 4:48:43 PM6/17/13
to canter...@googlegroups.com
Amrinder,
 
Were you able to find a solution to your problem? I'm having a similar one...
 
Kevin

Carlos Felipe Forigua Rodriguez

unread,
Mar 25, 2014, 5:19:36 PM3/25/14
to canter...@googlegroups.com
I've installed Cantera with ifort using this guide: http://bryanwweber.com/writing/personal/2014/01/08/installing-cantera-on-ubuntu-12.04.3-from-scratch-source-with-Intel-compilers/#InstallSundials

I've also compiled the samples at the source code folder downloaded from cantera using the terminal command $ scons samples

Unfortunately, when I try to compile from Cantera's installation folder it can't even recognize the module cantera.mod. Already tested permissions. I couldn't use the makefile either in the installation folder or the cantera's source folder.

Nick Curtis

unread,
Mar 25, 2014, 6:25:34 PM3/25/14
to canter...@googlegroups.com
Hi Carlos,
As far as I know, the fortran interface on our server is working, however neither Bryan nor I have tested it extensively. 
The fact that scons can build your samples suggests that the fortran interface is working on your box as well.

Could you post the makefile you're trying to use and a log of the errors you encounter?

Nick

Carlos Felipe Forigua Rodriguez

unread,
Mar 26, 2014, 10:57:24 AM3/26/14
to canter...@googlegroups.com
I include the makefiles and scons files used by Cantera. Scons works but Make doesn't work. I'm a bit new in make and ignorant in Scons. If you can recommend me please some resource to understand the compiling process of Cantera i'll be very grateful.

Thank you
Build-files.tar.gz

Nick Curtis

unread,
Mar 26, 2014, 12:26:00 PM3/26/14
to canter...@googlegroups.com
Hi Carlos,
I was referring to the make files you were using to compile your external program, but I see that we may be talking about different things.
Are you having issues compiling Cantera itself?  Or are you having trouble linking Cantera to an external program?

Just a quick rundown on SCons:
SCons is a python based build system that allows for (relatively) easy compilation of large programs on any platform where newish versions of python are supported.  Cantera uses SCons to build the main C++ libraries as well as the various interfaces (Python, fortran, matlab, etc.) that can be used to call Cantera methods / classes.

Following Bryan's guide, the only SCons commands you will likely ever need to run are:
scons build
scons test
and
[sudo] scons install (sudo may or may not be necessary depending where you're installing Cantera to)

These commands are run in the main Cantera build directory (the one where your .conf lives, as well as the main SConstruct file)

Once Cantera is build and installed, you most likely will not need to worry about using SCons to build any of your own programs, as it is generally far simpler to create a make file (or other specialized build procedure, e.g. cmake/visual studio project) that supports the platform you are working on.

Best,
Nick

Carlos Felipe Forigua Rodriguez

unread,
Mar 31, 2014, 4:23:14 PM3/31/14
to canter...@googlegroups.com
Yes, the build works with the fortran examples too. So, when i compile ¿should i only add to my makefile the *.mod files generated by cantera?

-Sorry for the late response, i was learning some of cantera awesome solutions.


--
You received this message because you are subscribed to a topic in the Google Groups "Cantera User's Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/bpEYSJ0LIUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at http://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/d/optout.

Carlos Felipe Forigua Rodriguez

unread,
Apr 7, 2014, 12:12:11 PM4/7/14
to canter...@googlegroups.com
Hey, I think I've found why Cantera examples didn't compile in the first place using ifort in ubuntu. The auto generated Makefile has a couple of errors. In attachments "orig.Makefile" is the original auto-generated file and "Makefile" is the version that works an my system. You could make a diff to recall the differences. I remember that it was an space an a change in the compiler parameter -module or something.

I took this makefiles generated from Cantera from the installation dir:  /home/carlos/.local/share/cantera/samples/f90

¿is this a real error? ¿where and how could I report this?

Thank you very much to put me in the right track.
To unsubscribe from this group and all its topics, send an email to cantera-users+unsubscribe@googlegroups.com.
makefiles.zip

Nick Curtis

unread,
Apr 7, 2014, 1:51:26 PM4/7/14
to canter...@googlegroups.com
Hi Carlos,
The space between $(FORTRANMODDIRPREFIX) and $(F90MODDIR) does look like it could be an error, you can report it on the bug tracker

Nick
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.

Nick Curtis

unread,
Apr 7, 2014, 1:51:59 PM4/7/14
to canter...@googlegroups.com
That should read "lack of a space between ..."

Ray Speth

unread,
Apr 7, 2014, 4:24:29 PM4/7/14
to canter...@googlegroups.com
Hi Carlos,

The lack of a space between $(FORTRANMODDIRPREFIX) and $(F90MODDIR) is intentional. For other Fortran compilers, there is no space between the flag for setting the module directory and the directory name itself, e.g. gfortran uses "-Jsome/path", which mirrors the "-I" flag for specifying include directories. For ifort, this variable is set to "-module ", which shows up in the Makefile with the trailing space. The only guess I have is that you've opened this file in an editor that strips trailing whitespace, which is what's causing the problem here.

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages