29 subroutine domain_write_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(in) :: vdata
36 integer,
intent(in),
optional :: unlim_dim_level
38 integer,
intent(in),
optional :: corner
43 call compressed_write(fileobj, variable_name, vdata, &
44 unlim_dim_level=unlim_dim_level, corner=corner)
56 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
57 character(len=*),
intent(in) :: variable_name
58 class(*),
dimension(:),
intent(in) :: vdata
61 integer,
intent(in),
optional :: unlim_dim_level
63 integer,
dimension(1),
intent(in),
optional :: corner
67 integer,
dimension(1),
intent(in),
optional :: edge_lengths
72 call compressed_write(fileobj, variable_name, vdata, &
73 unlim_dim_level=unlim_dim_level, corner=corner, &
74 edge_lengths=edge_lengths)
86 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
87 character(len=*),
intent(in) :: variable_name
88 class(*),
dimension(:,:),
intent(in) :: vdata
91 integer,
intent(in),
optional :: unlim_dim_level
93 integer,
dimension(2),
intent(in),
optional :: corner
97 integer,
dimension(2),
intent(in),
optional :: edge_lengths
102 integer(kind=i4_kind),
dimension(:,:),
allocatable :: buf_i4_kind
103 integer(kind=i8_kind),
dimension(:,:),
allocatable :: buf_i8_kind
104 real(kind=r4_kind),
dimension(:,:),
allocatable :: buf_r4_kind
105 real(kind=r8_kind),
dimension(:,:),
allocatable :: buf_r8_kind
106 logical :: buffer_includes_halos
107 integer,
dimension(2) :: c
108 integer,
dimension(2) :: e
109 integer(kind=i4_kind),
dimension(:,:),
allocatable :: global_buf_i4_kind
110 integer(kind=i8_kind),
dimension(:,:),
allocatable :: global_buf_i8_kind
111 real(kind=r4_kind),
dimension(:,:),
allocatable :: global_buf_r4_kind
112 real(kind=r8_kind),
dimension(:,:),
allocatable :: global_buf_r8_kind
114 type(domain2d),
pointer :: io_domain
119 integer,
dimension(:),
allocatable :: pe_icsize
120 integer,
dimension(:),
allocatable :: pe_iec
121 integer,
dimension(:),
allocatable :: pe_isc
122 integer,
dimension(:),
allocatable :: pe_jcsize
123 integer,
dimension(:),
allocatable :: pe_jec
124 integer,
dimension(:),
allocatable :: pe_jsc
126 integer :: xdim_index
128 integer :: ydim_index
131 integer(kind=i4_kind) :: fill_i4_kind
132 integer(kind=i8_kind) :: fill_i8_kind
133 real(kind=r4_kind) :: fill_r4_kind
134 real(kind=r8_kind) :: fill_r8_kind
140 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
141 xdim_index, ydim_index, xpos, ypos))
then
142 call compressed_write(fileobj, variable_name, vdata, &
143 unlim_dim_level=unlim_dim_level, corner=corner, &
144 edge_lengths=edge_lengths)
148 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
149 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, &
150 buffer_includes_halos, msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
155 if (fileobj%is_root)
then
156 allocate(pe_isc(
size(fileobj%pelist)))
157 allocate(pe_iec(
size(fileobj%pelist)))
158 allocate(pe_icsize(
size(fileobj%pelist)))
159 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xend=pe_iec, xsize=pe_icsize, &
161 allocate(pe_jsc(
size(fileobj%pelist)))
162 allocate(pe_jec(
size(fileobj%pelist)))
163 allocate(pe_jcsize(
size(fileobj%pelist)))
164 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, yend=pe_jec, ysize=pe_jcsize, &
168 call mpp_get_global_domain(io_domain, ybegin=ygmin, yend=ygmax, position=ypos)
169 call mpp_get_global_domain(io_domain, xbegin=xgmin, xend=xgmax, position=xpos)
173 e(xdim_index) = xgmax - xgmin + 1
174 e(ydim_index) = ygmax - ygmin + 1
179 type is (
integer(kind=i4_kind))
180 call allocate_array(global_buf_i4_kind, e)
181 global_buf_i4_kind = 0
182 if (get_fill_value(fileobj, variable_name, fill_i4_kind, broadcast=.false.))
then
183 global_buf_i4_kind = fill_i4_kind
185 type is (
integer(kind=i8_kind))
186 call allocate_array(global_buf_i8_kind, e)
187 global_buf_i8_kind = 0
188 if (get_fill_value(fileobj, variable_name, fill_i8_kind, broadcast=.false.))
then
189 global_buf_i8_kind = fill_i8_kind
191 type is (real(kind=r4_kind))
192 call allocate_array(global_buf_r4_kind, e)
193 global_buf_r4_kind = 0.
194 if (get_fill_value(fileobj, variable_name, fill_r4_kind, broadcast=.false.))
then
195 global_buf_r4_kind = fill_r4_kind
197 type is (real(kind=r8_kind))
198 call allocate_array(global_buf_r8_kind, e)
199 global_buf_r8_kind = 0.
200 if (get_fill_value(fileobj, variable_name, fill_r8_kind, broadcast=.false.))
then
201 global_buf_r8_kind = fill_r8_kind
204 call error(
"unsupported variable type: domain_write_2d: file: "//trim(fileobj%path)//
" variable:"// &
205 & trim(variable_name))
208 do i = 1,
size(fileobj%pelist)
210 c(xdim_index) = pe_isc(i) - xgmin + 1
211 c(ydim_index) = pe_jsc(i) - ygmin + 1
212 e(xdim_index) = pe_icsize(i)
213 e(ydim_index) = pe_jcsize(i)
215 type is (
integer(kind=i4_kind))
216 call allocate_array(buf_i4_kind, e)
220 if (buffer_includes_halos)
then
222 c(xdim_index) = isc - isd + 1
223 c(ydim_index) = jsc - jsd + 1
228 call get_array_section(buf_i4_kind, vdata, c, e)
229 c(xdim_index) = pe_isc(i) - xgmin + 1
230 c(ydim_index) = pe_jsc(i) - ygmin + 1
233 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i), block=.true.)
236 call put_array_section(buf_i4_kind, global_buf_i4_kind, c, e)
237 deallocate(buf_i4_kind)
238 type is (
integer(kind=i8_kind))
239 call allocate_array(buf_i8_kind, e)
243 if (buffer_includes_halos)
then
245 c(xdim_index) = isc - isd + 1
246 c(ydim_index) = jsc - jsd + 1
251 call get_array_section(buf_i8_kind, vdata, c, e)
252 c(xdim_index) = pe_isc(i) - xgmin + 1
253 c(ydim_index) = pe_jsc(i) - ygmin + 1
256 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i), block=.true.)
259 call put_array_section(buf_i8_kind, global_buf_i8_kind, c, e)
260 deallocate(buf_i8_kind)
261 type is (real(kind=r4_kind))
262 call allocate_array(buf_r4_kind, e)
266 if (buffer_includes_halos)
then
268 c(xdim_index) = isc - isd + 1
269 c(ydim_index) = jsc - jsd + 1
274 call get_array_section(buf_r4_kind, vdata, c, e)
275 c(xdim_index) = pe_isc(i) - xgmin + 1
276 c(ydim_index) = pe_jsc(i) - ygmin + 1
279 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i), block=.true.)
282 call put_array_section(buf_r4_kind, global_buf_r4_kind, c, e)
283 deallocate(buf_r4_kind)
284 type is (real(kind=r8_kind))
285 call allocate_array(buf_r8_kind, e)
289 if (buffer_includes_halos)
then
291 c(xdim_index) = isc - isd + 1
292 c(ydim_index) = jsc - jsd + 1
297 call get_array_section(buf_r8_kind, vdata, c, e)
298 c(xdim_index) = pe_isc(i) - xgmin + 1
299 c(ydim_index) = pe_jsc(i) - ygmin + 1
302 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i), block=.true.)
305 call put_array_section(buf_r8_kind, global_buf_r8_kind, c, e)
306 deallocate(buf_r8_kind)
311 deallocate(pe_icsize)
314 deallocate(pe_jcsize)
318 type is (
integer(kind=i4_kind))
319 call netcdf_write_data(fileobj, variable_name, global_buf_i4_kind, &
320 unlim_dim_level=unlim_dim_level)
321 deallocate(global_buf_i4_kind)
322 type is (
integer(kind=i8_kind))
323 call netcdf_write_data(fileobj, variable_name, global_buf_i8_kind, &
324 unlim_dim_level=unlim_dim_level)
325 deallocate(global_buf_i8_kind)
326 type is (real(kind=r4_kind))
327 call netcdf_write_data(fileobj, variable_name, global_buf_r4_kind, &
328 unlim_dim_level=unlim_dim_level)
329 deallocate(global_buf_r4_kind)
330 type is (real(kind=r8_kind))
331 call netcdf_write_data(fileobj, variable_name, global_buf_r8_kind, &
332 unlim_dim_level=unlim_dim_level)
333 deallocate(global_buf_r8_kind)
336 if (buffer_includes_halos)
then
337 c(xdim_index) = isc - isd + 1
338 c(ydim_index) = jsc - jsd + 1
340 e(xdim_index) = xc_size
341 e(ydim_index) = yc_size
343 type is (
integer(kind=i4_kind))
344 call allocate_array(buf_i4_kind, e)
345 call get_array_section(buf_i4_kind, vdata, c, e)
346 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root)
348 deallocate(buf_i4_kind)
349 type is (
integer(kind=i8_kind))
350 call allocate_array(buf_i8_kind, e)
351 call get_array_section(buf_i8_kind, vdata, c, e)
352 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root)
354 deallocate(buf_i8_kind)
355 type is (real(kind=r4_kind))
356 call allocate_array(buf_r4_kind, e)
357 call get_array_section(buf_r4_kind, vdata, c, e)
358 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root)
360 deallocate(buf_r4_kind)
361 type is (real(kind=r8_kind))
362 call allocate_array(buf_r8_kind, e)
363 call get_array_section(buf_r8_kind, vdata, c, e)
364 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root)
366 deallocate(buf_r8_kind)
368 call error(
"unsupported variable type: domain_write_2d: file: "//trim(fileobj%path)//
" variable:"// &
369 & trim(variable_name))
380 corner, edge_lengths)
382 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
383 character(len=*),
intent(in) :: variable_name
384 class(*),
dimension(:,:,:),
intent(in) :: vdata
387 integer,
intent(in),
optional :: unlim_dim_level
389 integer,
dimension(3),
intent(in),
optional :: corner
393 integer,
dimension(3),
intent(in),
optional :: edge_lengths
398 integer(kind=i4_kind),
dimension(:,:,:),
allocatable :: buf_i4_kind
399 integer(kind=i8_kind),
dimension(:,:,:),
allocatable :: buf_i8_kind
400 real(kind=r4_kind),
dimension(:,:,:),
allocatable :: buf_r4_kind
401 real(kind=r8_kind),
dimension(:,:,:),
allocatable :: buf_r8_kind
402 logical :: buffer_includes_halos
403 integer,
dimension(3) :: c
404 integer,
dimension(3) :: e
405 integer(kind=i4_kind),
dimension(:,:,:),
allocatable :: global_buf_i4_kind
406 integer(kind=i8_kind),
dimension(:,:,:),
allocatable :: global_buf_i8_kind
407 real(kind=r4_kind),
dimension(:,:,:),
allocatable :: global_buf_r4_kind
408 real(kind=r8_kind),
dimension(:,:,:),
allocatable :: global_buf_r8_kind
410 type(domain2d),
pointer :: io_domain
415 integer,
dimension(:),
allocatable :: pe_icsize
416 integer,
dimension(:),
allocatable :: pe_iec
417 integer,
dimension(:),
allocatable :: pe_isc
418 integer,
dimension(:),
allocatable :: pe_jcsize
419 integer,
dimension(:),
allocatable :: pe_jec
420 integer,
dimension(:),
allocatable :: pe_jsc
422 integer :: xdim_index
424 integer :: ydim_index
427 integer(kind=i4_kind) :: fill_i4_kind
428 integer(kind=i8_kind) :: fill_i8_kind
429 real(kind=r4_kind) :: fill_r4_kind
430 real(kind=r8_kind) :: fill_r8_kind
436 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
437 xdim_index, ydim_index, xpos, ypos))
then
438 call compressed_write(fileobj, variable_name, vdata, &
439 unlim_dim_level=unlim_dim_level, corner=corner, &
440 edge_lengths=edge_lengths)
444 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
445 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, &
446 buffer_includes_halos, msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
451 if (fileobj%is_root)
then
452 allocate(pe_isc(
size(fileobj%pelist)))
453 allocate(pe_iec(
size(fileobj%pelist)))
454 allocate(pe_icsize(
size(fileobj%pelist)))
455 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xend=pe_iec, xsize=pe_icsize, &
457 allocate(pe_jsc(
size(fileobj%pelist)))
458 allocate(pe_jec(
size(fileobj%pelist)))
459 allocate(pe_jcsize(
size(fileobj%pelist)))
460 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, yend=pe_jec, ysize=pe_jcsize, &
464 call mpp_get_global_domain(io_domain, ybegin=ygmin, yend=ygmax, position=ypos)
465 call mpp_get_global_domain(io_domain, xbegin=xgmin, xend=xgmax, position=xpos)
469 e(xdim_index) = xgmax - xgmin + 1
470 e(ydim_index) = ygmax - ygmin + 1
475 type is (
integer(kind=i4_kind))
476 call allocate_array(global_buf_i4_kind, e)
477 global_buf_i4_kind = 0
478 if (get_fill_value(fileobj, variable_name, fill_i4_kind, broadcast=.false.))
then
479 global_buf_i4_kind = fill_i4_kind
481 type is (
integer(kind=i8_kind))
482 call allocate_array(global_buf_i8_kind, e)
483 global_buf_i8_kind = 0
484 if (get_fill_value(fileobj, variable_name, fill_i8_kind, broadcast=.false.))
then
485 global_buf_i8_kind = fill_i8_kind
487 type is (real(kind=r4_kind))
488 call allocate_array(global_buf_r4_kind, e)
489 global_buf_r4_kind = 0.
490 if (get_fill_value(fileobj, variable_name, fill_r4_kind, broadcast=.false.))
then
491 global_buf_r4_kind = fill_r4_kind
493 type is (real(kind=r8_kind))
494 call allocate_array(global_buf_r8_kind, e)
495 global_buf_r8_kind = 0.
496 if (get_fill_value(fileobj, variable_name, fill_r8_kind, broadcast=.false.))
then
497 global_buf_r8_kind = fill_r8_kind
500 call error(
"unsupported variable type: domain_write_3d: file: "//trim(fileobj%path)//
" variable:"// &
501 & trim(variable_name))
504 do i = 1,
size(fileobj%pelist)
506 c(xdim_index) = pe_isc(i) - xgmin + 1
507 c(ydim_index) = pe_jsc(i) - ygmin + 1
508 e(xdim_index) = pe_icsize(i)
509 e(ydim_index) = pe_jcsize(i)
511 type is (
integer(kind=i4_kind))
512 call allocate_array(buf_i4_kind, e)
516 if (buffer_includes_halos)
then
518 c(xdim_index) = isc - isd + 1
519 c(ydim_index) = jsc - jsd + 1
524 call get_array_section(buf_i4_kind, vdata, c, e)
525 c(xdim_index) = pe_isc(i) - xgmin + 1
526 c(ydim_index) = pe_jsc(i) - ygmin + 1
529 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i), block=.true.)
532 call put_array_section(buf_i4_kind, global_buf_i4_kind, c, e)
533 deallocate(buf_i4_kind)
534 type is (
integer(kind=i8_kind))
535 call allocate_array(buf_i8_kind, e)
539 if (buffer_includes_halos)
then
541 c(xdim_index) = isc - isd + 1
542 c(ydim_index) = jsc - jsd + 1
547 call get_array_section(buf_i8_kind, vdata, c, e)
548 c(xdim_index) = pe_isc(i) - xgmin + 1
549 c(ydim_index) = pe_jsc(i) - ygmin + 1
552 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i), block=.true.)
555 call put_array_section(buf_i8_kind, global_buf_i8_kind, c, e)
556 deallocate(buf_i8_kind)
557 type is (real(kind=r4_kind))
558 call allocate_array(buf_r4_kind, e)
562 if (buffer_includes_halos)
then
564 c(xdim_index) = isc - isd + 1
565 c(ydim_index) = jsc - jsd + 1
570 call get_array_section(buf_r4_kind, vdata, c, e)
571 c(xdim_index) = pe_isc(i) - xgmin + 1
572 c(ydim_index) = pe_jsc(i) - ygmin + 1
575 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i), block=.true.)
578 call put_array_section(buf_r4_kind, global_buf_r4_kind, c, e)
579 deallocate(buf_r4_kind)
580 type is (real(kind=r8_kind))
581 call allocate_array(buf_r8_kind, e)
585 if (buffer_includes_halos)
then
587 c(xdim_index) = isc - isd + 1
588 c(ydim_index) = jsc - jsd + 1
593 call get_array_section(buf_r8_kind, vdata, c, e)
594 c(xdim_index) = pe_isc(i) - xgmin + 1
595 c(ydim_index) = pe_jsc(i) - ygmin + 1
598 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i), block=.true.)
601 call put_array_section(buf_r8_kind, global_buf_r8_kind, c, e)
602 deallocate(buf_r8_kind)
607 deallocate(pe_icsize)
610 deallocate(pe_jcsize)
614 type is (
integer(kind=i4_kind))
615 call netcdf_write_data(fileobj, variable_name, global_buf_i4_kind, &
616 unlim_dim_level=unlim_dim_level)
617 deallocate(global_buf_i4_kind)
618 type is (
integer(kind=i8_kind))
619 call netcdf_write_data(fileobj, variable_name, global_buf_i8_kind, &
620 unlim_dim_level=unlim_dim_level)
621 deallocate(global_buf_i8_kind)
622 type is (real(kind=r4_kind))
623 call netcdf_write_data(fileobj, variable_name, global_buf_r4_kind, &
624 unlim_dim_level=unlim_dim_level)
625 deallocate(global_buf_r4_kind)
626 type is (real(kind=r8_kind))
627 call netcdf_write_data(fileobj, variable_name, global_buf_r8_kind, &
628 unlim_dim_level=unlim_dim_level)
629 deallocate(global_buf_r8_kind)
632 if (buffer_includes_halos)
then
633 c(xdim_index) = isc - isd + 1
634 c(ydim_index) = jsc - jsd + 1
636 e(xdim_index) = xc_size
637 e(ydim_index) = yc_size
639 type is (
integer(kind=i4_kind))
640 call allocate_array(buf_i4_kind, e)
641 call get_array_section(buf_i4_kind, vdata, c, e)
642 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root)
644 deallocate(buf_i4_kind)
645 type is (
integer(kind=i8_kind))
646 call allocate_array(buf_i8_kind, e)
647 call get_array_section(buf_i8_kind, vdata, c, e)
648 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root)
650 deallocate(buf_i8_kind)
651 type is (real(kind=r4_kind))
652 call allocate_array(buf_r4_kind, e)
653 call get_array_section(buf_r4_kind, vdata, c, e)
654 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root)
656 deallocate(buf_r4_kind)
657 type is (real(kind=r8_kind))
658 call allocate_array(buf_r8_kind, e)
659 call get_array_section(buf_r8_kind, vdata, c, e)
660 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root)
662 deallocate(buf_r8_kind)
664 call error(
"unsupported variable type: domain_write_3d: file: "//trim(fileobj%path)//
" variable:"// &
665 & trim(variable_name))
676 corner, edge_lengths)
678 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
679 character(len=*),
intent(in) :: variable_name
680 class(*),
dimension(:,:,:,:),
intent(in) :: vdata
683 integer,
intent(in),
optional :: unlim_dim_level
685 integer,
dimension(4),
intent(in),
optional :: corner
689 integer,
dimension(4),
intent(in),
optional :: edge_lengths
694 integer(kind=i4_kind),
dimension(:,:,:,:),
allocatable :: buf_i4_kind
695 integer(kind=i8_kind),
dimension(:,:,:,:),
allocatable :: buf_i8_kind
696 real(kind=r4_kind),
dimension(:,:,:,:),
allocatable :: buf_r4_kind
697 real(kind=r8_kind),
dimension(:,:,:,:),
allocatable :: buf_r8_kind
698 logical :: buffer_includes_halos
699 integer,
dimension(4) :: c
700 integer,
dimension(4) :: e
701 integer(kind=i4_kind),
dimension(:,:,:,:),
allocatable :: global_buf_i4_kind
702 integer(kind=i8_kind),
dimension(:,:,:,:),
allocatable :: global_buf_i8_kind
703 real(kind=r4_kind),
dimension(:,:,:,:),
allocatable :: global_buf_r4_kind
704 real(kind=r8_kind),
dimension(:,:,:,:),
allocatable :: global_buf_r8_kind
706 type(domain2d),
pointer :: io_domain
711 integer,
dimension(:),
allocatable :: pe_icsize
712 integer,
dimension(:),
allocatable :: pe_iec
713 integer,
dimension(:),
allocatable :: pe_isc
714 integer,
dimension(:),
allocatable :: pe_jcsize
715 integer,
dimension(:),
allocatable :: pe_jec
716 integer,
dimension(:),
allocatable :: pe_jsc
718 integer :: xdim_index
720 integer :: ydim_index
723 integer(kind=i4_kind) :: fill_i4_kind
724 integer(kind=i8_kind) :: fill_i8_kind
725 real(kind=r4_kind) :: fill_r4_kind
726 real(kind=r8_kind) :: fill_r8_kind
732 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
733 xdim_index, ydim_index, xpos, ypos))
then
734 call compressed_write(fileobj, variable_name, vdata, &
735 unlim_dim_level=unlim_dim_level, corner=corner, &
736 edge_lengths=edge_lengths)
740 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
741 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, &
742 buffer_includes_halos, msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
747 if (fileobj%is_root)
then
748 allocate(pe_isc(
size(fileobj%pelist)))
749 allocate(pe_iec(
size(fileobj%pelist)))
750 allocate(pe_icsize(
size(fileobj%pelist)))
751 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xend=pe_iec, xsize=pe_icsize, &
753 allocate(pe_jsc(
size(fileobj%pelist)))
754 allocate(pe_jec(
size(fileobj%pelist)))
755 allocate(pe_jcsize(
size(fileobj%pelist)))
756 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, yend=pe_jec, ysize=pe_jcsize, &
760 call mpp_get_global_domain(io_domain, ybegin=ygmin, yend=ygmax, position=ypos)
761 call mpp_get_global_domain(io_domain, xbegin=xgmin, xend=xgmax, position=xpos)
765 e(xdim_index) = xgmax - xgmin + 1
766 e(ydim_index) = ygmax - ygmin + 1
771 type is (
integer(kind=i4_kind))
772 call allocate_array(global_buf_i4_kind, e)
773 global_buf_i4_kind = 0
774 if (get_fill_value(fileobj, variable_name, fill_i4_kind, broadcast=.false.))
then
775 global_buf_i4_kind = fill_i4_kind
777 type is (
integer(kind=i8_kind))
778 call allocate_array(global_buf_i8_kind, e)
779 global_buf_i8_kind = 0
780 if (get_fill_value(fileobj, variable_name, fill_i8_kind, broadcast=.false.))
then
781 global_buf_i8_kind = fill_i8_kind
783 type is (real(kind=r4_kind))
784 call allocate_array(global_buf_r4_kind, e)
785 global_buf_r4_kind = 0.
786 if (get_fill_value(fileobj, variable_name, fill_r4_kind, broadcast=.false.))
then
787 global_buf_r4_kind = fill_r4_kind
789 type is (real(kind=r8_kind))
790 call allocate_array(global_buf_r8_kind, e)
791 global_buf_r8_kind = 0.
792 if (get_fill_value(fileobj, variable_name, fill_r8_kind, broadcast=.false.))
then
793 global_buf_r8_kind = fill_r8_kind
796 call error(
"unsupported variable type: domain_write_4d: file: "//trim(fileobj%path)//
" variable:"// &
797 & trim(variable_name))
800 do i = 1,
size(fileobj%pelist)
802 c(xdim_index) = pe_isc(i) - xgmin + 1
803 c(ydim_index) = pe_jsc(i) - ygmin + 1
804 e(xdim_index) = pe_icsize(i)
805 e(ydim_index) = pe_jcsize(i)
807 type is (
integer(kind=i4_kind))
808 call allocate_array(buf_i4_kind, e)
812 if (buffer_includes_halos)
then
814 c(xdim_index) = isc - isd + 1
815 c(ydim_index) = jsc - jsd + 1
820 call get_array_section(buf_i4_kind, vdata, c, e)
821 c(xdim_index) = pe_isc(i) - xgmin + 1
822 c(ydim_index) = pe_jsc(i) - ygmin + 1
825 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i), block=.true.)
828 call put_array_section(buf_i4_kind, global_buf_i4_kind, c, e)
829 deallocate(buf_i4_kind)
830 type is (
integer(kind=i8_kind))
831 call allocate_array(buf_i8_kind, e)
835 if (buffer_includes_halos)
then
837 c(xdim_index) = isc - isd + 1
838 c(ydim_index) = jsc - jsd + 1
843 call get_array_section(buf_i8_kind, vdata, c, e)
844 c(xdim_index) = pe_isc(i) - xgmin + 1
845 c(ydim_index) = pe_jsc(i) - ygmin + 1
848 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i), block=.true.)
851 call put_array_section(buf_i8_kind, global_buf_i8_kind, c, e)
852 deallocate(buf_i8_kind)
853 type is (real(kind=r4_kind))
854 call allocate_array(buf_r4_kind, e)
858 if (buffer_includes_halos)
then
860 c(xdim_index) = isc - isd + 1
861 c(ydim_index) = jsc - jsd + 1
866 call get_array_section(buf_r4_kind, vdata, c, e)
867 c(xdim_index) = pe_isc(i) - xgmin + 1
868 c(ydim_index) = pe_jsc(i) - ygmin + 1
871 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i), block=.true.)
874 call put_array_section(buf_r4_kind, global_buf_r4_kind, c, e)
875 deallocate(buf_r4_kind)
876 type is (real(kind=r8_kind))
877 call allocate_array(buf_r8_kind, e)
881 if (buffer_includes_halos)
then
883 c(xdim_index) = isc - isd + 1
884 c(ydim_index) = jsc - jsd + 1
889 call get_array_section(buf_r8_kind, vdata, c, e)
890 c(xdim_index) = pe_isc(i) - xgmin + 1
891 c(ydim_index) = pe_jsc(i) - ygmin + 1
894 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i), block=.true.)
897 call put_array_section(buf_r8_kind, global_buf_r8_kind, c, e)
898 deallocate(buf_r8_kind)
903 deallocate(pe_icsize)
906 deallocate(pe_jcsize)
910 type is (
integer(kind=i4_kind))
911 call netcdf_write_data(fileobj, variable_name, global_buf_i4_kind, &
912 unlim_dim_level=unlim_dim_level)
913 deallocate(global_buf_i4_kind)
914 type is (
integer(kind=i8_kind))
915 call netcdf_write_data(fileobj, variable_name, global_buf_i8_kind, &
916 unlim_dim_level=unlim_dim_level)
917 deallocate(global_buf_i8_kind)
918 type is (real(kind=r4_kind))
919 call netcdf_write_data(fileobj, variable_name, global_buf_r4_kind, &
920 unlim_dim_level=unlim_dim_level)
921 deallocate(global_buf_r4_kind)
922 type is (real(kind=r8_kind))
923 call netcdf_write_data(fileobj, variable_name, global_buf_r8_kind, &
924 unlim_dim_level=unlim_dim_level)
925 deallocate(global_buf_r8_kind)
928 if (buffer_includes_halos)
then
929 c(xdim_index) = isc - isd + 1
930 c(ydim_index) = jsc - jsd + 1
932 e(xdim_index) = xc_size
933 e(ydim_index) = yc_size
935 type is (
integer(kind=i4_kind))
936 call allocate_array(buf_i4_kind, e)
937 call get_array_section(buf_i4_kind, vdata, c, e)
938 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root)
940 deallocate(buf_i4_kind)
941 type is (
integer(kind=i8_kind))
942 call allocate_array(buf_i8_kind, e)
943 call get_array_section(buf_i8_kind, vdata, c, e)
944 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root)
946 deallocate(buf_i8_kind)
947 type is (real(kind=r4_kind))
948 call allocate_array(buf_r4_kind, e)
949 call get_array_section(buf_r4_kind, vdata, c, e)
950 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root)
952 deallocate(buf_r4_kind)
953 type is (real(kind=r8_kind))
954 call allocate_array(buf_r8_kind, e)
955 call get_array_section(buf_r8_kind, vdata, c, e)
956 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root)
958 deallocate(buf_r8_kind)
960 call error(
"unsupported variable type: domain_write_4d: file: "//trim(fileobj%path)//
" variable:"// &
961 & trim(variable_name))
972 corner, edge_lengths)
974 type(fmsnetcdfdomainfile_t),
intent(in) :: fileobj
975 character(len=*),
intent(in) :: variable_name
976 class(*),
dimension(:,:,:,:,:),
intent(in) :: vdata
979 integer,
intent(in),
optional :: unlim_dim_level
981 integer,
dimension(5),
intent(in),
optional :: corner
985 integer,
dimension(5),
intent(in),
optional :: edge_lengths
990 integer(kind=i4_kind),
dimension(:,:,:,:,:),
allocatable :: buf_i4_kind
991 integer(kind=i8_kind),
dimension(:,:,:,:,:),
allocatable :: buf_i8_kind
992 real(kind=r4_kind),
dimension(:,:,:,:,:),
allocatable :: buf_r4_kind
993 real(kind=r8_kind),
dimension(:,:,:,:,:),
allocatable :: buf_r8_kind
994 logical :: buffer_includes_halos
995 integer,
dimension(5) :: c
996 integer,
dimension(5) :: e
997 integer(kind=i4_kind),
dimension(:,:,:,:,:),
allocatable :: global_buf_i4_kind
998 integer(kind=i8_kind),
dimension(:,:,:,:,:),
allocatable :: global_buf_i8_kind
999 real(kind=r4_kind),
dimension(:,:,:,:,:),
allocatable :: global_buf_r4_kind
1000 real(kind=r8_kind),
dimension(:,:,:,:,:),
allocatable :: global_buf_r8_kind
1002 type(domain2d),
pointer :: io_domain
1007 integer,
dimension(:),
allocatable :: pe_icsize
1008 integer,
dimension(:),
allocatable :: pe_iec
1009 integer,
dimension(:),
allocatable :: pe_isc
1010 integer,
dimension(:),
allocatable :: pe_jcsize
1011 integer,
dimension(:),
allocatable :: pe_jec
1012 integer,
dimension(:),
allocatable :: pe_jsc
1014 integer :: xdim_index
1016 integer :: ydim_index
1019 integer(kind=i4_kind) :: fill_i4_kind
1020 integer(kind=i8_kind) :: fill_i8_kind
1021 real(kind=r4_kind) :: fill_r4_kind
1022 real(kind=r8_kind) :: fill_r8_kind
1028 if (.not. is_variable_domain_decomposed(fileobj, variable_name, .true., &
1029 xdim_index, ydim_index, xpos, ypos))
then
1030 call compressed_write(fileobj, variable_name, vdata, &
1031 unlim_dim_level=unlim_dim_level, corner=corner, &
1032 edge_lengths=edge_lengths)
1036 call domain_offsets(
size(vdata, xdim_index),
size(vdata, ydim_index), fileobj%domain, &
1037 xpos, ypos, isd, isc, xc_size, jsd, jsc, yc_size, &
1038 buffer_includes_halos, msg=
"file:"//trim(fileobj%path)//
" and variable:"//trim(variable_name))
1043 if (fileobj%is_root)
then
1044 allocate(pe_isc(
size(fileobj%pelist)))
1045 allocate(pe_iec(
size(fileobj%pelist)))
1046 allocate(pe_icsize(
size(fileobj%pelist)))
1047 call mpp_get_compute_domains(io_domain, xbegin=pe_isc, xend=pe_iec, xsize=pe_icsize, &
1049 allocate(pe_jsc(
size(fileobj%pelist)))
1050 allocate(pe_jec(
size(fileobj%pelist)))
1051 allocate(pe_jcsize(
size(fileobj%pelist)))
1052 call mpp_get_compute_domains(io_domain, ybegin=pe_jsc, yend=pe_jec, ysize=pe_jcsize, &
1056 call mpp_get_global_domain(io_domain, ybegin=ygmin, yend=ygmax, position=ypos)
1057 call mpp_get_global_domain(io_domain, xbegin=xgmin, xend=xgmax, position=xpos)
1061 e(xdim_index) = xgmax - xgmin + 1
1062 e(ydim_index) = ygmax - ygmin + 1
1067 type is (
integer(kind=i4_kind))
1068 call allocate_array(global_buf_i4_kind, e)
1069 global_buf_i4_kind = 0
1070 if (get_fill_value(fileobj, variable_name, fill_i4_kind, broadcast=.false.))
then
1071 global_buf_i4_kind = fill_i4_kind
1073 type is (
integer(kind=i8_kind))
1074 call allocate_array(global_buf_i8_kind, e)
1075 global_buf_i8_kind = 0
1076 if (get_fill_value(fileobj, variable_name, fill_i8_kind, broadcast=.false.))
then
1077 global_buf_i8_kind = fill_i8_kind
1079 type is (real(kind=r4_kind))
1080 call allocate_array(global_buf_r4_kind, e)
1081 global_buf_r4_kind = 0.
1082 if (get_fill_value(fileobj, variable_name, fill_r4_kind, broadcast=.false.))
then
1083 global_buf_r4_kind = fill_r4_kind
1085 type is (real(kind=r8_kind))
1086 call allocate_array(global_buf_r8_kind, e)
1087 global_buf_r8_kind = 0.
1088 if (get_fill_value(fileobj, variable_name, fill_r8_kind, broadcast=.false.))
then
1089 global_buf_r8_kind = fill_r8_kind
1092 call error(
"unsupported variable type: domain_write_5d: file: "//trim(fileobj%path)//
" variable:"// &
1093 & trim(variable_name))
1096 do i = 1,
size(fileobj%pelist)
1098 c(xdim_index) = pe_isc(i) - xgmin + 1
1099 c(ydim_index) = pe_jsc(i) - ygmin + 1
1100 e(xdim_index) = pe_icsize(i)
1101 e(ydim_index) = pe_jcsize(i)
1103 type is (
integer(kind=i4_kind))
1104 call allocate_array(buf_i4_kind, e)
1108 if (buffer_includes_halos)
then
1110 c(xdim_index) = isc - isd + 1
1111 c(ydim_index) = jsc - jsd + 1
1116 call get_array_section(buf_i4_kind, vdata, c, e)
1117 c(xdim_index) = pe_isc(i) - xgmin + 1
1118 c(ydim_index) = pe_jsc(i) - ygmin + 1
1121 call mpp_recv(buf_i4_kind,
size(buf_i4_kind), fileobj%pelist(i), block=.true.)
1124 call put_array_section(buf_i4_kind, global_buf_i4_kind, c, e)
1125 deallocate(buf_i4_kind)
1126 type is (
integer(kind=i8_kind))
1127 call allocate_array(buf_i8_kind, e)
1131 if (buffer_includes_halos)
then
1133 c(xdim_index) = isc - isd + 1
1134 c(ydim_index) = jsc - jsd + 1
1139 call get_array_section(buf_i8_kind, vdata, c, e)
1140 c(xdim_index) = pe_isc(i) - xgmin + 1
1141 c(ydim_index) = pe_jsc(i) - ygmin + 1
1144 call mpp_recv(buf_i8_kind,
size(buf_i8_kind), fileobj%pelist(i), block=.true.)
1147 call put_array_section(buf_i8_kind, global_buf_i8_kind, c, e)
1148 deallocate(buf_i8_kind)
1149 type is (real(kind=r4_kind))
1150 call allocate_array(buf_r4_kind, e)
1154 if (buffer_includes_halos)
then
1156 c(xdim_index) = isc - isd + 1
1157 c(ydim_index) = jsc - jsd + 1
1162 call get_array_section(buf_r4_kind, vdata, c, e)
1163 c(xdim_index) = pe_isc(i) - xgmin + 1
1164 c(ydim_index) = pe_jsc(i) - ygmin + 1
1167 call mpp_recv(buf_r4_kind,
size(buf_r4_kind), fileobj%pelist(i), block=.true.)
1170 call put_array_section(buf_r4_kind, global_buf_r4_kind, c, e)
1171 deallocate(buf_r4_kind)
1172 type is (real(kind=r8_kind))
1173 call allocate_array(buf_r8_kind, e)
1177 if (buffer_includes_halos)
then
1179 c(xdim_index) = isc - isd + 1
1180 c(ydim_index) = jsc - jsd + 1
1185 call get_array_section(buf_r8_kind, vdata, c, e)
1186 c(xdim_index) = pe_isc(i) - xgmin + 1
1187 c(ydim_index) = pe_jsc(i) - ygmin + 1
1190 call mpp_recv(buf_r8_kind,
size(buf_r8_kind), fileobj%pelist(i), block=.true.)
1193 call put_array_section(buf_r8_kind, global_buf_r8_kind, c, e)
1194 deallocate(buf_r8_kind)
1199 deallocate(pe_icsize)
1202 deallocate(pe_jcsize)
1206 type is (
integer(kind=i4_kind))
1207 call netcdf_write_data(fileobj, variable_name, global_buf_i4_kind, &
1208 unlim_dim_level=unlim_dim_level)
1209 deallocate(global_buf_i4_kind)
1210 type is (
integer(kind=i8_kind))
1211 call netcdf_write_data(fileobj, variable_name, global_buf_i8_kind, &
1212 unlim_dim_level=unlim_dim_level)
1213 deallocate(global_buf_i8_kind)
1214 type is (real(kind=r4_kind))
1215 call netcdf_write_data(fileobj, variable_name, global_buf_r4_kind, &
1216 unlim_dim_level=unlim_dim_level)
1217 deallocate(global_buf_r4_kind)
1218 type is (real(kind=r8_kind))
1219 call netcdf_write_data(fileobj, variable_name, global_buf_r8_kind, &
1220 unlim_dim_level=unlim_dim_level)
1221 deallocate(global_buf_r8_kind)
1224 if (buffer_includes_halos)
then
1225 c(xdim_index) = isc - isd + 1
1226 c(ydim_index) = jsc - jsd + 1
1228 e(xdim_index) = xc_size
1229 e(ydim_index) = yc_size
1231 type is (
integer(kind=i4_kind))
1232 call allocate_array(buf_i4_kind, e)
1233 call get_array_section(buf_i4_kind, vdata, c, e)
1234 call mpp_send(buf_i4_kind,
size(buf_i4_kind), fileobj%io_root)
1236 deallocate(buf_i4_kind)
1237 type is (
integer(kind=i8_kind))
1238 call allocate_array(buf_i8_kind, e)
1239 call get_array_section(buf_i8_kind, vdata, c, e)
1240 call mpp_send(buf_i8_kind,
size(buf_i8_kind), fileobj%io_root)
1242 deallocate(buf_i8_kind)
1243 type is (real(kind=r4_kind))
1244 call allocate_array(buf_r4_kind, e)
1245 call get_array_section(buf_r4_kind, vdata, c, e)
1246 call mpp_send(buf_r4_kind,
size(buf_r4_kind), fileobj%io_root)
1248 deallocate(buf_r4_kind)
1249 type is (real(kind=r8_kind))
1250 call allocate_array(buf_r8_kind, e)
1251 call get_array_section(buf_r8_kind, vdata, c, e)
1252 call mpp_send(buf_r8_kind,
size(buf_r8_kind), fileobj%io_root)
1254 deallocate(buf_r8_kind)
1256 call error(
"unsupported variable type: domain_write_5d: file: "//trim(fileobj%path)//
" variable:"// &
1257 & trim(variable_name))
subroutine domain_write_3d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_write_4d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_write_1d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_write_5d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_write_0d(fileobj, variable_name, vdata, unlim_dim_level, corner)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_write_2d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
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...