diff options
-rw-r--r-- | doc/source/f2py/distutils.rst | 6 | ||||
-rw-r--r-- | numpy/f2py/__main__.py | 3 | ||||
-rw-r--r-- | numpy/f2py/auxfuncs.py | 6 | ||||
-rw-r--r-- | numpy/f2py/capi_maps.py | 30 | ||||
-rwxr-xr-x | numpy/f2py/crackfortran.py | 4 | ||||
-rwxr-xr-x | numpy/f2py/f2py2e.py | 2 | ||||
-rw-r--r-- | numpy/f2py/setup.py | 7 | ||||
-rw-r--r-- | numpy/f2py/src/test/Makefile | 96 | ||||
-rw-r--r-- | numpy/f2py/src/test/bar.f | 11 | ||||
-rw-r--r-- | numpy/f2py/src/test/foo.f | 11 | ||||
-rw-r--r-- | numpy/f2py/src/test/foo90.f90 | 13 | ||||
-rw-r--r-- | numpy/f2py/src/test/foomodule.c | 150 | ||||
-rw-r--r-- | numpy/f2py/src/test/wrap.f | 70 | ||||
-rw-r--r-- | tools/linter.py | 1 |
14 files changed, 29 insertions, 381 deletions
diff --git a/doc/source/f2py/distutils.rst b/doc/source/f2py/distutils.rst index 2c3c2184f..575dacdff 100644 --- a/doc/source/f2py/distutils.rst +++ b/doc/source/f2py/distutils.rst @@ -66,12 +66,12 @@ Extensions to ``distutils`` * When building Python packages containing Fortran sources, one can choose different Fortran compilers by using the ``build_ext`` command option ``--fcompiler=<Vendor>``. Here ``<Vendor>`` can be one of the - following names:: + following names (on ``linux`` systems):: - absoft sun mips intel intelv intele intelev nag compaq compaqv gnu vast pg hpux + absoft compaq fujitsu g95 gnu gnu95 intel intele intelem lahey nag nagfor nv pathf95 pg vast See ``numpy_distutils/fcompiler.py`` for an up-to-date list of - supported compilers or run + supported compilers for different platforms, or run :: diff --git a/numpy/f2py/__main__.py b/numpy/f2py/__main__.py index c6115070e..936a753a2 100644 --- a/numpy/f2py/__main__.py +++ b/numpy/f2py/__main__.py @@ -1,4 +1,5 @@ -# See http://cens.ioc.ee/projects/f2py2e/ +# See: +# https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e from numpy.f2py.f2py2e import main main() diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index 5250fea84..c8f2067c9 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -347,9 +347,9 @@ def iscomplexfunction_warn(rout): ************************************************************** Warning: code with a function returning complex value may not work correctly with your Fortran compiler. - Run the following test before using it in your applications: - $(f2py install dir)/test-site/{b/runme_scalar,e/runme} - When using GNU gcc/g77 compilers, codes should work correctly. + When using GNU gcc/g77 compilers, codes should work + correctly for callbacks with: + f2py -c -DF2PY_CB_RETURNCOMPLEX **************************************************************\n""") return 1 return 0 diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index fe0d4a52b..655cfd768 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -48,7 +48,7 @@ c2py_map = {'double': 'float', 'unsigned_char': 'int', # forced casting 'short': 'int', # forced casting 'unsigned_short': 'int', # forced casting - 'int': 'int', # (forced casting) + 'int': 'int', # forced casting 'long': 'int', 'long_long': 'long', 'unsigned': 'int', # forced casting @@ -95,8 +95,8 @@ if using_newcore: 'complex_double': 'NPY_CDOUBLE', 'complex_long_double': 'NPY_CDOUBLE', 'string':'NPY_STRING' - } + c2pycode_map = {'double': 'd', 'float': 'f', 'long_double': 'd', # forced casting @@ -114,6 +114,7 @@ c2pycode_map = {'double': 'd', 'complex_long_double': 'D', # forced casting 'string': 'c' } + if using_newcore: c2pycode_map = {'double': 'd', 'float': 'f', @@ -133,6 +134,7 @@ if using_newcore: 'complex_double': 'D', 'complex_long_double': 'G', 'string': 'S'} + c2buildvalue_map = {'double': 'd', 'float': 'f', 'char': 'b', @@ -146,10 +148,6 @@ c2buildvalue_map = {'double': 'd', 'complex_long_double': 'N', 'string': 'y'} -if using_newcore: - # c2buildvalue_map=??? - pass - f2cmap_all = {'real': {'': 'float', '4': 'float', '8': 'double', '12': 'long_double', '16': 'long_double'}, 'integer': {'': 'int', '1': 'signed_char', '2': 'short', @@ -185,22 +183,22 @@ def load_f2cmap_file(f2cmap_file): return # User defined additions to f2cmap_all. - # f2cmap_file must contain a dictionary of dictionaries, only. For + # f2cmap_file must contain a dictionary of dictionaries, only. For # example, {'real':{'low':'float'}} means that Fortran 'real(low)' is - # interpreted as C 'float'. This feature is useful for F90/95 users if - # they use PARAMETERSs in type specifications. + # interpreted as C 'float'. This feature is useful for F90/95 users if + # they use PARAMETERS in type specifications. try: outmess('Reading f2cmap from {!r} ...\n'.format(f2cmap_file)) with open(f2cmap_file, 'r') as f: d = eval(f.read(), {}, {}) - for k, d1 in list(d.items()): - for k1 in list(d1.keys()): + for k, d1 in d.items(): + for k1 in d1.keys(): d1[k1.lower()] = d1[k1] d[k.lower()] = d[k] - for k in list(d.keys()): + for k in d.keys(): if k not in f2cmap_all: f2cmap_all[k] = {} - for k1 in list(d[k].keys()): + for k1 in d[k].keys(): if d[k][k1] in c2py_map: if k1 in f2cmap_all[k]: outmess( @@ -279,11 +277,9 @@ def getctype(var): errmess('getctype: "%s(kind=%s)" is mapped to C "%s" (to override define dict(%s = dict(%s="<C typespec>")) in %s/.f2py_f2cmap file).\n' % (typespec, var['kindselector']['kind'], ctype, typespec, var['kindselector']['kind'], os.getcwd())) - else: if not isexternal(var): - errmess( - 'getctype: No C-type found in "%s", assuming void.\n' % var) + errmess('getctype: No C-type found in "%s", assuming void.\n' % var) return ctype @@ -523,7 +519,7 @@ def sign2map(a, var): if f(var): intent_flags.append('F2PY_%s' % s) if intent_flags: - # XXX: Evaluate intent_flags here. + # TODO: Evaluate intent_flags here. ret['intent'] = '|'.join(intent_flags) else: ret['intent'] = 'F2PY_INTENT_IN' diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index c3ec792e3..c05fe8af6 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -245,7 +245,6 @@ for c in "abcdefghopqrstuvwxyz$_": defaultimplicitrules[c] = {'typespec': 'real'} for c in "ijklmn": defaultimplicitrules[c] = {'typespec': 'integer'} -del c badnames = {} invbadnames = {} for n in ['int', 'double', 'float', 'char', 'short', 'long', 'void', 'case', 'while', @@ -3357,7 +3356,8 @@ def crack2fortran(block): """ footer = """ ! This file was auto-generated with f2py (version:%s). -! See http://cens.ioc.ee/projects/f2py2e/ +! See: +! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e """ % (f2py_version) return header + pyf + footer diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 2e267cc6c..1256f5330 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -168,7 +168,7 @@ numpy Version: {numpy_version} Requires: Python 3.5 or higher. License: NumPy license (see LICENSE.txt in the NumPy source code) Copyright 1999 - 2011 Pearu Peterson all rights reserved. -http://cens.ioc.ee/projects/f2py2e/""" +https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e""" def scaninputline(inputline): diff --git a/numpy/f2py/setup.py b/numpy/f2py/setup.py index 0a35db477..31997fa10 100644 --- a/numpy/f2py/setup.py +++ b/numpy/f2py/setup.py @@ -39,8 +39,8 @@ if __name__ == "__main__": config = configuration(top_path='') config = config.todict() - config['download_url'] = "http://cens.ioc.ee/projects/f2py2e/2.x"\ - "/F2PY-2-latest.tar.gz" + config['download_url'] = "https://web.archive.org/web/20140822061353/"\ + "http://cens.ioc.ee/projects/f2py2e/2.x/F2PY-2-latest.tar.gz" config['classifiers'] = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -68,6 +68,7 @@ command line tool (f2py) for generating Python C/API modules for wrapping Fortran 77/90/95 subroutines, accessing common blocks from Python, and calling Python functions from Fortran (call-backs). Interfacing subroutines/data from Fortran 90/95 modules is supported.""", - url="http://cens.ioc.ee/projects/f2py2e/", + url="https://web.archive.org/web/20140822061353/"\ + "http://cens.ioc.ee/projects/f2py2e/", keywords=['Fortran', 'f2py'], **config) diff --git a/numpy/f2py/src/test/Makefile b/numpy/f2py/src/test/Makefile deleted file mode 100644 index 0f8869f72..000000000 --- a/numpy/f2py/src/test/Makefile +++ /dev/null @@ -1,96 +0,0 @@ -# -*- makefile -*- -# File: Makefile-foo -# Usage: -# make -f Makefile-foo [MODE=opt|debug] -# Notes: -# 1) You must use GNU make; try `gmake ..' if `make' fails. -# 2) This file is auto-generated with f2py (version 2.264). -# f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, -# written by Pearu Peterson <pearu@ioc.ee>. -# See http://cens.ioc.ee/projects/f2py2e/ -# Generation date: Wed Sep 13 16:22:55 2000 -# $Revision: 1.2 $ -# $Date: 2000/09/17 16:10:27 $ - -# Recommendation notes produced by f2py2e/buildmakefile.py: -# *** - -PYINC = -I/numeric/include/python1.5/Numeric -I/numeric/include/python1.5 -INCLUDES = -I.. -LIBS = -L$(shell gcc -v 2>&1 | grep specs | sed -e 's/Reading specs from //g' | sed -e 's/\/specs//g') -lg2c -LIBS=-L$$ABSOFT/lib -lfio -lf77math -lf90math -LIBS=-L/numeric/bin -lvast90 -L/usr/lib/gcc-lib/i586-mandrake-linux/2.95.2 -lg2c - -# Wrapper generator: -F2PY = /home/pearu/bin/f2py-cvs - -# Fortran compiler: Absoft f95 -FC = f95 -FC = f90 -FOPT = -FDEBUG = -FFLAGS = -B108 -YCFRL=1 -YCOM_NAMES=LCS -YCOM_PFX -YCOM_SFX=_ -YEXT_PFX -YEXT_NAMES=LCS -FFLAGS = -# C compiler: cc ('gcc 2.x.x' 2.95.2) -CC = cc -COPT = -CDEBUG = -CFLAGS = -fpic - -# Linker: ld ('GNU ld' 2.9.5) -LD = ld -LDFLAGS = -shared -s -SO = .so - -ifeq '$(MODE)' 'debug' -FFLAGS += $(FDEBUG) -CFLAGS += $(CDEBUG) -endif -ifeq '$(MODE)' 'opt' -FFLAGS += $(FOPT) -CFLAGS += $(COPT) -endif -FFLAGS += $(INCLUDES) -CFLAGS += $(PYINC) $(INCLUDES) - -SRCC = ../fortranobject.c -SRCF = mod.f90 bar.f foo90.f90 wrap.f -SRCS = $(SRCC) $(SRCF) -OBJC = $(filter %.o,$(SRCC:.c=.o) $(SRCC:.cc=.o) $(SRCC:.C=.o)) -OBJF = $(filter %.o,$(SRCF:.f90=.o) $(SRCF:.f=.o) $(SRCF:.F=.o) $(SRCF:.for=.o)) -OBJS = $(OBJC) $(OBJF) - -INSTALLNAME = f2py2e-apps -INSTALLDIRECTORY = /numeric/lib/python1.5/site-packages/$(INSTALLNAME) -INSTALLDIR = install -d -c -INSTALLEXEC = install -m 755 -c - -all: foo - -foo: foomodule$(SO) -foomodule$(SO) : foomodule.o $(OBJS) - $(LD) $(LDFLAGS) -o $@ $< $(OBJS) $(LIBS) - -foomodule.o: foomodule.c - - -$(OBJS) : $(SRCS) -%.o : %.f ; $(FC) -c $(FFLAGS) $< -%.o : %.f90 ; $(FC) -c $(FFLAGS) $< - -test: foomodule$(SO) - python -c 'import foo;print foo.__doc__' -install: foomodule$(SO) - $(INSTALLDIR) $(INSTALLDIRECTORY) - $(INSTALLEXEC) foomodule$(SO) $(INSTALLDIRECTORY) - cd $(INSTALLDIRECTORY) && echo "$(INSTALLNAME)" > ../$(INSTALLNAME).pth - -.PHONY: clean distclean debug test install foo -debug: - echo "OBJS=$(OBJS)" - echo "SRCS=$(SRCS)" -clean: - $(RM) *.o *.mod core foomodule.{dvi,log} $(OBJS) -distclean: clean - $(RM) *.so *.sl foomodule.{tex,so} - $(RM) .f2py_get_compiler_* diff --git a/numpy/f2py/src/test/bar.f b/numpy/f2py/src/test/bar.f deleted file mode 100644 index 5354ceaf9..000000000 --- a/numpy/f2py/src/test/bar.f +++ /dev/null @@ -1,11 +0,0 @@ - subroutine bar() - integer a - real*8 b,c(3) - common /foodata/ a,b,c - a = 4 - b = 6.7 - c(2) = 3.0 - write(*,*) "bar:a=",a - write(*,*) "bar:b=",b - write(*,*) "bar:c=",c - end diff --git a/numpy/f2py/src/test/foo.f b/numpy/f2py/src/test/foo.f deleted file mode 100644 index 5354ceaf9..000000000 --- a/numpy/f2py/src/test/foo.f +++ /dev/null @@ -1,11 +0,0 @@ - subroutine bar() - integer a - real*8 b,c(3) - common /foodata/ a,b,c - a = 4 - b = 6.7 - c(2) = 3.0 - write(*,*) "bar:a=",a - write(*,*) "bar:b=",b - write(*,*) "bar:c=",c - end diff --git a/numpy/f2py/src/test/foo90.f90 b/numpy/f2py/src/test/foo90.f90 deleted file mode 100644 index dbca7e95b..000000000 --- a/numpy/f2py/src/test/foo90.f90 +++ /dev/null @@ -1,13 +0,0 @@ -subroutine foo() - integer a - real*8 b,c(3) - common /foodata/ a,b,c - print*, " F: in foo" - a = 5 - b = 6.3 - c(2) = 9.1 -end subroutine foo - - - - diff --git a/numpy/f2py/src/test/foomodule.c b/numpy/f2py/src/test/foomodule.c deleted file mode 100644 index 00a48f4c0..000000000 --- a/numpy/f2py/src/test/foomodule.c +++ /dev/null @@ -1,150 +0,0 @@ -/* File: foomodule.c - * Example of FortranObject usage. See also wrap.f foo.f foo90.f90. - * Author: Pearu Peterson <pearu@ioc.ee>. - * http://cens.ioc.ee/projects/f2py2e/ - * $Revision: 1.2 $ - * $Date: 2000/09/17 16:10:27 $ - */ -#ifdef __cplusplus -extern "C" { -#endif - -#define PY_SSIZE_T_CLEAN -#include <Python.h> - -#include "fortranobject.h" - -static PyObject *foo_error; - -#if defined(NO_APPEND_FORTRAN) -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) F -#else -#define F_FUNC(f,F) f -#endif -#else -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) F##_ -#else -#define F_FUNC(f,F) f##_ -#endif -#endif - -/************* foo_bar *************/ -static char doc_foo_bar[] = "\ -Function signature:\n\ - bar()\n\ -"; -static PyObject *foo_bar(PyObject *capi_self, PyObject *capi_args, - PyObject *capi_keywds, void (*f2py_func)()) { - PyObject *capi_buildvalue = NULL; - static char *capi_kwlist[] = {NULL}; - if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ - "|:foo.bar",\ - capi_kwlist)) - goto capi_fail; - (*f2py_func)(); - capi_buildvalue = Py_BuildValue(""); - capi_fail: - return capi_buildvalue; -} -/************ mod_init **************/ -static PyObject *mod_init(PyObject *capi_self, PyObject *capi_args, - PyObject *capi_keywds, void (*f2py_func)()) { - PyObject *capi_buildvalue = NULL; - static char *capi_kwlist[] = {NULL}; - if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ - "|:mod.init",\ - capi_kwlist)) - goto capi_fail; - (*f2py_func)(); - capi_buildvalue = Py_BuildValue(""); - capi_fail: - return capi_buildvalue; -} - -/* F90 module */ -static FortranDataDef f2py_mod_def[] = { - {"a",0, {}, NPY_INT}, - {"b",0, {}, NPY_DOUBLE}, - {"c",1, {3}, NPY_DOUBLE}, - {"d",1, {-1}, NPY_DOUBLE}, - {"init",-1,{},0,NULL,(void *)mod_init}, - {NULL} -}; -static void f2py_setup_mod(char *a,char *b,char *c,void (*d)(),char *init) { - f2py_mod_def[0].data = a; - f2py_mod_def[1].data = b; - f2py_mod_def[2].data = c; - f2py_mod_def[3].func = d; - f2py_mod_def[4].data = init; -} -extern void F_FUNC(f2pyinitmod,F2PYINITMOD)(); - static void f2py_init_mod() { - F_FUNC(f2pyinitmod,F2PYINITMOD)(f2py_setup_mod); - } - -/* COMMON block */ -static FortranDataDef f2py_foodata_def[] = { - {"a",0, {}, NPY_INT}, - {"b",0, {}, NPY_DOUBLE}, - {"c",1, {3}, NPY_DOUBLE}, - {NULL} -}; -static void f2py_setup_foodata(char *a,char *b,char *c) { - f2py_foodata_def[0].data = a; - f2py_foodata_def[1].data = b; - f2py_foodata_def[2].data = c; -} -extern void F_FUNC(f2pyinitfoodata,F2PYINITFOODATA)(); - static void f2py_init_foodata() { - F_FUNC(f2pyinitfoodata,F2PYINITFOODATA)(f2py_setup_foodata); - } - -/* Fortran routines (needs no initialization/setup function) */ -extern void F_FUNC(bar,BAR)(); - extern void F_FUNC(foo,FOO)(); - static FortranDataDef f2py_routines_def[] = { - {"bar",-1, {}, 0, (char *)F_FUNC(bar,BAR),(void *)foo_bar,doc_foo_bar}, - {"foo",-1, {}, 0, (char *)F_FUNC(foo,FOO),(void *)foo_bar,doc_foo_bar}, - {NULL} - }; - -static PyMethodDef foo_module_methods[] = { - /*eof method*/ - {NULL,NULL} -}; - -void initfoo() { - int i; - PyObject *m, *d, *s, *tmp; - import_array(); - - m = Py_InitModule("foo", foo_module_methods); - - d = PyModule_GetDict(m); - s = PyUnicode_FromString("This module 'foo' demonstrates the usage of fortranobject."); - PyDict_SetItemString(d, "__doc__", s); - - /* Fortran objects: */ - tmp = PyFortranObject_New(f2py_mod_def,f2py_init_mod); - PyDict_SetItemString(d, "mod", tmp); - Py_DECREF(tmp); - tmp = PyFortranObject_New(f2py_foodata_def,f2py_init_foodata); - PyDict_SetItemString(d, "foodata", tmp); - Py_DECREF(tmp); - for(i=0;f2py_routines_def[i].name!=NULL;i++) { - tmp = PyFortranObject_NewAsAttr(&f2py_routines_def[i]); - PyDict_SetItemString(d, f2py_routines_def[i].name, tmp); - Py_DECREF(tmp); - } - - Py_DECREF(s); - - if (PyErr_Occurred()) - Py_FatalError("can't initialize module foo"); -} - -#ifdef __cplusplus -} -#endif diff --git a/numpy/f2py/src/test/wrap.f b/numpy/f2py/src/test/wrap.f deleted file mode 100644 index 9414eb9f6..000000000 --- a/numpy/f2py/src/test/wrap.f +++ /dev/null @@ -1,70 +0,0 @@ - subroutine f2py_mod_get_dims(f2py_r,f2py_s,f2py_set,f2py_n) - use mod - external f2py_set - logical f2py_ns - integer f2py_s(*),f2py_r,f2py_i,f2py_j - character*(*) f2py_n - if ("d".eq.f2py_n) then - f2py_ns = .FALSE. - if (allocated(d)) then - do f2py_i=1,f2py_r - if ((size(d,f2py_r-f2py_i+1).ne.f2py_s(f2py_i)).and. - c (f2py_s(f2py_i).ge.0)) then - f2py_ns = .TRUE. - end if - end do - if (f2py_ns) then - deallocate(d) - end if - end if - if (.not.allocated(d)) then - allocate(d(f2py_s(1))) - end if - if (allocated(d)) then - do f2py_i=1,f2py_r - f2py_s(f2py_i) = size(d,f2py_r-f2py_i+1) - end do - call f2py_set(d) - end if - end if - end subroutine f2py_mod_get_dims - subroutine f2py_mod_get_dims_d(r,s,set_data) - use mod, only: d => d - external set_data - logical ns - integer s(*),r,i,j - ns = .FALSE. - if (allocated(d)) then - do i=1,r - if ((size(d,r-i+1).ne.s(i)).and.(s(i).ge.0)) then - ns = .TRUE. - end if - end do - if (ns) then - deallocate(d) - end if - end if - if (.not.allocated(d).and.(s(1).ge.1)) then - allocate(d(s(1))) - end if - if (allocated(d)) then - do i=1,r - s(i) = size(d,r-i+1) - end do - end if - call set_data(d,allocated(d)) - end subroutine f2py_mod_get_dims_d - - subroutine f2pyinitmod(setupfunc) - use mod - external setupfunc,f2py_mod_get_dims_d,init - call setupfunc(a,b,c,f2py_mod_get_dims_d,init) - end subroutine f2pyinitmod - - subroutine f2pyinitfoodata(setupfunc) - external setupfunc - integer a - real*8 b,c(3) - common /foodata/ a,b,c - call setupfunc(a,b,c) - end subroutine f2pyinitfoodata diff --git a/tools/linter.py b/tools/linter.py index fd229dbef..9d23ffb48 100644 --- a/tools/linter.py +++ b/tools/linter.py @@ -15,6 +15,7 @@ CONFIG = os.path.join( EXCLUDE = ( "numpy/typing/tests/data/", "numpy/__config__.py", + "numpy/f2py", ) |