Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92085449
pi_seq.f90
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 17, 05:39
Size
942 B
Mime Type
text/x-c
Expires
Tue, Nov 19, 05:39 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22374133
Attached To
rSCINTROPAR Introduction to parallelism
pi_seq.f90
View Options
! ==========================================================================
! This exercise is taken from the class Parallel Programming Workshop (MPI,
! OpenMP and Advanced Topics) at HLRS given by Rolf Rabenseifner
! ==========================================================================
program
pi
implicit none
integer
::
myrank
,
num_threads
integer
,
parameter
::
n
=
10000000
double precision
::
omp_t1
,
omp_t2
double precision
::
dx
,
x
,
sm
,
lsum
,
pif
double precision
,
external
::
second
,
f
integer
::
i
! calculate pi = integral [0..1] 4 / (1 + x**2) dx */
omp_t1
=
second
()
dx
=
1.
/
n
sm
=
0.0
;
do
i
=
1
,
n
x
=
(
1.
*
i
-
0.5
)
*
dx
sm
=
sm
+
f
(
x
)
enddo
pif
=
dx
*
sm
omp_t2
=
second
()
print
*
,
'computed pi ='
,
pif
print
*
,
'Running time = '
,
(
omp_t2
-
omp_t1
)
end program
pi
double precision
function
f
(
a
)
implicit none
double precision
,
intent
(
in
)
::
a
f
=
4.
/
(
1.
+
(
a
**
2
))
end function
f
Event Timeline
Log In to Comment