octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fortran 90 support in mkoctfile


From: Alexander Barth
Subject: Re: Fortran 90 support in mkoctfile
Date: Fri, 25 Aug 2006 16:05:45 -0400
User-agent: Thunderbird 1.5.0.2 (X11/20060501)

John W. Eaton wrote:
> On 25-Aug-2006, Alexander Barth wrote:
> 
> | It is already possible to compile Fortran 90 programs with mkoctfile and to 
> call those subroutines
> | (with a C++ wrapper) from Octave if octave is compiled with a Fortran 90 
> compiler (like gfortran or
> | g95). The only issue is the file extension. mkoctfile recognizes only the 
> .f and .F extensions. This
> | means that the Fortran 90 source has to be written in fixed form (but all 
> Fortran 90  features are
> | also available in fixed format). The free form sources with the extensions 
> .f90 or .F90 are not
> | recognized as Fortran files.
> | 
> | But since fixed form source is an obsolescent feature in Fortran 95, it is 
> preferable to write new
> | code in free form.
> | 
> | On a separate issue, it seems that include (-I) and macro definition (-D) 
> options are not passed to
> | the Fortran compiler. I don't know if there is any particular reason for 
> this, but the use of
> | Fortran programs with octave would be greatly simplified if those options 
> are taken into account.
> | 
> | The modification of mkoctfile.in to handle the free form Fortran code and 
> the -I and -D options are
> | (quite) minor. Attached is the patch for both mentioned issues for octave 
> 2.9.8.
> 
> I think I omitted the -I and -D options because standard Fortran 77
> doesn't have a preprocessor or include files and I would have guessed
> there is no convention for these options in Fortran compilers.
> 
> Will using the same options for Fortran and C/C++ cause problems?
In general, the include file names for Fortran and C programs are different, 
for example mpi.h for C
and mpif.h for Fortran. I don't think there is a risk of confusion with the 
include path.

For macro definition, there can be problems in some rare cases when the macro 
should be defined in C
but not in Fortran. But I think, that in most cases the expected behavior of:

mkoctfile -DDEBUG cprog.cc fprog.F

is

g++ -c -DDEBUG cprog.cc
gfortran -c -DDEBUG fprog.F


> 
> I suppose if it does, one could use separate mkoctfile invocations for
> C/C++ files and Fortran files, so I checked in the changes.


I agree. If a makefile is used, separate mkoctfile invocation will probably be 
the most common case
anyway.

Thanks
Alex




-- 
_______________________________________________________________

  Alexander Barth

  Ocean Circulation Group
  University of South Florida
  College of Marine Science
  140 Seventh Avenue South
  St. Petersburg, Florida  33701
  USA

  Phone: +1-727-553-3508     FAX:   +1-727-553-1189

_______________________________________________________________


reply via email to

[Prev in Thread] Current Thread [Next in Thread]