28 class(fmsnetcdffile_t),
intent(inout) :: fileobj
29 class(*),
dimension(:,:),
intent(in) :: vdata
30 type(bc_information),
intent(inout) :: bc_info
35 integer :: isc, iec, jsc, jec
36 integer :: i1, i2, j1, j2
37 integer :: i_add, j_add
39 real(kind=r4_kind),
dimension(:,:),
allocatable,
target :: global_buf_r4_kind
40 real(kind=r4_kind),
dimension(:,:),
allocatable,
target :: local_buf_r4_kind
41 real(kind=r8_kind),
dimension(:,:),
allocatable,
target :: global_buf_r8_kind
42 real(kind=r8_kind),
dimension(:,:),
allocatable,
target :: local_buf_r8_kind
44 integer(kind=i8_kind) :: chksum_val
45 character(len=32) :: chksum
48 isc = bc_info%indices(1)
49 iec = bc_info%indices(2)
50 jsc = bc_info%indices(3)
51 jec = bc_info%indices(4)
54 i1 = 1 + bc_info%x_halo
56 j1 = 1 + bc_info%y_halo
60 i_add = bc_info%ishift
61 j_add = bc_info%jshift
64 if (fileobj%is_root)
then
65 i_glob = bc_info%global_size(1)
66 j_glob = bc_info%global_size(2)
71 type is (real(kind=r4_kind))
73 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
75 allocate(global_buf_r4_kind(i_glob+1, j_glob))
79 allocate(local_buf_r4_kind(1,1))
80 local_buf_r4_kind = 0.
81 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
82 i1=1; i2=1; j1=1; j2=1
85 if(fileobj%is_root)
allocate(global_buf_r4_kind(i_glob, j_glob))
86 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2)))
87 local_buf_r4_kind = vdata
90 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
91 local_buf_r4_kind(i1:i2,j1:j2), &
92 global_buf_r4_kind, fileobj%is_root)
94 deallocate(local_buf_r4_kind)
96 if (fileobj%is_root)
then
97 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
98 allocate(bc_info%globaldata2d_r4(i_glob, j_glob))
99 bc_info%globaldata2d_r4=global_buf_r4_kind(1:i_glob,1:j_glob)
100 deallocate(global_buf_r4_kind)
102 type is (real(kind=r8_kind))
104 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
106 allocate(global_buf_r8_kind(i_glob+1, j_glob))
110 allocate(local_buf_r8_kind(1,1))
111 local_buf_r8_kind = 0.
112 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
113 i1=1; i2=1; j1=1; j2=1
116 if(fileobj%is_root)
allocate(global_buf_r8_kind(i_glob, j_glob))
117 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2)))
118 local_buf_r8_kind = vdata
121 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
122 local_buf_r8_kind(i1:i2,j1:j2), &
123 global_buf_r8_kind, fileobj%is_root)
124 deallocate(local_buf_r8_kind)
126 if (fileobj%is_root)
then
127 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
128 allocate(bc_info%globaldata2d_r8(i_glob, j_glob))
129 bc_info%globaldata2d_r8=global_buf_r8_kind(1:i_glob,1:j_glob)
130 deallocate(global_buf_r8_kind)
133 call error(
"gather_data_bc_2d: unsupported type. Currently only r8_kind and r4_kinds are supported")
137 if (fileobj%is_root)
then
139 write(chksum,
"(Z16)") chksum_val
140 bc_info%chksum = chksum
148 class(fmsnetcdffile_t),
intent(inout) :: fileobj
149 class(*),
dimension(:,:,:),
intent(in) :: vdata
150 type(bc_information),
intent(inout) :: bc_info
156 integer :: isc, iec, jsc, jec
157 integer :: i1, i2, j1, j2
158 integer :: i_add, j_add
160 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r4_kind
161 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r4_kind
162 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r8_kind
163 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r8_kind
165 integer(kind=i8_kind) :: chksum_val
166 character(len=32) :: chksum
169 isc = bc_info%indices(1)
170 iec = bc_info%indices(2)
171 jsc = bc_info%indices(3)
172 jec = bc_info%indices(4)
175 i1 = 1 + bc_info%x_halo
177 j1 = 1 + bc_info%y_halo
181 i_add = bc_info%ishift
182 j_add = bc_info%jshift
185 if (fileobj%is_root)
then
186 i_glob = bc_info%global_size(1)
187 j_glob = bc_info%global_size(2)
190 k_glob=bc_info%global_size(3)
193 type is (real(kind=r4_kind))
195 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
197 allocate(global_buf_r4_kind(i_glob+1, j_glob, bc_info%global_size(3)))
201 allocate(local_buf_r4_kind(1,1,1))
202 local_buf_r4_kind = 0.
203 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
204 i1=1; i2=1; j1=1; j2=1
207 if(fileobj%is_root)
allocate(global_buf_r4_kind(i_glob, j_glob, k_glob))
208 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
209 local_buf_r4_kind = vdata
212 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
213 local_buf_r4_kind(i1:i2,j1:j2,:), &
214 global_buf_r4_kind, fileobj%is_root)
215 deallocate(local_buf_r4_kind)
217 if (fileobj%is_root)
then
218 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
219 allocate(bc_info%globaldata3d_r4(i_glob, j_glob, bc_info%global_size(3)))
220 bc_info%globaldata3d_r4=global_buf_r4_kind(1:i_glob,1:j_glob,:)
221 deallocate(global_buf_r4_kind)
223 type is (real(kind=r8_kind))
225 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
227 allocate(global_buf_r8_kind(i_glob+1, j_glob, bc_info%global_size(3)))
231 allocate(local_buf_r8_kind(1,1,1))
232 local_buf_r8_kind = 0.
233 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
234 i1=1; i2=1; j1=1; j2=1
237 if(fileobj%is_root)
allocate(global_buf_r8_kind(i_glob, j_glob, k_glob))
238 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
239 local_buf_r8_kind = vdata
242 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
243 local_buf_r8_kind(i1:i2,j1:j2,:), &
244 global_buf_r8_kind, fileobj%is_root)
245 deallocate(local_buf_r8_kind)
247 if (fileobj%is_root)
then
248 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
249 allocate(bc_info%globaldata3d_r8(i_glob, j_glob, bc_info%global_size(3)))
250 bc_info%globaldata3d_r8=global_buf_r8_kind(1:i_glob,1:j_glob,:)
251 deallocate(global_buf_r8_kind)
254 call error(
"gather_data_bc_3d: unsupported type. Currently only r8_kind and r4_kinds are supported")
258 if (fileobj%is_root)
then
260 write(chksum,
"(Z16)") chksum_val
261 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.