Changeset 1855 for inundation


Ignore:
Timestamp:
Sep 28, 2005, 6:00:46 PM (19 years ago)
Author:
ole
Message:

Better interface to meshing for karratha + some pypar work

Location:
inundation/pypar/mandelbrot_example
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pypar/mandelbrot_example/compile.py

    r1852 r1855  
    111111  include = os.path.join(os.path.join(sys.exec_prefix, 'include'),
    112112                     'python'+sys.version[:3])
    113   headerfile = os.path.join(include, 'Python.h')
    114113 
     114 
     115  # Check existence of Python.h
     116  #
     117  headerfile = include + '/Python.h'
    115118  try:
    116     # unix style include directory
    117119    open(headerfile, 'r')
    118120  except:
    119     # windows style include directory
    120     include = os.path.join(sys.exec_prefix, 'include')
    121     headerfile = os.path.join(include, 'Python.h')
    122     try:
    123       open(headerfile, 'r')
    124     except:
    125       raise """Did not find Python header file.
    126       Make sure files for Python C-extensions are installed."""
     121    raise """Did not find Python header file %s.
     122    Make sure files for Python C-extensions are installed.
     123    In debian linux, for example, you need to install a
     124    package called something like python2.1-dev""" %headerfile
     125 
    127126 
    128127  # Check filename(s)
     
    147146    # Compile
    148147    #
     148    s = "%s -c %s -I%s -o %s.o" %(compiler, FN, include, root)
     149    if os.name == 'posix' and os.uname()[4] == 'x86_64':
     150      #Extra flags for 64 bit architectures
     151      #s += ' -fPIC -m64' #gcc
     152      s += ' -fPIC -tp amd64' #pgcc
     153     
    149154   
    150     s = "%s -c %s -I%s -o %s.o -Wall -O" %(compiler, FN, include, root)
    151155    if verbose:
    152156      print s
     
    161165 
    162166  # Make shared library (*.so)
     167  s = "%s -%s %s -o %s.so" %(loader, sharedflag, object_files, root1)
     168
     169  if os.name == 'posix' and os.uname()[4] == 'x86_64':
     170      #Extra flags for 64 bit architectures using Portland compilers
     171      s += ' -mcmodel=medium'
    163172 
    164   s = "%s -%s %s -o %s.so -lm" %(loader, sharedflag, object_files, root1)
    165173  if verbose:
    166174    print s
  • inundation/pypar/mandelbrot_example/mandel_ext.c

    r1852 r1855  
    1 // Python - C extension for fast computation of the Mandelbrot iteration
     1/* Python - C extension for fast computation of the Mandelbrot iteration
    22//
    33// To compile:
     
    1212// k = calculate_point(c, kmax)
    1313//
    14 // Ole Nielsen, SUT 2003
     14// Ole Nielsen, SUT 2003 */
    1515       
    1616#include "Python.h"
    1717
    18 // Computational function
     18/* Computational function */
    1919int _calculate_point(Py_complex c, int kmax) {
    2020  int count;
     
    3737
    3838
    39 // Interface to Python
     39/* Interface to Python */
    4040PyObject *calculate_point(PyObject *self, PyObject *args) {
    41   PyComplexObject *C;  // Python Complex object
    42   Py_complex c;        // C Complex structure
     41  PyComplexObject *C;  /* Python Complex object */
     42  Py_complex c;        /* C Complex structure */
    4343  int kmax, count;
    4444
    45   // Convert Python arguments to C 
     45  /* Convert Python arguments to C  */
    4646  if (!PyArg_ParseTuple(args, "Oi", &C, &kmax))
    4747    return NULL;
    4848  c = PyComplex_AsCComplex((PyObject*) C);   
    4949 
    50   // Call underlying routine
     50  /* Call underlying routine */
    5151  count = _calculate_point(c, kmax);
    5252
    53   // Return results as a Python object
     53  /* Return results as a Python object */
    5454  return Py_BuildValue("i", count);
    5555}
    5656
    5757
    58 // Method table for python module
     58/* Method table for python module */
    5959static struct PyMethodDef MethodTable[] = {
    6060  {"calculate_point", calculate_point, METH_VARARGS}, 
     
    6363
    6464
    65 // Module initialisation   
     65/* Module initialisation  */
    6666void initmandel_ext(void){
    6767  Py_InitModule("mandel_ext", MethodTable);
Note: See TracChangeset for help on using the changeset viewer.