-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsolution.f90
More file actions
37 lines (28 loc) · 1.06 KB
/
Copy pathsolution.f90
File metadata and controls
37 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
! PWR069: Use the keyword only to explicitly state what to import from a module
module Areas
use iso_fortran_env, only: real32
implicit none
public :: constant_pi, area_circle, area_rectangle, area_square
real(kind=real32), parameter :: constant_pi = 3.1415
contains
pure real(kind=real32) function area_circle(radius)
real(kind=real32), intent(in) :: radius
area_circle = constant_pi * radius * radius
end function area_circle
pure real(kind=real32) function area_rectangle(length, width)
real(kind=real32), intent(in) :: length, width
area_rectangle = length * width
end function area_rectangle
pure real(kind=real32) function area_square(side)
real(kind=real32), intent(in) :: side
area_square = side * side
end function area_square
end module Areas
program test_with_only
use Areas, only : constant_pi, area_circle
use iso_fortran_env, only: real32
implicit none
real(kind=real32) :: radius = 2.0
print *, 'Area of circle: ', area_circle(radius)
print *, 'Value of pi used: ', constant_pi
end program test_with_only