[f2py] g95 and f2py
Bill McLean
w.mclean at unsw.edu.au
Wed Mar 9 05:37:43 EET 2005
It is possible to make f2py work with the g95 compiler
(http://g95.sourceforge.net/). In your scipy_distutils directory, add
the attached file g95fcompiler.py and edit fcompiler.py by adding
the line
'g95':('g95fcompiler', 'G95FCompiler',
"G95 Compiler"),
to the fcompiler_class dictionary. Doing
f2py -c --help-fcompiler
you should get something like
List of available Fortran compilers:
--fcompiler=g95 G95 Compiler (Feb 16 2005)
--fcompiler=gnu GNU Fortran Compiler (3.3.4)
assuming, of course, that you have installed g95. (Since g95 does not have
a version number, the date of the current binary is used.)
>From the tests directory of the f2py distribution, do
python run_all.py --fcompiler=g95 --quiet
to run the test programs. They all worked for me, except that the
files
foo.f foo_fixed.f90 foo_free.f90
seem to be missing.
---------------------------------------------------------------------
Dr. William McLean tel: +61 2 9385 7045
School of Mathematics fax: +61 2 9385 7123
The University of New South Wales Sydney 2052
email: w.mclean at unsw.edu.au
AUSTRALIA CRICOS Code for UNSW: 00098G
Associate Editor, The ANZIAM Journal.
----------------------------------------------------------------------
-------------- next part --------------
# http://g95.sourceforge.net/
import os
import sys
from cpuinfo import cpu
from fcompiler import FCompiler
class G95FCompiler(FCompiler):
compiler_type = 'g95'
version_pattern = r'.*\(experimental\) \(g95!\) (?P<version>.*)\).*'
executables = {
'version_cmd' : ["g95", "--version"],
'compiler_f77' : ["g95"],
'compiler_fix' : ["g95", "-ffixed-form"],
'compiler_f90' : ["g95"],
'linker_so' : ["g95","-shared"],
'archiver' : ["ar", "-cr"],
'ranlib' : ["ranlib"]
}
pic_flags = ['-fpic']
module_dir_switch = '-fmod='
module_include_switch = '-I'
def get_flags(self):
return ['-fno-second-underscore']
def get_flags_opt(self):
return ['-O']
def get_flags_debug(self):
return ['-g']
if __name__ == '__main__':
from distutils import log
log.set_verbosity(2)
from fcompiler import new_fcompiler
compiler = new_fcompiler(compiler='g95')
compiler.customize()
print compiler.get_version()
More information about the f2py-users
mailing list