3 ! Check PDT type extension and simple OOP.
7 integer :: mat_dim = 256
8 integer, parameter :: ftype = kind(0.0d0)
15 integer, kind :: a = kind(0.0e0)
18 real(kind = a) :: d(b, b)
21 type, extends(mytype) :: thytype(h)
23 integer(kind = h) :: j
30 integer(kind = q) :: idx_mat(2,2) ! check these do not get treated as pdt_arrays.
31 type (mytype (b=s)) :: mat1
32 type (mytype (b=s*2)) :: mat2
35 real, allocatable :: matrix (:,:)
36 type(thytype(ftype, 4, 4)) :: w
38 class(mytype(ftype, :)), allocatable :: cz
40 w%d = reshape ([(real(i), i = 1, d_dim*d_dim)],[d_dim,d_dim])
42 ! Make sure that the type extension is ordering the parameters correctly.
43 if (w%a .ne. ftype) call abort
44 if (w%b .ne. 4) call abort
45 if (w%h .ne. 4) call abort
46 if (size (w%d) .ne. 16) call abort
47 if (int (w%d(2,4)) .ne. 14) call abort
48 if (kind (w%j) .ne. w%h) call abort
50 ! As a side issue, ensure PDT components are OK
51 if (q%mat1%b .ne. q%s) call abort
52 if (q%mat2%b .ne. q%s*2) call abort
53 if (size (q%mat1%d) .ne. mat_dim**2) call abort
54 if (size (q%mat2%d) .ne. 4*mat_dim**2) call abort
56 ! Now check some basic OOP with PDTs
59 ! TODO - for some reason, using w%d directly in the source causes a seg fault.
60 allocate (cz, source = mytype(ftype, d_dim, 0, matrix))
62 type is (mytype(ftype, *))
63 if (int (sum (cz%d)) .ne. 136) call abort
64 type is (thytype(ftype, *, 8))
69 allocate (thytype(ftype, d_dim*2, 8) :: cz)
70 cz%d = reshape ([(i*10, i = 1, cz%b**2)], [cz%b,cz%b])
72 type is (mytype(ftype, *))
74 type is (thytype(ftype, *, 8))
75 if (int (sum (cz%d)) .ne. 20800) call abort