[f2py] g95 and f2py
Bill McLean
w.mclean at unsw.edu.au
Tue Mar 8 06:40:10 EET 2005
I have been experimenting with using the g95 compiler
(http://g95.sourceforge.net/) to build python extension modules. Add
the attached file g95fcompiler.py to the scipy_distutils and adding the
line
'g95':('g95fcompiler', 'G95FCompiler',
"G95 Compiler"),
to the fcompiler_class dictionary in fcompiler.py. Doing
f2py -c --help-fcompiler
I then get on my PC,
List of available Fortran compilers:
--fcompiler=g95 G95 Compiler (Feb 16 2005)
--fcompiler=gnu GNU Fortran Compiler (3.3.4)
--fcompiler=intel Intel Fortran Compiler for 32-bit apps (8.1)
--fcompiler=pg Portland Group Fortran Compiler (5.1-3)
Also, from the tests directory of the f2py distribution, doing
python run_all.py --fcompiler=g95 --quiet
I find that all f77 and f90 test are ok, except that the "mixed" source
files
foo.f foo_fixed.f90 foo_free.f90
are not found.
---------------------------------------------------------------------
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