aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-06-21 12:42:05 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-06-21 12:42:05 +0200
commitf73f1331f30d330dd10cd0b02ca56c3ab5d31eaa (patch)
tree33da6aa60bf646804ec57da6e5b32aa881adde46 /src
parent7a4ff1cb42a88cb30225896b645c1174c1f8e3d1 (diff)
downloadfortran-assignment3-f73f1331f30d330dd10cd0b02ca56c3ab5d31eaa.tar.gz
fortran-assignment3-f73f1331f30d330dd10cd0b02ca56c3ab5d31eaa.zip
make quadratures a module, sketch the integrate fuction for newton-cotes quadratures
Diffstat (limited to 'src')
-rw-r--r--src/quadratures.f9045
1 files changed, 30 insertions, 15 deletions
diff --git a/src/quadratures.f90 b/src/quadratures.f90
index 9e6bd38..90bba6e 100644
--- a/src/quadratures.f90
+++ b/src/quadratures.f90
@@ -1,7 +1,11 @@
-PROGRAM quadratures
+MODULE quadratures
+ IMPLICIT none
+
+ integer(kind=8) :: subintervals = 100
+
INTERFACE
- FUNCTION integrate(ibeg, iend, myfun, p) result(value)
+ FUNCTION integrate(ibeg, iend, myfun, p) result(val)
IMPLICIT none
! beginning of integration interval
real(kind=8), intent(in) :: ibeg
@@ -12,7 +16,7 @@ PROGRAM quadratures
! polynomial order
integer(kind=4), intent(in) :: p
! result of integration
- real(kind=8) :: value
+ real(kind=8) :: val
END FUNCTION integrate
END INTERFACE
@@ -23,19 +27,30 @@ PROGRAM quadratures
real(kind=8) :: y
END FUNCTION funint
END INTERFACE
-
- procedure(funint), pointer :: ptr
-
- ptr => my_exp
-
- write(*,*) my_exp(2.0_8)
CONTAINS
+
+ FUNCTION newton_cotes(ibeg, iend, fun, p) result(val)
+ IMPLICIT none
+ real(kind=8), intent(in) :: ibeg
+ real(kind=8), intent(in) :: iend
+ procedure(funint) :: fun
+ integer(kind=4), intent(in) :: p
+ real(kind=8) :: val
+
+ SELECT CASE (p)
+ CASE (:-1)
+ STOP "negative interpolationg polynomial order passed"
+ CASE (0)
+ val = 0 ! rectangle(ibeg, iend, fun)
+ CASE (1)
+ val = 0 ! trapeze(ibeg, iend, fun)
+ CASE (2)
+ val = 0 ! simpson_1_third(ibeg, iend, fun)
+ CASE default
+ STOP "Newton-Cotes quadratures only implemented for order < 3"
+ END SELECT
+ END FUNCTION newton_cotes
- FUNCTION my_exp(x) result(y)
- real(kind=8), intent(in) :: x
- real(kind=8) :: y
- y = exp(x)
- END FUNCTION my_exp
-END PROGRAM quadratures
+END MODULE quadratures
39d432397e7107021fd6cb3ec01aecfb64'>build-self: Help users to submit useful bug reports.Tobias Geerinckx-Rice * build-aux/build-self.scm (build): Request the ‘COMPLETE output’. 2021-10-17maint: Factorize po xref translation.Julien Lepiller This ensures we use the same method in "make" as in "guix/self.scm". * Makefile.am: Build guix/build/po.scm. * build-aux/convert-xref.scm: New file. * doc/local.mk (xref_command): Use it. * guix/self.scm (translate-cross-references): Move it... * guix/build/po.scm: Parse comments and flags separately to find fuzzy flags. (translate-cross-references): ...here. (parse-tree->assoc): Ignore fuzzy entries. 2021-06-23build: Makefile splits Scheme compilation in four steps.Ludovic Courtès Fixes <https://bugs.gnu.org/48963>. Reported by Julien Lepiller <julien@lepiller.eu>. This reduces peak memory consumption to something less unreasonable. * Makefile.am (make-go): Depend on 'make-*-go' targets; remove body. (guile-compilation-rule): New function. (MODULES_CORE, MODULES_PACKAGES, MODULES_SYSTEM, MODULES_CLI): New variables. <top level>: Call 'guile-compilation-rule' 4 times. * build-aux/compile-all.scm <top level>: Expect "--total" and "--processed". Take them into account when displaying progress reports. 2021-06-18build: Remove Guile 2.2 workaround.Ludovic Courtès * build-aux/compile-all.scm <top level>: Remove Guile 2.2 workaround.