-
Notifications
You must be signed in to change notification settings - Fork 1
/
approach1.F90
48 lines (39 loc) · 978 Bytes
/
approach1.F90
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
44
45
46
47
48
module my_approach1
use my_data1
class(grid_base), allocatable, target :: grid
contains
subroutine grid_init(a)
class(*), dimension(:), intent(in) :: a
select type (a)
type is (real(4))
allocate(grid_r4::grid)
select type (grid)
type is (grid_r4)
grid%i = 1
grid%j = 2
grid%x = a(1)
grid%y = a(2)
end select
type is (real(8))
allocate(grid_r8::grid)
select type (grid)
type is (grid_r8)
grid%i = 1
grid%j = 2
grid%x = a(1)
grid%y = a(2)
end select
end select
end subroutine grid_init
subroutine do_something_with_grid()
select type (grid)
type is (grid_r4)
print*, grid%i, grid%j, grid%x, grid%y
type is (grid_r8)
print*, grid%i, grid%j, grid%x, grid%y
end select
end subroutine do_something_with_grid
subroutine grid_end()
deallocate(grid)
end subroutine grid_end
end module my_approach1