summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIly <90933947+Ily83@users.noreply.github.com>2022-11-04 01:16:03 +0100
committerGitHub <noreply@github.com>2022-11-04 01:16:03 +0100
commit8c78bb13d93806ee78508b55aae79b2cfa05f1dc (patch)
tree303b044dbac3446e69737c78c92b78617e15e6e5
parent9912e4294585cf717e13cb874dcad298d140af6e (diff)
Update fortran90.html.markdown
added DO CONCURRENT
-rw-r--r--fortran90.html.markdown28
1 files changed, 28 insertions, 0 deletions
diff --git a/fortran90.html.markdown b/fortran90.html.markdown
index 2f2cfdfd..8ba0de5b 100644
--- a/fortran90.html.markdown
+++ b/fortran90.html.markdown
@@ -436,6 +436,34 @@ contains
end module fruity
+
+! ISO Standard Fortran 2008 introduced the DO CONCURRENT construct to allow you to express loop-level parallelism
+
+integer :: i
+real :: array(100)
+
+DO CONCURRENT (i = 1:size(array))
+ array(i) = sqrt(i**i)
+END DO
+
+
+! Only calls to pure functions are allowed inside the loop and we can declare multiple indices:
+
+integer :: x, y
+real :: array(8, 16)
+
+do concurrent (x = 1:size(array, 1), y = 1:size(array, 2))
+ array(x, y) = real(x)
+end do
+
+! loop indices can also declared inside the contruct:
+
+real :: array(8, 16)
+
+do concurrent (integer :: x = 1:size(array, 1), y = 1:size(array, 2))
+ array(x, y) = real(x)
+end do
+
```
### More Resources