octave-maintainers
[Top][All Lists]
Advanced

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

Fortran 90 support in mkoctfile


From: Alexander Barth
Subject: Fortran 90 support in mkoctfile
Date: Fri, 25 Aug 2006 12:29:09 -0400
User-agent: Thunderbird 1.5.0.2 (X11/20060501)

Hi all,

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.

Cheers,

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

_______________________________________________________________
*** mkoctfile.in.orig   2006-08-25 11:41:05.000000000 -0400
--- mkoctfile.in        2006-08-25 12:00:08.000000000 -0400
***************
*** 112,118 ****
        file=$1
        ccfiles="$ccfiles $file"
      ;;
!     *.f | *.F)
        file=$1
        f77files="$f77files $file"
      ;;
--- 112,118 ----
        file=$1
        ccfiles="$ccfiles $file"
      ;;
!     *.f | *.F | *.f90 | *.F90)
        file=$1
        f77files="$f77files $file"
      ;;
***************
*** 195,202 ****
                              .cc   C++ source
                              .C    C++ source
                              .cpp  C++ source
!                             .f    Fortran source
!                             .F    Fortran source
                              .o    object file
  
  EOF
--- 195,204 ----
                              .cc   C++ source
                              .C    C++ source
                              .cpp  C++ source
!                             .f    Fortran source (fixed form)
!                             .F    Fortran source (fixed form)
!                             .f90  Fortran source (free form)
!                             .F90  Fortran source (free form)
                              .o    object file
  
  EOF
***************
*** 344,349 ****
--- 346,357 ----
        *.F)
          b=`echo $f | $SED 's,\.F$,,'`
        ;;
+       *.f90)
+         b=`echo $f | $SED 's,\.f90$,,'`
+       ;;
+       *.F90)
+         b=`echo $f | $SED 's,\.F90$,,'`
+       ;;
      esac
      if [ -n "$F77" ]; then
        if [ -n "$outputfile" ]; then
***************
*** 356,362 ****
          o=$b.o
        fi
        objfiles="$objfiles $o"
!       cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $pass_on_options $f -o $o"
        $dbg $cmd
        eval $cmd
      elif [ -n "$F2C" ]; then
--- 364,370 ----
          o=$b.o
        fi
        objfiles="$objfiles $o"
!       cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f 
-o $o"
        $dbg $cmd
        eval $cmd
      elif [ -n "$F2C" ]; then

reply via email to

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