From 4874af99fcb9c9af869536a2bd390e9e94d07b8a Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Sun, 7 Feb 2021 21:54:48 +0200 Subject: ENH: Share memory of read-only intent(in) arrays. Closes #16347 --- numpy/f2py/src/fortranobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/f2py/src') diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index 3275f90ad..b9ef18701 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -799,7 +799,7 @@ PyArrayObject* array_from_pyobj(const int type_num, && ARRAY_ISCOMPATIBLE(arr,type_num) && F2PY_CHECK_ALIGNMENT(arr, intent) ) { - if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY(arr):PyArray_ISFARRAY(arr)) { + if ((intent & F2PY_INTENT_C)?PyArray_ISCARRAY_RO(arr):PyArray_ISFARRAY_RO(arr)) { if ((intent & F2PY_INTENT_OUT)) { Py_INCREF(arr); } @@ -807,9 +807,9 @@ PyArrayObject* array_from_pyobj(const int type_num, return arr; } } - if (intent & F2PY_INTENT_INOUT) { strcpy(mess, "failed to initialize intent(inout) array"); + /* Must use PyArray_IS*ARRAY because intent(inout) requires writable input */ if ((intent & F2PY_INTENT_C) && !PyArray_ISCARRAY(arr)) strcat(mess, " -- input not contiguous"); if (!(intent & F2PY_INTENT_C) && !PyArray_ISFARRAY(arr)) -- cgit v1.2.1