29 subroutine domain_read_0d(fileobj, variable_name, vdata, unlim_dim_level, corner)
31 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
32 character(len=*),
intent(in) :: variable_name
33 class(*),
intent(inout) :: vdata
36 integer,
intent(in),
optional :: unlim_dim_level
38 integer,
intent(in),
optional :: corner
43 call netcdf_read_data(fileobj, variable_name, vdata, &
44 unlim_dim_level=unlim_dim_level, corner=corner, &
58 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
59 character(len=*),
intent(in) :: variable_name
60 class(*),
dimension(:),
intent(inout) :: vdata
63 integer,
intent(in),
optional :: unlim_dim_level
65 integer,
dimension(1),
intent(in),
optional :: corner
69 integer,
dimension(1),
intent(in),
optional :: edge_lengths
74 call netcdf_read_data(fileobj, variable_name, vdata, &
75 unlim_dim_level=unlim_dim_level, corner=corner, &
76 edge_lengths=edge_lengths, broadcast=.true.)
88 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
89 character(len=*),
intent(in) :: variable_name
90 class(*),
contiguous,
target,
intent(inout) :: vdata(:,:)
93 integer,
intent(in),
optional :: unlim_dim_level
95 integer,
dimension(2),
intent(in),
optional :: corner
99 integer,
dimension(2),
intent(in),
optional :: edge_lengths
104 integer :: xdim_index
105 integer :: ydim_index
117 logical :: buffer_includes_halos
122 type(domain2d),
pointer :: io_domain
125 integer(kind=i4_kind),
dimension(:,:),
allocatable :: buf_i4_kind_pe
126 integer(kind=i8_kind),
dimension(:,:),
allocatable :: buf_i8_kind_pe
127 real(kind=r4_kind),
dimension(:,:),
allocatable :: buf_r4_kind_pe
128 real(kind=r8_kind),
dimension(:,:),
allocatable :: buf_r8_kind_pe
129 integer(kind=i4_kind),
dimension(:,:),
allocatable :: buf_i4_kind
130 integer(kind=i8_kind),
dimension(:,:),
allocatable :: buf_i8_kind
131 real(kind=r4_kind),
dimension(:,:),
allocatable :: buf_r4_kind
132 real(kind=r8_kind),
dimension(:,:),
allocatable :: buf_r8_kind
133 class(*),
dimension(:,:,:,:),
pointer :: vdata_dummy
135 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
136 xdim_index, ydim_index, xpos, ypos))
then
137 call netcdf_read_data(fileobj, variable_name, vdata, &
138 unlim_dim_level=unlim_dim_level, corner=corner, &
139 edge_lengths=edge_lengths, broadcast=.true.)
143 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
144 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, buffer_includes_halos, &
145 msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
147 if (fileobj%use_netcdf_mpi)
then
151 if (buffer_includes_halos)
then
154 e(xdim_index) = xc_size + 2*(isc - isd)
155 e(ydim_index) = yc_size + 2*(jsc - jsd)
159 e(xdim_index) = xc_size
160 e(ydim_index) = yc_size
163 call netcdf_read_data(fileobj, variable_name, vdata, unlim_dim_level=unlim_dim_level, corner=c, edge_lengths=e)
167 if (xdim_index .ne. 1 .or. ydim_index .ne. 2)
then
171 vdata_dummy(1:
size(vdata,1),1:
size(vdata,2), 1:1, 1:1) => vdata(:,:)
172 call domain_read_4d(fileobj, variable_name, vdata_dummy, unlim_dim_level)
179 call mpp_get_global_domain(io_domain, xbegin=xgbegin, xsize=xgsize, position=xpos)
180 call mpp_get_global_domain(io_domain, ybegin=ygbegin, ysize=ygsize, position=ypos)
183 if (fileobj%is_root)
then
185 if (fileobj%adjust_indices)
then
192 c(xdim_index) = xgbegin
193 c(ydim_index) = ygbegin
196 e(xdim_index) = xgsize
197 e(ydim_index) = ygsize
201 type is (
integer(kind=i4_kind))
202 call allocate_array(buf_i4_kind, e)
203 call netcdf_read_data(fileobj, variable_name, buf_i4_kind, &
204 unlim_dim_level=unlim_dim_level, &
205 corner=c, edge_lengths=e, broadcast=.false.)
206 type is (
integer(kind=i8_kind))
207 call allocate_array(buf_i8_kind, e)
208 call netcdf_read_data(fileobj, variable_name, buf_i8_kind, &
209 unlim_dim_level=unlim_dim_level, &
210 corner=c, edge_lengths=e, broadcast=.false.)
211 type is (real(kind=r4_kind))
212 call allocate_array(buf_r4_kind, e)
213 call netcdf_read_data(fileobj, variable_name, buf_r4_kind, &
214 unlim_dim_level=unlim_dim_level, &
215 corner=c, edge_lengths=e, broadcast=.false.)
216 type is (real(kind=r8_kind))
217 call allocate_array(buf_r8_kind, e)
218 call netcdf_read_data(fileobj, variable_name, buf_r8_kind, &
219 unlim_dim_level=unlim_dim_level, &
220 corner=c, edge_lengths=e, broadcast=.false.)
222 call error(
"unsupported variable type: domain_read_2d: file: "//trim(fileobj%path)//
" variable:"// &
223 & trim(variable_name))
231 if (buffer_includes_halos)
then
233 c(xdim_index) = isc - isd + 1
234 c(ydim_index) = jsc - jsd + 1
240 e(xdim_index) = xc_size
241 e(ydim_index) = yc_size
244 type is (
integer(kind=i4_kind))
245 call allocate_array(buf_i4_kind_pe, e)
246 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
247 buf_i4_kind_pe, buf_i4_kind, fileobj%is_root)
248 call put_array_section(buf_i4_kind_pe, vdata, c, e)
249 deallocate(buf_i4_kind_pe)
250 type is (
integer(kind=i8_kind))
251 call allocate_array(buf_i8_kind_pe, e)
252 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
253 buf_i8_kind_pe, buf_i8_kind, fileobj%is_root)
254 call put_array_section(buf_i8_kind_pe, vdata, c, e)
255 deallocate(buf_i8_kind_pe)
256 type is (real(kind=r4_kind))
257 call allocate_array(buf_r4_kind_pe, e)
258 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
259 buf_r4_kind_pe, buf_r4_kind, fileobj%is_root)
260 call put_array_section(buf_r4_kind_pe, vdata, c, e)
261 deallocate(buf_r4_kind_pe)
262 type is (real(kind=r8_kind))
263 call allocate_array(buf_r8_kind_pe, e)
264 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, fileobj%pelist, &
265 buf_r8_kind_pe, buf_r8_kind, fileobj%is_root)
266 call put_array_section(buf_r8_kind_pe, vdata, c, e)
267 deallocate(buf_r8_kind_pe)
269 call error(
"unsupported variable type: domain_read_2d: file: "//trim(fileobj%path)//
" variable:"// &
270 & trim(variable_name))
273 if (fileobj%is_root)
then
274 if (
allocated(buf_i4_kind))
deallocate(buf_i4_kind)
275 if (
allocated(buf_i8_kind))
deallocate(buf_i8_kind)
276 if (
allocated(buf_r4_kind))
deallocate(buf_r4_kind)
277 if (
allocated(buf_r8_kind))
deallocate(buf_r8_kind)
288 corner, edge_lengths)
289 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
290 character(len=*),
intent(in) :: variable_name
291 class(*),
contiguous,
target,
intent(inout) :: vdata(:,:,:)
294 integer,
intent(in),
optional :: unlim_dim_level
296 integer,
dimension(3),
intent(in),
optional :: corner
300 integer,
dimension(3),
intent(in),
optional :: edge_lengths
305 integer :: xdim_index
306 integer :: ydim_index
318 logical :: buffer_includes_halos
323 type(domain2d),
pointer :: io_domain
326 integer(kind=i4_kind),
dimension(:,:,:),
allocatable :: buf_i4_kind_pe
327 integer(kind=i8_kind),
dimension(:,:,:),
allocatable :: buf_i8_kind_pe
328 real(kind=r4_kind),
dimension(:,:,:),
allocatable :: buf_r4_kind_pe
329 real(kind=r8_kind),
dimension(:,:,:),
allocatable :: buf_r8_kind_pe
330 integer(kind=i4_kind),
dimension(:,:,:),
allocatable :: buf_i4_kind
331 integer(kind=i8_kind),
dimension(:,:,:),
allocatable :: buf_i8_kind
332 real(kind=r4_kind),
dimension(:,:,:),
allocatable :: buf_r4_kind
333 real(kind=r8_kind),
dimension(:,:,:),
allocatable :: buf_r8_kind
334 class(*),
dimension(:,:,:,:),
pointer :: vdata_dummy
336 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
337 xdim_index, ydim_index, xpos, ypos))
then
338 call netcdf_read_data(fileobj, variable_name, vdata, &
339 unlim_dim_level=unlim_dim_level, corner=corner, &
340 edge_lengths=edge_lengths, broadcast=.true.)
344 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
345 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, buffer_includes_halos, &
346 msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
348 if (fileobj%use_netcdf_mpi)
then
352 if (buffer_includes_halos)
then
355 e(xdim_index) = xc_size + 2*(isc - isd)
356 e(ydim_index) = yc_size + 2*(jsc - jsd)
360 e(xdim_index) = xc_size
361 e(ydim_index) = yc_size
364 call netcdf_read_data(fileobj, variable_name, vdata, unlim_dim_level=unlim_dim_level, corner=c, edge_lengths=e)
368 if (xdim_index .ne. 1 .or. ydim_index .ne. 2)
then
372 vdata_dummy(1:
size(vdata,1),1:
size(vdata,2), 1:
size(vdata,3), 1:1) => vdata(:,:,:)
373 call domain_read_4d(fileobj, variable_name, vdata_dummy, unlim_dim_level)
378 if (
present(corner)) c = corner
381 if (
present(edge_lengths)) e = edge_lengths
383 call mpp_get_global_domain(io_domain, xbegin=xgbegin, xsize=xgsize, position=xpos)
384 call mpp_get_global_domain(io_domain, ybegin=ygbegin, ysize=ygsize, position=ypos)
387 if (fileobj%is_root)
then
389 if (fileobj%adjust_indices)
then
396 c(xdim_index) = xgbegin
397 c(ydim_index) = ygbegin
400 e(xdim_index) = xgsize
401 e(ydim_index) = ygsize
405 type is (
integer(kind=i4_kind))
406 call allocate_array(buf_i4_kind, e)
407 call netcdf_read_data(fileobj, variable_name, buf_i4_kind, &
408 unlim_dim_level=unlim_dim_level, &
409 corner=c, edge_lengths=e, broadcast=.false.)
410 type is (
integer(kind=i8_kind))
411 call allocate_array(buf_i8_kind, e)
412 call netcdf_read_data(fileobj, variable_name, buf_i8_kind, &
413 unlim_dim_level=unlim_dim_level, &
414 corner=c, edge_lengths=e, broadcast=.false.)
415 type is (real(kind=r4_kind))
416 call allocate_array(buf_r4_kind, e)
417 call netcdf_read_data(fileobj, variable_name, buf_r4_kind, &
418 unlim_dim_level=unlim_dim_level, &
419 corner=c, edge_lengths=e, broadcast=.false.)
420 type is (real(kind=r8_kind))
421 call allocate_array(buf_r8_kind, e)
422 call netcdf_read_data(fileobj, variable_name, buf_r8_kind, &
423 unlim_dim_level=unlim_dim_level, &
424 corner=c, edge_lengths=e, broadcast=.false.)
426 call error(
"unsupported variable type: domain_read_2d: file: "//trim(fileobj%path)//
" variable:"// &
427 & trim(variable_name))
435 if (buffer_includes_halos)
then
437 c(xdim_index) = isc - isd + 1
438 c(ydim_index) = jsc - jsd + 1
444 e(xdim_index) = xc_size
445 e(ydim_index) = yc_size
448 type is (
integer(kind=i4_kind))
449 call allocate_array(buf_i4_kind_pe, e)
450 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
451 buf_i4_kind_pe, buf_i4_kind, fileobj%is_root)
452 call put_array_section(buf_i4_kind_pe, vdata, c, e)
453 deallocate(buf_i4_kind_pe)
454 type is (
integer(kind=i8_kind))
455 call allocate_array(buf_i8_kind_pe, e)
456 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
457 buf_i8_kind_pe, buf_i8_kind, fileobj%is_root)
458 call put_array_section(buf_i8_kind_pe, vdata, c, e)
459 deallocate(buf_i8_kind_pe)
460 type is (real(kind=r4_kind))
461 call allocate_array(buf_r4_kind_pe, e)
462 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
463 buf_r4_kind_pe, buf_r4_kind, fileobj%is_root)
464 call put_array_section(buf_r4_kind_pe, vdata, c, e)
465 deallocate(buf_r4_kind_pe)
466 type is (real(kind=r8_kind))
467 call allocate_array(buf_r8_kind_pe, e)
468 call mpp_scatter(isc-xgbegin+1, isc+xc_size-xgbegin, jsc-ygbegin+1, jsc+yc_size-ygbegin, e(3), fileobj%pelist, &
469 buf_r8_kind_pe, buf_r8_kind, fileobj%is_root)
470 call put_array_section(buf_r8_kind_pe, vdata, c, e)
471 deallocate(buf_r8_kind_pe)
473 call error(
"unsupported variable type: domain_read_2d: file: "//trim(fileobj%path)//
" variable:"// &
474 & trim(variable_name))
477 if (fileobj%is_root)
then
478 if (
allocated(buf_i4_kind))
deallocate(buf_i4_kind)
479 if (
allocated(buf_i8_kind))
deallocate(buf_i8_kind)
480 if (
allocated(buf_r4_kind))
deallocate(buf_r4_kind)
481 if (
allocated(buf_r8_kind))
deallocate(buf_r8_kind)
493 corner, edge_lengths)
495 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
496 character(len=*),
intent(in) :: variable_name
497 class(*),
dimension(:,:,:,:),
intent(inout) :: vdata
500 integer,
intent(in),
optional :: unlim_dim_level
502 integer,
dimension(4),
intent(in),
optional :: corner
506 integer,
dimension(4),
intent(in),
optional :: edge_lengths
511 integer :: xdim_index
512 integer :: ydim_index
513 type(domain2d),
pointer :: io_domain
523 integer,
dimension(:),
allocatable :: pe_isc
524 integer,
dimension(:),
allocatable :: pe_icsize
525 integer,
dimension(:),
allocatable :: pe_jsc
526 integer,
dimension(:),
allocatable :: pe_jcsize
527 integer,
dimension(4) :: c
528 integer,
dimension(4) :: e
529 integer(kind=i4_kind),
dimension(:,:,:,:),
allocatable :: buf_i4_kind
530 integer(kind=i8_kind),
dimension(:,:,:,:),
allocatable :: buf_i8_kind
531 real(kind=r4_kind),
dimension(:,:,:,:),
allocatable :: buf_r4_kind
532 real(kind=r8_kind),
dimension(:,:,:,:),
allocatable :: buf_r8_kind
533 logical :: buffer_includes_halos
537 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
538 xdim_index, ydim_index, xpos, ypos))
then
539 call netcdf_read_data(fileobj, variable_name, vdata, &
540 unlim_dim_level=unlim_dim_level, corner=corner, &
541 edge_lengths=edge_lengths, broadcast=.true.)
545 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
546 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, buffer_includes_halos, &
547 msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
549 if (fileobj%use_netcdf_mpi)
then
553 if (buffer_includes_halos)
then
556 e(xdim_index) = xc_size + 2*(isc - isd)
557 e(ydim_index) = yc_size + 2*(jsc - jsd)
561 e(xdim_index) = xc_size
562 e(ydim_index) = yc_size
565 call netcdf_read_data(fileobj, variable_name, vdata, unlim_dim_level=unlim_dim_level, corner=c, edge_lengths=e)
572 if (
present(edge_lengths)) e = edge_lengths
575 if (fileobj%is_root)
then
576 allocate(pe_isc(
size(fileobj%pelist)))
577 allocate(pe_icsize(
size(fileobj%pelist)))
578 allocate(pe_jsc(
size(fileobj%pelist)))
579 allocate(pe_jcsize(
size(fileobj%pelist)))
580 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xsize=pe_icsize, position=xpos)
581 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, ysize=pe_jcsize, position=ypos)
582 call mpp_get_global_domain(io_domain, xbegin=xgmin, position=xpos)
583 call mpp_get_global_domain(io_domain, ybegin=ygmin, position=ypos)
584 do i = 1,
size(fileobj%pelist)
585 if (
present(corner)) c = corner
586 c(xdim_index) = pe_isc(i)
587 c(ydim_index) = pe_jsc(i)
588 if (fileobj%adjust_indices)
then
589 c(xdim_index) = c(xdim_index) - xgmin + 1
590 c(ydim_index) = c(ydim_index) - ygmin + 1
592 e(xdim_index) = pe_icsize(i)
593 e(ydim_index) = pe_jcsize(i)
595 type is (
integer(kind=i4_kind))
597 call allocate_array(buf_i4_kind, e)
598 call netcdf_read_data(fileobj, variable_name, buf_i4_kind, &
599 unlim_dim_level=unlim_dim_level, &
600 corner=c, edge_lengths=e, broadcast=.false.)
604 if (buffer_includes_halos)
then
606 c(xdim_index) = isc - isd + 1
607 c(ydim_index) = jsc - jsd + 1
609 call put_array_section(buf_i4_kind, vdata, c, e)
612 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i))
615 deallocate(buf_i4_kind)
616 type is (
integer(kind=i8_kind))
618 call allocate_array(buf_i8_kind, e)
619 call netcdf_read_data(fileobj, variable_name, buf_i8_kind, &
620 unlim_dim_level=unlim_dim_level, &
621 corner=c, edge_lengths=e, broadcast=.false.)
625 if (buffer_includes_halos)
then
627 c(xdim_index) = isc - isd + 1
628 c(ydim_index) = jsc - jsd + 1
630 call put_array_section(buf_i8_kind, vdata, c, e)
633 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i))
636 deallocate(buf_i8_kind)
637 type is (real(kind=r4_kind))
639 call allocate_array(buf_r4_kind, e)
640 call netcdf_read_data(fileobj, variable_name, buf_r4_kind, &
641 unlim_dim_level=unlim_dim_level, &
642 corner=c, edge_lengths=e, broadcast=.false.)
646 if (buffer_includes_halos)
then
648 c(xdim_index) = isc - isd + 1
649 c(ydim_index) = jsc - jsd + 1
651 call put_array_section(buf_r4_kind, vdata, c, e)
654 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i))
657 deallocate(buf_r4_kind)
658 type is (real(kind=r8_kind))
660 call allocate_array(buf_r8_kind, e)
661 call netcdf_read_data(fileobj, variable_name, buf_r8_kind, &
662 unlim_dim_level=unlim_dim_level, &
663 corner=c, edge_lengths=e, broadcast=.false.)
667 if (buffer_includes_halos)
then
669 c(xdim_index) = isc - isd + 1
670 c(ydim_index) = jsc - jsd + 1
672 call put_array_section(buf_r8_kind, vdata, c, e)
675 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i))
678 deallocate(buf_r8_kind)
680 call error(
"unsupported variable type: domain_read_4d: file: "//trim(fileobj%path)//
" variable:"// &
681 & trim(variable_name))
685 deallocate(pe_icsize)
687 deallocate(pe_jcsize)
690 if (buffer_includes_halos)
then
691 c(xdim_index) = isc - isd + 1
692 c(ydim_index) = jsc - jsd + 1
694 e(xdim_index) = xc_size
695 e(ydim_index) = yc_size
697 type is (
integer(kind=i4_kind))
698 call allocate_array(buf_i4_kind, e)
699 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root, block=.true.)
700 call put_array_section(buf_i4_kind, vdata, c, e)
701 deallocate(buf_i4_kind)
702 type is (
integer(kind=i8_kind))
703 call allocate_array(buf_i8_kind, e)
704 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root, block=.true.)
705 call put_array_section(buf_i8_kind, vdata, c, e)
706 deallocate(buf_i8_kind)
707 type is (real(kind=r4_kind))
708 call allocate_array(buf_r4_kind, e)
709 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root, block=.true.)
710 call put_array_section(buf_r4_kind, vdata, c, e)
711 deallocate(buf_r4_kind)
712 type is (real(kind=r8_kind))
713 call allocate_array(buf_r8_kind, e)
714 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root, block=.true.)
715 call put_array_section(buf_r8_kind, vdata, c, e)
716 deallocate(buf_r8_kind)
718 call error(
"unsupported variable type: domain_read_4d: file: "//trim(fileobj%path)//
" variable:"// &
719 & trim(variable_name))
731 corner, edge_lengths)
733 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
734 character(len=*),
intent(in) :: variable_name
735 class(*),
dimension(:,:,:,:,:),
intent(inout) :: vdata
738 integer,
intent(in),
optional :: unlim_dim_level
740 integer,
dimension(5),
intent(in),
optional :: corner
744 integer,
dimension(5),
intent(in),
optional :: edge_lengths
749 integer :: xdim_index
750 integer :: ydim_index
751 type(domain2d),
pointer :: io_domain
761 integer,
dimension(:),
allocatable :: pe_isc
762 integer,
dimension(:),
allocatable :: pe_icsize
763 integer,
dimension(:),
allocatable :: pe_jsc
764 integer,
dimension(:),
allocatable :: pe_jcsize
765 integer,
dimension(5) :: c
766 integer,
dimension(5) :: e
767 integer(kind=i4_kind),
dimension(:,:,:,:,:),
allocatable :: buf_i4_kind
768 integer(kind=i8_kind),
dimension(:,:,:,:,:),
allocatable :: buf_i8_kind
769 real(kind=r4_kind),
dimension(:,:,:,:,:),
allocatable :: buf_r4_kind
770 real(kind=r8_kind),
dimension(:,:,:,:,:),
allocatable :: buf_r8_kind
771 logical :: buffer_includes_halos
775 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
776 xdim_index, ydim_index, xpos, ypos))
then
777 call netcdf_read_data(fileobj, variable_name, vdata, &
778 unlim_dim_level=unlim_dim_level, corner=corner, &
779 edge_lengths=edge_lengths, broadcast=.true.)
783 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
784 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, buffer_includes_halos, &
785 msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
787 if (fileobj%use_netcdf_mpi)
then
791 if (buffer_includes_halos)
then
794 e(xdim_index) = xc_size + 2*(isc - isd)
795 e(ydim_index) = yc_size + 2*(jsc - jsd)
799 e(xdim_index) = xc_size
800 e(ydim_index) = yc_size
803 call netcdf_read_data(fileobj, variable_name, vdata, unlim_dim_level=unlim_dim_level, corner=c, edge_lengths=e)
810 if (
present(edge_lengths)) e = edge_lengths
813 if (fileobj%is_root)
then
814 allocate(pe_isc(
size(fileobj%pelist)))
815 allocate(pe_icsize(
size(fileobj%pelist)))
816 allocate(pe_jsc(
size(fileobj%pelist)))
817 allocate(pe_jcsize(
size(fileobj%pelist)))
818 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xsize=pe_icsize, position=xpos)
819 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, ysize=pe_jcsize, position=ypos)
820 call mpp_get_global_domain(io_domain, xbegin=xgmin, position=xpos)
821 call mpp_get_global_domain(io_domain, ybegin=ygmin, position=ypos)
822 do i = 1,
size(fileobj%pelist)
824 if (
present(corner)) c = corner
825 c(xdim_index) = pe_isc(i)
826 c(ydim_index) = pe_jsc(i)
827 if (fileobj%adjust_indices)
then
828 c(xdim_index) = c(xdim_index) - xgmin + 1
829 c(ydim_index) = c(ydim_index) - ygmin + 1
831 e(xdim_index) = pe_icsize(i)
832 e(ydim_index) = pe_jcsize(i)
834 type is (
integer(kind=i4_kind))
836 call allocate_array(buf_i4_kind, e)
837 call netcdf_read_data(fileobj, variable_name, buf_i4_kind, &
838 unlim_dim_level=unlim_dim_level, &
839 corner=c, edge_lengths=e, broadcast=.false.)
844 if (buffer_includes_halos)
then
846 c(xdim_index) = isc - isd + 1
847 c(ydim_index) = jsc - jsd + 1
849 call put_array_section(buf_i4_kind, vdata, c, e)
852 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i))
855 deallocate(buf_i4_kind)
856 type is (
integer(kind=i8_kind))
858 call allocate_array(buf_i8_kind, e)
859 call netcdf_read_data(fileobj, variable_name, buf_i8_kind, &
860 unlim_dim_level=unlim_dim_level, &
861 corner=c, edge_lengths=e, broadcast=.false.)
865 if (buffer_includes_halos)
then
867 c(xdim_index) = isc - isd + 1
868 c(ydim_index) = jsc - jsd + 1
870 call put_array_section(buf_i8_kind, vdata, c, e)
873 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i))
876 deallocate(buf_i8_kind)
877 type is (real(kind=r4_kind))
879 call allocate_array(buf_r4_kind, e)
880 call netcdf_read_data(fileobj, variable_name, buf_r4_kind, &
881 unlim_dim_level=unlim_dim_level, &
882 corner=c, edge_lengths=e, broadcast=.false.)
886 if (buffer_includes_halos)
then
888 c(xdim_index) = isc - isd + 1
889 c(ydim_index) = jsc - jsd + 1
891 call put_array_section(buf_r4_kind, vdata, c, e)
894 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i))
897 deallocate(buf_r4_kind)
898 type is (real(kind=r8_kind))
900 call allocate_array(buf_r8_kind, e)
901 call netcdf_read_data(fileobj, variable_name, buf_r8_kind, &
902 unlim_dim_level=unlim_dim_level, &
903 corner=c, edge_lengths=e, broadcast=.false.)
907 if (buffer_includes_halos)
then
909 c(xdim_index) = isc - isd + 1
910 c(ydim_index) = jsc - jsd + 1
912 call put_array_section(buf_r8_kind, vdata, c, e)
915 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i))
918 deallocate(buf_r8_kind)
920 call error(
"unsupported variable type: domain_read_5d: file: "//trim(fileobj%path)//
" variable:"// &
921 & trim(variable_name))
925 deallocate(pe_icsize)
927 deallocate(pe_jcsize)
930 if (buffer_includes_halos)
then
931 c(xdim_index) = isc - isd + 1
932 c(ydim_index) = jsc - jsd + 1
934 e(xdim_index) = xc_size
935 e(ydim_index) = yc_size
937 type is (
integer(kind=i4_kind))
938 call allocate_array(buf_i4_kind, e)
939 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root, block=.true.)
940 call put_array_section(buf_i4_kind, vdata, c, e)
941 deallocate(buf_i4_kind)
942 type is (
integer(kind=i8_kind))
943 call allocate_array(buf_i8_kind, e)
944 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root, block=.true.)
945 call put_array_section(buf_i8_kind, vdata, c, e)
946 deallocate(buf_i8_kind)
947 type is (real(kind=r4_kind))
948 call allocate_array(buf_r4_kind, e)
949 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root, block=.true.)
950 call put_array_section(buf_r4_kind, vdata, c, e)
951 deallocate(buf_r4_kind)
952 type is (real(kind=r8_kind))
953 call allocate_array(buf_r8_kind, e)
954 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root, block=.true.)
955 call put_array_section(buf_r8_kind, vdata, c, e)
956 deallocate(buf_r8_kind)
958 call error(
"unsupported variable type: domain_read_5d: file: "//trim(fileobj%path)//
" variable:"// &
959 & trim(variable_name))
subroutine domain_read_0d(fileobj, variable_name, vdata, unlim_dim_level, corner)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine domain_read_1d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine domain_read_2d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine domain_read_4d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine domain_read_5d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
type(domain2d) function, pointer mpp_get_io_domain(domain)
Set user stack size.
subroutine mpp_sync_self(pelist, check, request, msg_size, msg_type)
This is to check if current PE's outstanding puts are complete but we can't use shmem_fence because w...