-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add remove_pointer_arg test support contiguous
- Loading branch information
daniel
committed
Dec 5, 2024
1 parent
fde8cfd
commit 117e03c
Showing
7 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#======================================================================= | ||
# define the compiler names | ||
#======================================================================= | ||
|
||
CC = gcc | ||
F90 = gfortran | ||
PYTHON = python | ||
CFLAGS = -fPIC | ||
F90FLAGS = -fPIC | ||
PY_MOD = pywrapper | ||
F90_SRC = main.f90 | ||
OBJ = $(F90_SRC:.f90=.o) | ||
F90WRAP_SRC = $(addprefix f90wrap_,${F90_SRC}) | ||
WRAPFLAGS = -v | ||
F2PYFLAGS = --build-dir build | ||
F90WRAP = f90wrap | ||
F2PY = f2py-f90wrap | ||
.PHONY: all clean | ||
|
||
all: test | ||
|
||
clean: | ||
rm -rf *.mod *.smod *.o f90wrap*.f90 ${PY_MOD}.py _${PY_MOD}*.so __pycache__/ .f2py_f2cmap build ${PY_MOD}/ | ||
|
||
main.o: ${F90_SRC} | ||
${F90} ${F90FLAGS} -c $< -o $@ | ||
|
||
%.o: %.f90 | ||
${F90} ${F90FLAGS} -c $< -o $@ | ||
|
||
${F90WRAP_SRC}: ${OBJ} | ||
${F90WRAP} -m ${PY_MOD} ${WRAPFLAGS} ${F90_SRC} | ||
|
||
f2py: ${F90WRAP_SRC} | ||
CFLAGS="${CFLAGS}" ${F2PY} -c -m _${PY_MOD} ${F2PYFLAGS} f90wrap_*.f90 *.o | ||
|
||
test: f2py | ||
${PYTHON} tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include ../make.meson.inc | ||
|
||
NAME := pywrapper | ||
|
||
test: build | ||
$(PYTHON) tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
program main | ||
|
||
end program | ||
|
||
module m_test | ||
|
||
implicit none | ||
public | ||
|
||
contains | ||
|
||
function to_be_ignored_1() result(ptr) | ||
real,pointer :: ptr(:,:) | ||
ptr => null() | ||
end function to_be_ignored_1 | ||
|
||
function to_be_ignored_2() result(ptr) | ||
real,pointer,contiguous :: ptr(:,:) | ||
ptr => null() | ||
end function to_be_ignored_2 | ||
|
||
function not_to_be_ignored() result(out_int) | ||
integer :: out_int | ||
out_int = 1 | ||
end function not_to_be_ignored | ||
|
||
end module m_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import unittest | ||
|
||
from pywrapper import m_test | ||
|
||
class TestReturnArray(unittest.TestCase): | ||
|
||
def not_ignored(self): | ||
_ = m_test.not_to_be_ignored() | ||
|
||
def ignored_1(self): | ||
with self.assertRaises(AttributeError): | ||
_ = m_test.to_be_ignored_1() | ||
|
||
def ignored_2(self): | ||
with self.assertRaises(AttributeError): | ||
_ = m_test.to_be_ignored_2() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters