summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Smith <kwsmith1@wisc.edu>2009-08-16 21:08:21 -0500
committerKurt Smith <kwsmith1@wisc.edu>2009-08-16 21:08:21 -0500
commit3f95cc5afaf474b79b7b9708b20f18ea6a52b4e5 (patch)
treed5d83f91051cec7cb3c60f9c7f896595a6eb6117
parentf12ece3ed4d28b95ffb2abc37b2ae299106d0d3a (diff)
downloadcython-3f95cc5afaf474b79b7b9708b20f18ea6a52b4e5.tar.gz
edits for fwrap array support
-rw-r--r--Tools/fwrap/Visitor.py1
-rw-r--r--Tools/fwrap/runtests.py2
-rw-r--r--Tools/fwrap/tests/run/simple_array.f9588
3 files changed, 87 insertions, 4 deletions
diff --git a/Tools/fwrap/Visitor.py b/Tools/fwrap/Visitor.py
index 98d89569c..5c59f19ca 100644
--- a/Tools/fwrap/Visitor.py
+++ b/Tools/fwrap/Visitor.py
@@ -764,6 +764,7 @@ class CyImplGenerator(GeneratorBase):
self.import_code.root.putln("cimport %s as %s" % (
PxdGenerator.make_fname(self.projname).split('.')[0],
CY_IMPORT_ALIAS))
+ self.import_code.root.putln("cimport numpy as np")
self.import_code.root.putln("")
self.import_code.copyto(fh)
diff --git a/Tools/fwrap/runtests.py b/Tools/fwrap/runtests.py
index 4e92bb627..9b95768f2 100644
--- a/Tools/fwrap/runtests.py
+++ b/Tools/fwrap/runtests.py
@@ -243,7 +243,7 @@ setup(cmdclass={'build_ext' : fwrap_build_ext},
orig_stdout, orig_stderr = sys.stdout, sys.stderr
sys.stdout = _devnull()
sys.stderr = _devnull()
- run_setup(setup_fqpath, script_args=['build_ext', '--inplace'])
+ run_setup(setup_fqpath, script_args=['build_ext', '--fcompiler=gnu95', '-lgfortran', '--inplace'])
finally:
os.chdir(thisdir)
sys.stdout,sys.stderr = orig_stdout, orig_stderr
diff --git a/Tools/fwrap/tests/run/simple_array.f95 b/Tools/fwrap/tests/run/simple_array.f95
index 0ce5e8de8..7e9a0e1c9 100644
--- a/Tools/fwrap/tests/run/simple_array.f95
+++ b/Tools/fwrap/tests/run/simple_array.f95
@@ -11,10 +11,92 @@
! end subroutine pass_array
- subroutine pass_array(arr0)
+ subroutine pass_array(arr0, arr1, arr2)
implicit none
- integer, dimension(:,:), intent(inout) :: arr0
+ integer, dimension(:,:), intent(in) :: arr0
+ integer, dimension(:,:), intent(inout) :: arr1
+ integer, dimension(:,:), intent(out) :: arr2
- arr0 = 5
+ print *, arr0
+ print *, arr1
+
+ arr2 = arr1 + arr0
end subroutine pass_array
+
+ subroutine pass_5D(arr0, arr1, arr2)
+ implicit none
+ integer :: i,j,k,l,m
+ integer, dimension(:,:,:,:,:), intent(in) :: arr0
+ integer, dimension(:,:,:,:,:), intent(inout) :: arr1
+ integer, dimension(:,:,:,:,:), intent(out) :: arr2
+
+ print *, shape(arr0)
+ print *, shape(arr1)
+ print *, shape(arr2)
+ ! print *, arr0
+ ! print *, arr1
+
+ do i = 1, size(arr0,1)
+ do j = 1, size(arr0,2)
+ do k = 1, size(arr0,3)
+ do l = 1, size(arr0,4)
+ do m = 1, size(arr0,5)
+ print *, arr0(m,l,k,j,i)
+ enddo
+ enddo
+ enddo
+ enddo
+ enddo
+
+ arr2 = arr1 + arr0
+
+ end subroutine pass_5D
+
+ subroutine pass_3D(arr0, arr1, arr2)
+ implicit none
+ integer :: i,j,k,l,m
+ integer, dimension(:,:,:), intent(in) :: arr0
+ integer, dimension(:,:,:), intent(inout) :: arr1
+ integer, dimension(:,:,:), intent(out) :: arr2
+
+ print *, shape(arr0)
+ print *, shape(arr1)
+ print *, shape(arr2)
+ ! print *, arr0
+ ! print *, arr1
+
+ do k = 1, size(arr0,1)
+ do l = 1, size(arr0,2)
+ do m = 1, size(arr0,3)
+ print *, arr0(m,l,k)
+ enddo
+ enddo
+ enddo
+
+ arr2 = arr1 + arr0
+
+ end subroutine pass_3D
+
+ subroutine pass_2D(arr0, arr1, arr2)
+ implicit none
+ integer :: i,j,k,l,m
+ integer, dimension(:,:,:), intent(in) :: arr0
+ integer, dimension(:,:,:), intent(inout) :: arr1
+ integer, dimension(:,:,:), intent(out) :: arr2
+
+ print *, shape(arr0)
+ print *, shape(arr1)
+ print *, shape(arr2)
+ ! print *, arr0
+ ! print *, arr1
+
+ do l = 1, size(arr0,1)
+ do m = 1, size(arr0,2)
+ print *, arr0(m,l)
+ enddo
+ enddo
+
+ arr2 = arr1 + arr0
+
+ end subroutine pass_2D