File: procedure_18.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (43 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download
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
38
39
40
41
42
43
module mod1_procedure_18
  implicit none
  private
  public :: f_function

  contains

  elemental function f_function(x, y) result(fx)
    real, intent(in) :: x
    real, intent(in), optional :: y
    real :: w_y
    real :: fx
    w_y=1.0
    if (present(y)) w_y=y
    fx = w_y
  end function f_function
end module mod1_procedure_18

module mod2_procedure_18
  use :: mod1_procedure_18
  implicit none
  private
  public :: function_interface

  interface function_interface
    module procedure f_function
  end interface
end module mod2_procedure_18

program procedure_18
  use :: mod1_procedure_18
  use :: mod2_procedure_18
  implicit none
  real :: res, eps
  res = 0.5
  eps = 1e-8
  print *, "fx is ", f_function(0.8, y=0.5)
  if (abs(f_function(0.8, y=0.5) - res) > eps) error stop
  print *, "fx is ", function_interface(0.8, 0.5)
  if (abs(function_interface(0.8, 0.5) - res) > eps) error stop
  print *, "fx is ", function_interface(0.8, y=0.5)
  if (abs(function_interface(0.8, y=0.5) - res) > eps) error stop
end program procedure_18