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)
allocate(global_buf_r4_kind(i_glob, j_glob))
85 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2)))
86 local_buf_r4_kind = vdata
89 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
90 local_buf_r4_kind(i1:i2,j1:j2), &
91 global_buf_r4_kind, fileobj%is_root)
93 deallocate(local_buf_r4_kind)
95 if (fileobj%is_root)
then
96 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
97 allocate(bc_info%globaldata2d_r4(i_glob, j_glob))
98 bc_info%globaldata2d_r4=global_buf_r4_kind(1:i_glob,1:j_glob)
99 deallocate(global_buf_r4_kind)
101 type is (real(kind=r8_kind))
103 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
105 allocate(global_buf_r8_kind(i_glob+1, j_glob))
109 allocate(local_buf_r8_kind(1,1))
110 local_buf_r8_kind = 0.
111 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
112 i1=1; i2=1; j1=1; j2=1
115 if(fileobj%is_root)
allocate(global_buf_r8_kind(i_glob, j_glob))
116 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2)))
117 local_buf_r8_kind = vdata
120 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, bc_info%pelist, &
121 local_buf_r8_kind(i1:i2,j1:j2), &
122 global_buf_r8_kind, fileobj%is_root)
123 deallocate(local_buf_r8_kind)
125 if (fileobj%is_root)
then
126 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob), (/
mpp_pe()/))
127 allocate(bc_info%globaldata2d_r8(i_glob, j_glob))
128 bc_info%globaldata2d_r8=global_buf_r8_kind(1:i_glob,1:j_glob)
129 deallocate(global_buf_r8_kind)
132 call error(
"gather_data_bc_2d: unsupported type. Currently only r8_kind and r4_kinds are supported")
136 if (fileobj%is_root)
then
138 write(chksum,
"(Z16)") chksum_val
139 bc_info%chksum = chksum
147 class(fmsnetcdffile_t),
intent(inout) :: fileobj
148 class(*),
dimension(:,:,:),
intent(in) :: vdata
149 type(bc_information),
intent(inout) :: bc_info
155 integer :: isc, iec, jsc, jec
156 integer :: i1, i2, j1, j2
157 integer :: i_add, j_add
159 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r4_kind
160 real(kind=r4_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r4_kind
161 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: global_buf_r8_kind
162 real(kind=r8_kind),
dimension(:,:,:),
allocatable,
target :: local_buf_r8_kind
164 integer(kind=i8_kind) :: chksum_val
165 character(len=32) :: chksum
168 isc = bc_info%indices(1)
169 iec = bc_info%indices(2)
170 jsc = bc_info%indices(3)
171 jec = bc_info%indices(4)
174 i1 = 1 + bc_info%x_halo
176 j1 = 1 + bc_info%y_halo
180 i_add = bc_info%ishift
181 j_add = bc_info%jshift
184 if (fileobj%is_root)
then
185 i_glob = bc_info%global_size(1)
186 j_glob = bc_info%global_size(2)
189 k_glob=bc_info%global_size(3)
192 type is (real(kind=r4_kind))
194 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
196 allocate(global_buf_r4_kind(i_glob+1, j_glob, bc_info%global_size(3)))
200 allocate(local_buf_r4_kind(1,1,1))
201 local_buf_r4_kind = 0.
202 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
203 i1=1; i2=1; j1=1; j2=1
206 if(fileobj%is_root)
allocate(global_buf_r4_kind(i_glob, j_glob, k_glob))
207 allocate(local_buf_r4_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
208 local_buf_r4_kind = vdata
211 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
212 local_buf_r4_kind(i1:i2,j1:j2,:), &
213 global_buf_r4_kind, fileobj%is_root)
214 deallocate(local_buf_r4_kind)
216 if (fileobj%is_root)
then
217 chksum_val = mpp_chksum(global_buf_r4_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
218 allocate(bc_info%globaldata3d_r4(i_glob, j_glob, bc_info%global_size(3)))
219 bc_info%globaldata3d_r4=global_buf_r4_kind(1:i_glob,1:j_glob,:)
220 deallocate(global_buf_r4_kind)
222 type is (real(kind=r8_kind))
224 if (fileobj%is_root .and. .not. bc_info%data_on_file_root)
then
226 allocate(global_buf_r8_kind(i_glob+1, j_glob, bc_info%global_size(3)))
230 allocate(local_buf_r8_kind(1,1,1))
231 local_buf_r8_kind = 0.
232 isc = 1+i_glob; i_add=0; iec=1+i_glob; jsc=j_glob; j_add=0; jec=j_glob
233 i1=1; i2=1; j1=1; j2=1
236 if(fileobj%is_root)
allocate(global_buf_r8_kind(i_glob, j_glob, k_glob))
237 allocate(local_buf_r8_kind(
size(vdata,1),
size(vdata,2),
size(vdata,3)))
238 local_buf_r8_kind = vdata
241 call mpp_gather(isc+i_add, iec+i_add, jsc+j_add, jec+j_add, k_glob, bc_info%pelist, &
242 local_buf_r8_kind(i1:i2,j1:j2,:), &
243 global_buf_r8_kind, fileobj%is_root)
244 deallocate(local_buf_r8_kind)
246 if (fileobj%is_root)
then
247 chksum_val = mpp_chksum(global_buf_r8_kind(1:i_glob,1:j_glob, :), (/
mpp_pe()/))
248 allocate(bc_info%globaldata3d_r8(i_glob, j_glob, bc_info%global_size(3)))
249 bc_info%globaldata3d_r8=global_buf_r8_kind(1:i_glob,1:j_glob,:)
250 deallocate(global_buf_r8_kind)
253 call error(
"gather_data_bc_3d: unsupported type. Currently only r8_kind and r4_kinds are supported")
257 if (fileobj%is_root)
then
259 write(chksum,
"(Z16)") chksum_val
260 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.