Skip to content

Commit

Permalink
F2PY G3: added simple test for subroutine with derived type intent(in…
Browse files Browse the repository at this point in the history
…,out) argument. Fixed bugs.
  • Loading branch information
pearu committed Oct 8, 2006
1 parent 416f306 commit b7f719a
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 142 deletions.
51 changes: 51 additions & 0 deletions numpy/f2py/lib/main.py
Expand Up @@ -44,6 +44,56 @@
--2d-numeric Use f2py2e tool with Numeric support.
--2d-numarray Use f2py2e tool with Numarray support.
-m <modulename> Name of the module; f2py generates a Python/C API
file <modulename>module.c or extension module <modulename>.
For wrapping Fortran 90 modules, f2py will use Fortran
module names.
Options effective only with -h
------------------------------
-h <filename> Write signatures of the fortran routines to file <filename>
and exit. You can then edit <filename> and use it instead
of <fortran files> for generating extension module source.
If <filename> is stdout or stderr then the signatures are
printed to the corresponding stream.
--overwrite-signature Overwrite existing signature file.
Options effective only with -c
------------------------------
-c Compile fortran sources and build extension module.
--build-dir <dirname> All f2py generated files are created in <dirname>.
Default is tempfile.mktemp() and it will be removed after
f2py stops unless <dirname> is specified via --build-dir
option.
numpy.distutils options effective only with -c
----------------------------------------------
--fcompiler=<name> Specify Fortran compiler type by vendor
Extra options effective only with -c
------------------------------------
-L/path/to/lib/ -l<libname>
-D<name[=define]> -U<name>
-I/path/to/include/
<filename>.o <filename>.(so|dynlib|dll) <filename>.a
Using the following macros may be required with non-gcc Fortran
compilers:
-DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN
-DUNDERSCORE_G77
-DF2PY_DEBUG_PYOBJ_TOFROM --- pyobj_(to|from)_<ctype> functions will
print debugging messages to stderr.
"""

import re
Expand Down Expand Up @@ -266,6 +316,7 @@ def configuration(parent_package='', top_path=None):
undef_macros = undef_macros,
include_dirs = include_dirs,
extra_objects = extra_objects,
language = 'f90',
)
if external_subprograms:
wrapper = PythonWrapperModule(modulename)
Expand Down
41 changes: 29 additions & 12 deletions numpy/f2py/lib/parser/base_classes.py
Expand Up @@ -426,8 +426,9 @@ def torepr(self, depth=-1,incrtab=''):
l.append(ttab + 'a=' + self.a.torepr(depth-1,incrtab+' ').lstrip())
return '\n'.join(l)

def get_indent_tab(self,colon=None,deindent=False):
if self.reader.isfix:
def get_indent_tab(self,colon=None,deindent=False,isfix=None):
if isfix is None: isfix = self.reader.isfix
if isfix:
tab = ' '*6
else:
tab = ''
Expand All @@ -441,19 +442,35 @@ def get_indent_tab(self,colon=None,deindent=False):
return tab
s = self.item.label
if colon is None:
if self.reader.isfix:
if isfix:
colon = ''
else:
colon = ':'
if s:
c = ''
if self.reader.isfix:
if isfix:
c = ' '
tab = tab[len(c+s)+len(colon):]
if not tab: tab = ' '
tab = c + s + colon + tab
return tab

def __str__(self):
return self.tofortran()

def asfix(self):
lines = []
for line in self.tofortran(isfix=True).split('\n'):
if len(line)>72 and line[0]==' ':
lines.append(line[:72]+'&\n &')
line = line[72:]
while len(line)>66:
lines.append(line[:66]+'&\n &')
line = line[66:]
lines.append(line+'\n')
else: lines.append(line+'\n')
return ''.join(lines).replace('\n &\n','\n')

def format_message(self, kind, message):
if self.item is not None:
message = self.reader.format_message(kind, message,
Expand Down Expand Up @@ -544,11 +561,11 @@ def __init__(self, parent, item=None):

def tostr(self):
return self.blocktype.upper() + ' '+ self.name
def __str__(self):
l=[self.get_indent_tab(colon=':') + self.tostr()]

def tofortran(self, isfix=None):
l=[self.get_indent_tab(colon=':', isfix=isfix) + self.tostr()]
for c in self.content:
l.append(str(c))
l.append(c.tofortran(isfix=isfix))
return '\n'.join(l)

def torepr(self, depth=-1, incrtab=''):
Expand Down Expand Up @@ -736,10 +753,10 @@ def process_item(self):
def analyze(self):
return

def get_indent_tab(self,colon=None,deindent=False):
return Statement.get_indent_tab(self, colon=colon, deindent=True)
def get_indent_tab(self,colon=None,deindent=False,isfix=None):
return Statement.get_indent_tab(self, colon=colon, deindent=True,isfix=isfix)

def __str__(self):
return self.get_indent_tab() + 'END %s %s'\
def tofortran(self, isfix=None):
return self.get_indent_tab(isfix=isfix) + 'END %s %s'\
% (self.blocktype.upper(),self.name or '')

4 changes: 2 additions & 2 deletions numpy/f2py/lib/parser/block_statements.py
Expand Up @@ -846,8 +846,8 @@ def tostr(self):
assert len(self.content)==1,`self.content`
return 'IF (%s) %s' % (self.expr, str(self.content[0]).lstrip())

def __str__(self):
return self.get_indent_tab(colon=':') + self.tostr()
def tofortran(self,isfix=None):
return self.get_indent_tab(colon=':',isfix=isfix) + self.tostr()

def get_classes(self):
return action_stmt
Expand Down

0 comments on commit b7f719a

Please sign in to comment.