111
|
1 ! { dg-do compile }
|
|
2 !
|
|
3 ! PR fortran/39427
|
|
4 !
|
|
5 ! Check constructor functionality.
|
|
6 !
|
|
7 ! Contributed by Damian Rouson.
|
|
8 !
|
|
9 module mycomplex_module
|
|
10 private
|
|
11 public :: mycomplex
|
|
12 type mycomplex
|
|
13 ! private
|
|
14 real :: argument, modulus
|
|
15 end type
|
|
16 interface mycomplex
|
|
17 module procedure complex_to_mycomplex, two_reals_to_mycomplex
|
|
18 end interface
|
|
19 ! :
|
|
20 contains
|
|
21 type(mycomplex) function complex_to_mycomplex(c)
|
|
22 complex, intent(in) :: c
|
|
23 ! :
|
|
24 end function complex_to_mycomplex
|
|
25 type(mycomplex) function two_reals_to_mycomplex(x,y)
|
|
26 real, intent(in) :: x
|
|
27 real, intent(in), optional :: y
|
|
28 ! :
|
|
29 end function two_reals_to_mycomplex
|
|
30 ! :
|
|
31 end module mycomplex_module
|
|
32 ! :
|
|
33 program myuse
|
|
34 use mycomplex_module
|
|
35 type(mycomplex) :: a, b, c
|
|
36 ! :
|
|
37 a = mycomplex(argument=5.6, modulus=1.0) ! The structure constructor
|
|
38 c = mycomplex(x=0.0, y=1.0) ! A function reference
|
|
39 c = mycomplex(0.0, 1.0) ! A function reference
|
|
40 end program myuse
|