aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-06-01 12:03:01 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-06-01 12:03:01 +0200
commit21a2abb375380d745d648ba868ef0a0de4d3cbbe (patch)
tree9c2dd7dfda152804a57971f39557096bd0bccbe4
parent24cadd2552c5df78e6b9a13abc49e7e7b213d3bc (diff)
downloadfortran-assignment2-21a2abb375380d745d648ba868ef0a0de4d3cbbe.tar.gz
fortran-assignment2-21a2abb375380d745d648ba868ef0a0de4d3cbbe.zip
compute sinuses signal
-rw-r--r--test.f9028
1 files changed, 25 insertions, 3 deletions
diff --git a/test.f90 b/test.f90
index abc2e58..b5beb0b 100644
--- a/test.f90
+++ b/test.f90
@@ -1,10 +1,32 @@
PROGRAM test
use, intrinsic :: iso_c_binding
- implicit none
+ IMPLICIT none
- include 'fftw3.f03'
+ INCLUDE 'fftw3.f03'
- write(*,*) "ok"
+ integer, parameter :: npoints = 1024
+ real(C_DOUBLE), parameter :: start = 0, end = 1
+ integer :: i
+ real(C_DOUBLE) :: t, &
+ delta = (end - start) / real(npoints - 1, C_DOUBLE)
+ DO i = 0, npoints - 1
+
+ t = i * delta + start
+
+ write(*,*) t, " ", f1(t)
+
+ END DO
+
+CONTAINS
+
+ real(C_DOUBLE) FUNCTION f1(t)
+ real(C_DOUBLE), intent(in) :: t
+ real(C_DOUBLE), parameter :: pi = acos(-1.0)
+
+ f1 = sin(2 * pi * t * 200) + 2 * sin(2 * pi * t * 400)
+
+ END FUNCTION f1
+
END PROGRAM test