jameskermode / f90wrap

F90 to Python interface generator with derived type support
GNU Lesser General Public License v3.0
243 stars 80 forks source link

update numpy flags #197

Closed jan-janssen closed 1 year ago

jan-janssen commented 1 year ago

The numpy flags changed:

NPY_FORTRAN -> NPY_ARRAY_F_CONTIGUOUS
NPY_WRITEABLE -> NPY_ARRAY_WRITEABLE
NPY_ALIGNED -> NPY_ARRAY_ALIGNED

https://numpy.org/devdocs/reference/c-api/array.html#array-flags

jameskermode commented 1 year ago

Thanks for the contribution. It’s failing the CI on Python 3.8 on macOS, presumably because the version of numpy there predates the change. Is there a way to get this to work in both cases, eg with an#ifdef?

jameskermode commented 1 year ago

From a quick look wrapping your changes in #if NUMPY_VERSION > 1.7 and leaving my old code in an #else branch should do the job.

jan-janssen commented 1 year ago

Unfortunately, there are still some more issues, it seems also PyArray_INT is now replaced with PyTypeNum_ISINTEGER and the usage of PyArrayObject changed as well. The error I currently get is:

  ../../f90wrap/arraydatamodule.c:62:36: error: 'PyArray_INT' undeclared (first use in this function); did you mean 'PyArray_CGT'?
     62 |   capi_this_tmp = array_from_pyobj(PyArray_INT,this_Dims,this_Rank,capi_this_intent,this_capi);
        |                                    ^~~~~~~~~~~
        |                                    PyArray_CGT
  ../../f90wrap/arraydatamodule.c:62:36: note: each undeclared identifier is reported only once for each function it appears in
  ../../f90wrap/arraydatamodule.c:68:33: error: 'PyArrayObject' {aka 'struct tagPyArrayObject'} has no member named 'data'
     68 |     this = (int *)(capi_this_tmp->data);
        |                                 ^~
  ../../f90wrap/arraydatamodule.c: At top level:
  ../../f90wrap/arraydatamodule.c:128:197: warning: unknown escape sequence: '\g'
    128 |    "Make an array from integer(sizeof_fortran_t) array containing reference to derived type object,\n and fortran array function.\n\get_array(sizeof_fortran_t, fpointer,array_fobj[,key]) -> array"},
        |                                                                                                                                                                                                     ^
  [2/9] Generating f90wrap/sizeof_fortran_tmodule.c with a custom command