-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxArrayModule.f90
141 lines (116 loc) · 3.39 KB
/
BoxArrayModule.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
! ____ _ __ ____ __ ____
! / __/___(_) / ___ ____/ __ \__ _____ ___ / /_ / _/__ ____
! _\ \/ __/ / _ \/ -_) __/ /_/ / // / -_|_-</ __/ _/ // _ \/ __/
! /___/\__/_/_.__/\__/_/ \___\_\_,_/\__/___/\__/ /___/_//_/\__(_)
!
!
! Copyright 2010 SciberQuest Inc.
!
! No permission is granted to reproduce this software.
!
! This is experimental software and is provided ‘‘as is’’, with no
! warranties of any kind whatsoever, no support, no promise of updates,
! or printed documentation.
!==============================================================================
module BoxArrayModule
use BoxModule
interface NewBoxArray
module procedure NewBoxArray4
module procedure NewBoxArray8
end interface
interface DeleteBoxArray
module procedure DeleteBoxArray4
module procedure DeleteBoxArray8
end interface
interface BoxArrayInit
module procedure BoxArrayInit4
module procedure BoxArrayInit8
end interface
contains
!----------------------------------------------------------------------------
subroutine NewBoxArray4(bbox,A)
implicit none
type(Box) bbox
real*4, pointer, dimension(:,:,:) :: A
integer iErr
allocate( &
A(bbox%I(1):bbox%I(2), &
bbox%I(3):bbox%I(4), &
bbox%I(5):bbox%I(6)), &
stat=iErr)
if (iErr.ne.0) then
write(0,*)"Failed to allocate array."
stop
end if
end subroutine
!----------------------------------------------------------------------------
subroutine NewBoxArray8(bbox,A)
implicit none
type(Box) bbox
real*8, pointer, dimension(:,:,:) :: A
integer iErr
allocate( &
A(bbox%I(1):bbox%I(2), &
bbox%I(3):bbox%I(4), &
bbox%I(5):bbox%I(6)), &
stat=iErr)
if (iErr.ne.0) then
write(0,*)"Failed to allocate array."
stop
end if
end subroutine
!----------------------------------------------------------------------------
subroutine DeleteBoxArray4(A)
implicit none
real*4, pointer, dimension(:,:,:) :: A
if (.not.associated(A)) return
deallocate(A)
nullify(A)
end subroutine
!----------------------------------------------------------------------------
subroutine DeleteBoxArray8(A)
implicit none
real*8, pointer, dimension(:,:,:) :: A
if (.not.associated(A)) return
deallocate(A)
nullify(A)
end subroutine
!------------------------------------------------------------------------------
subroutine BoxArrayInit4(bbox,A,val)
implicit none
type(Box) bbox
real*4 A( &
bbox%I(1):bbox%I(2), &
bbox%I(3):bbox%I(4), &
bbox%I(5):bbox%I(6))
real*4 val
integer i,j,k
do k=bbox%I(5),bbox%I(6)
do j=bbox%I(3),bbox%I(4)
do i=bbox%I(1),bbox%I(2)
A(i,j,k)=val
enddo
enddo
enddo
return
end subroutine
!------------------------------------------------------------------------------
subroutine BoxArrayInit8(bbox,A,val)
implicit none
type(Box) bbox
real*8 A( &
bbox%I(1):bbox%I(2), &
bbox%I(3):bbox%I(4), &
bbox%I(5):bbox%I(6))
real*4 val
integer i,j,k
do k=bbox%I(5),bbox%I(6)
do j=bbox%I(3),bbox%I(4)
do i=bbox%I(1),bbox%I(2)
A(i,j,k)=val
enddo
enddo
enddo
return
end subroutine
end module