aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-06-01 12:26:42 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-06-01 12:26:42 +0200
commit411e388ebd94d6d6da9ba5536488badf8ed59c9f (patch)
treeb9eaaf4559cd8469135a4dd2a489bdf49454f736 /src
parent94e4f02728e102d69a1a2378869c22519751fe47 (diff)
downloadfortran-assignment2-411e388ebd94d6d6da9ba5536488badf8ed59c9f.tar.gz
fortran-assignment2-411e388ebd94d6d6da9ba5536488badf8ed59c9f.zip
allocate aligned memory using fftw
Diffstat (limited to 'src')
-rw-r--r--src/f1.f9018
1 files changed, 15 insertions, 3 deletions
diff --git a/src/f1.f90 b/src/f1.f90
index 38f360f..f03b9bf 100644
--- a/src/f1.f90
+++ b/src/f1.f90
@@ -11,14 +11,26 @@ PROGRAM test
real(C_DOUBLE) :: t, &
delta = (end - start) / real(npoints - 1, C_DOUBLE)
- DO i = 0, npoints - 1
+ type(C_PTR) :: p_in!, p_out, plan
- t = i * delta + start
+ real(C_DOUBLE), pointer :: arr_in(:)
+! complex(C_DOUBLE_COMPLEX), pointer :: out_arr(npoints)
+
+ p_in = fftw_alloc_real(int(npoints, C_SIZE_T))
+
+ call c_f_pointer(p_in, arr_in, [npoints])
+
+ DO i = 1, npoints
+
+ t = (i - 1) * delta + start
+ arr_in(i) = f1(t)
- write(*,*) t, " ", f1(t)
+ write(*,*) t, " ", arr_in(i)
END DO
+ call fftw_free(p_in)
+
CONTAINS
PURE real(C_DOUBLE) FUNCTION f1(t)