27 class(fmsnetcdffile_t),
intent(inout) :: fileobj
28 class(*),
dimension(:,:),
intent(in) :: vdata
29 type(bc_information),
intent(inout) :: bc_info
34 integer :: isc, iec, jsc, jec
35 integer :: i1, i2, j1, j2
36 integer :: i_add, j_add
38 real(kind=r4_kind),
dimension(:,:),
allocatable,
target :: global_buf_r4_kind
39 real(kind=r4_kind),
dimension(:,:),
allocatable,
target :: local_buf_r4_kind
40 real(kind=r8_kind),
dimension(:,:),
allocatable,
target :: global_buf_r8_kind
41 real(kind=r8_kind),
dimension(:,:),
allocatable,
target :: local_buf_r8_kind
43 integer(kind=i8_kind) :: chksum_val
44 character(len=32) :: chksum
47 isc = bc_info%indices(1)
48 iec = bc_info%indices(2)
49 jsc = bc_info%indices(3)
50 jec = bc_info%indices(4)
53 i1 = 1 + bc_info%x_halo
55 j1 = 1 + bc_info%y_halo
59 i_add = bc_info%ishift
60 j_add = bc_info%jshift
63 if (fileobj%is_root)
then
64 i_glob = bc_info%global_size(1)
65 j_glob = bc_info%global_size(2)
70 type is (real(kind=r4_kind))
72 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
74 allocate(global_buf_r4_kind(i_glob+1, j_glob))
78 allocate(local_buf_r4_kind(1,1))
79 local_buf_r4_kind = 0.
80 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
81 i1=1; i2=1; j1=1; j2=1
84 if(fileobj%is_root)
then
85 allocate(global_buf_r4_kind(i_glob, j_glob))
87 allocate(global_buf_r4_kind(1, 1))
89 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2)))
90 local_buf_r4_kind = vdata
93 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
94 local_buf_r4_kind(i1:i2,j1:j2), &
95 global_buf_r4_kind, fileobj%is_root)
97 deallocate(local_buf_r4_kind)
99 if (fileobj%is_root)
then
100 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
101 allocate(bc_info%globaldata2d_r4(i_glob, j_glob))
102 bc_info%globaldata2d_r4=global_buf_r4_kind(1:i_glob,1:j_glob)
103 deallocate(global_buf_r4_kind)
105 type is (real(kind=r8_kind))
107 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
109 allocate(global_buf_r8_kind(i_glob+1, j_glob))
113 allocate(local_buf_r8_kind(1,1))
114 local_buf_r8_kind = 0.
115 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
116 i1=1; i2=1; j1=1; j2=1
119 if(fileobj%is_root)
then
120 allocate(global_buf_r8_kind(i_glob, j_glob))
122 allocate(global_buf_r8_kind(1, 1))
124 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2)))
125 local_buf_r8_kind = vdata
128 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
129 local_buf_r8_kind(i1:i2,j1:j2), &
130 global_buf_r8_kind, fileobj%is_root)
131 deallocate(local_buf_r8_kind)
133 if (fileobj%is_root)
then
134 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
135 allocate(bc_info%globaldata2d_r8(i_glob, j_glob))
136 bc_info%globaldata2d_r8=global_buf_r8_kind(1:i_glob,1:j_glob)
137 deallocate(global_buf_r8_kind)
140 call error(
"gather_data_bc_2d: unsupported type. Currently only r8_kind and r4_kinds are supported")
144 if (fileobj%is_root)
then
146 write(chksum,
"(Z16)") chksum_val
147 bc_info%chksum = chksum
155 class(fmsnetcdffile_t),
intent(inout) :: fileobj
156 class(*),
dimension(:,:,:),
intent(in) :: vdata
157 type(bc_information),
intent(inout) :: bc_info
163 integer :: isc, iec, jsc, jec
164 integer :: i1, i2, j1, j2
165 integer :: i_add, j_add
167 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r4_kind
168 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r4_kind
169 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r8_kind
170 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r8_kind
172 integer(kind=i8_kind) :: chksum_val
173 character(len=32) :: chksum
176 isc = bc_info%indices(1)
177 iec = bc_info%indices(2)
178 jsc = bc_info%indices(3)
179 jec = bc_info%indices(4)
182 i1 = 1 + bc_info%x_halo
184 j1 = 1 + bc_info%y_halo
188 i_add = bc_info%ishift
189 j_add = bc_info%jshift
192 if (fileobj%is_root)
then
193 i_glob = bc_info%global_size(1)
194 j_glob = bc_info%global_size(2)
197 k_glob=bc_info%global_size(3)
200 type is (real(kind=r4_kind))
202 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
204 allocate(global_buf_r4_kind(i_glob+1, j_glob, bc_info%global_size(3)))
208 allocate(local_buf_r4_kind(1,1,1))
209 local_buf_r4_kind = 0.
210 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
211 i1=1; i2=1; j1=1; j2=1
214 if(fileobj%is_root)
then
215 allocate(global_buf_r4_kind(i_glob, j_glob, k_glob))
217 allocate(global_buf_r4_kind(1, 1, 1))
219 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
220 local_buf_r4_kind = vdata
223 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
224 local_buf_r4_kind(i1:i2,j1:j2,:), &
225 global_buf_r4_kind, fileobj%is_root)
226 deallocate(local_buf_r4_kind)
228 if (fileobj%is_root)
then
229 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
230 allocate(bc_info%globaldata3d_r4(i_glob, j_glob, bc_info%global_size(3)))
231 bc_info%globaldata3d_r4=global_buf_r4_kind(1:i_glob,1:j_glob,:)
232 deallocate(global_buf_r4_kind)
234 type is (real(kind=r8_kind))
236 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
238 allocate(global_buf_r8_kind(i_glob+1, j_glob, bc_info%global_size(3)))
242 allocate(local_buf_r8_kind(1,1,1))
243 local_buf_r8_kind = 0.
244 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
245 i1=1; i2=1; j1=1; j2=1
248 if(fileobj%is_root)
then
249 allocate(global_buf_r8_kind(i_glob, j_glob, k_glob))
251 allocate(global_buf_r8_kind(1, 1, 1))
253 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
254 local_buf_r8_kind = vdata
257 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
258 local_buf_r8_kind(i1:i2,j1:j2,:), &
259 global_buf_r8_kind, fileobj%is_root)
260 deallocate(local_buf_r8_kind)
262 if (fileobj%is_root)
then
263 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
264 allocate(bc_info%globaldata3d_r8(i_glob, j_glob, bc_info%global_size(3)))
265 bc_info%globaldata3d_r8=global_buf_r8_kind(1:i_glob,1:j_glob,:)
266 deallocate(global_buf_r8_kind)
269 call error(
"gather_data_bc_3d: unsupported type. Currently only r8_kind and r4_kinds are supported")
273 if (fileobj%is_root)
then
275 write(chksum,
"(Z16)") chksum_val
276 bc_info%chksum = chksum
integer function mpp_pe()
Returns processor ID.
subroutine gather_data_bc_3d(fileobj, vdata, bc_info)
gathers the 2d vdata from all of the relevant pes into the root_pe and saves it to a buffer.
subroutine gather_data_bc_2d(fileobj, vdata, bc_info)
gathers the 2d vdata from all of the relevant pes into the root_pe and saves it to a buffer.