37 integer(i4_kind),
intent(in) :: funit
39 type(fieldtype),
intent(inout) :: field
40 type(domainug),
intent(inout) :: domain
42 real(KIND=r8_kind),
dimension(:),
intent(inout) :: fdata
43 integer,
dimension(:),
intent(in) :: nelems_io
47 real(KIND=r8_kind),
intent(in),
optional :: tstamp
48 real(KIND=r8_kind),
intent(in),
optional :: default_data
51 real(KIND=r8_kind) :: fill
52 type(domainug),
pointer :: io_domain
53 integer(i4_kind) :: io_domain_npes
54 integer(i4_kind),
dimension(:),
allocatable :: pelist
55 integer(i4_kind) :: nelems
58 real(kind=r8_kind),
dimension(:),
allocatable :: rbuff
60 real(kind=r8_kind),
dimension(:),
allocatable :: cdata
66 call mpp_clock_begin(mpp_write_clock)
69 if (.not. module_is_initialized)
then
70 call mpp_error(fatal, &
71 "mpp_io_unstructured_write_r_1D:" &
72 //
" you must first call mpp_io_init.")
77 if (.not. mpp_file(funit)%valid)
then
78 call mpp_error(fatal, &
79 "mpp_io_unstructured_write_r_1D:" &
80 //
" the inputted file unit is already in use.")
85 if (
present(default_data))
then
92 io_domain => mpp_get_ug_io_domain(domain)
95 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
96 allocate(pelist(io_domain_npes))
97 call mpp_get_ug_domain_pelist(io_domain, &
103 if (
mpp_pe() .eq. pelist(1) .and. .not. &
104 mpp_file(funit)%write_on_this_pe)
then
105 call mpp_error(fatal, &
106 "mpp_io_unstructured_write_r_1D:" &
107 //
" the root rank of the pelist must be allowed" &
108 //
" to perform the write.")
110 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
111 call mpp_error(fatal, &
112 "mpp_io_unstructured_write_r_1D:" &
113 //
" the non-root ranks of the pelist are not" &
114 //
" allowed to perform the write.")
119 if (
mpp_pe() .eq. pelist(1))
then
120 nelems = sum(nelems_io)
121 allocate(rbuff(nelems))
127 call mpp_gather(fdata, &
135 if (
mpp_pe() .eq. pelist(1))
then
136 allocate(cdata(nelems))
141 field%size(1) = nelems
142 call write_record_r8(funit, &
155 call mpp_clock_end(mpp_write_clock)
172 integer(i4_kind),
intent(in) :: funit
174 type(fieldtype),
intent(inout) :: field
175 type(domainug),
intent(inout) :: domain
177 real(KIND=r8_kind),
dimension(:,:),
intent(inout) :: fdata
178 integer,
dimension(:),
intent(in) :: nelems_io
182 real(KIND=r8_kind),
intent(in),
optional :: tstamp
183 real(KIND=r8_kind),
intent(in),
optional :: default_data
186 real(KIND=r8_kind) :: fill
187 type(domainug),
pointer :: io_domain
188 integer(i4_kind) :: io_domain_npes
189 integer(i4_kind),
dimension(:),
allocatable :: pelist
190 integer(i4_kind) :: dim_size_1
192 integer(i4_kind) :: dim_size_2
194 real(kind=r8_kind),
dimension(:),
allocatable :: sbuff
196 integer(i4_kind) :: nelems
199 real(kind=r8_kind),
dimension(:),
allocatable :: rbuff
201 real(kind=r8_kind),
dimension(:,:),
allocatable :: cdata
203 integer(i4_kind) :: offset_r
205 integer(i4_kind) :: offset_c
207 integer(i4_kind) :: i
208 integer(i4_kind) :: j
209 integer(i4_kind) :: k
213 call mpp_clock_begin(mpp_write_clock)
216 if (.not. module_is_initialized)
then
217 call mpp_error(fatal, &
218 "mpp_io_unstructured_write_r_2D:" &
219 //
" you must first call mpp_io_init.")
224 if (.not. mpp_file(funit)%valid)
then
225 call mpp_error(fatal, &
226 "mpp_io_unstructured_write_r_2D:" &
227 //
" the inputted file unit is already in use.")
232 if (
present(default_data))
then
239 io_domain => mpp_get_ug_io_domain(domain)
242 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
243 allocate(pelist(io_domain_npes))
244 call mpp_get_ug_domain_pelist(io_domain, &
250 if (
mpp_pe() .eq. pelist(1) .and. .not. &
251 mpp_file(funit)%write_on_this_pe)
then
252 call mpp_error(fatal, &
253 "mpp_io_unstructured_write_r_2D:" &
254 //
" the root rank of the pelist must be allowed" &
255 //
" to perform the write.")
257 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
258 call mpp_error(fatal, &
259 "mpp_io_unstructured_write_r_2D:" &
260 //
" the non-root ranks of the pelist are not" &
261 //
" allowed to perform the write.")
266 allocate(sbuff(
size(fdata)))
267 dim_size_1 =
size(fdata,1)
268 dim_size_2 =
size(fdata,2)
271 sbuff((j-1)*dim_size_1+i) = fdata(i,j)
277 if (
mpp_pe() .eq. pelist(1))
then
278 nelems = sum(nelems_io)
279 allocate(rbuff(nelems*dim_size_2))
285 call mpp_gather(sbuff, &
288 nelems_io*dim_size_2, &
294 if (
mpp_pe() .eq. pelist(1))
then
295 allocate(cdata(nelems,dim_size_2))
299 do k = 1,io_domain_npes
301 offset_r = (j-1)*nelems_io(k) + dim_size_2*(sum(nelems_io(1:k-1)))
303 offset_r = (j-1)*nelems_io(k)
305 do i = 1,nelems_io(k)
306 cdata(i+offset_c,j) = rbuff(i+offset_r)
308 offset_c = offset_c + nelems_io(k)
311 field%size(1) = nelems
312 call write_record_r8(funit, &
326 call mpp_clock_end(mpp_write_clock)
343 integer(i4_kind),
intent(in) :: funit
345 type(fieldtype),
intent(inout) :: field
346 type(domainug),
intent(inout) :: domain
348 real(KIND=r8_kind),
dimension(:,:,:),
intent(inout) :: fdata
349 integer,
dimension(:),
intent(in) :: nelems_io
353 real(KIND=r8_kind),
intent(in),
optional :: tstamp
354 real(KIND=r8_kind),
intent(in),
optional :: default_data
357 real(KIND=r8_kind) :: fill
359 type(domainug),
pointer :: io_domain
360 integer(i4_kind) :: io_domain_npes
362 integer(i4_kind),
dimension(:),
allocatable :: pelist
363 integer(i4_kind) :: dim_size_1
365 integer(i4_kind) :: dim_size_2
367 integer(i4_kind) :: dim_size_3
369 real(kind=r8_kind),
dimension(:),
allocatable :: sbuff
371 integer(i4_kind) :: nelems
374 real(kind=r8_kind),
dimension(:),
allocatable :: rbuff
376 real(kind=r8_kind),
dimension(:,:,:),
allocatable :: cdata
378 integer(i4_kind) :: offset_r
380 integer(i4_kind) :: offset_c
382 integer(i4_kind) :: i
383 integer(i4_kind) :: j
384 integer(i4_kind) :: k
385 integer(i4_kind) :: m
389 call mpp_clock_begin(mpp_write_clock)
392 if (.not. module_is_initialized)
then
393 call mpp_error(fatal, &
394 "mpp_io_unstructured_write_r_3D:" &
395 //
" you must first call mpp_io_init.")
400 if (.not. mpp_file(funit)%valid)
then
401 call mpp_error(fatal, &
402 "mpp_io_unstructured_write_r_3D:" &
403 //
" the inputted file unit is already in use.")
408 if (
present(default_data))
then
415 io_domain => mpp_get_ug_io_domain(domain)
418 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
419 allocate(pelist(io_domain_npes))
420 call mpp_get_ug_domain_pelist(io_domain, &
426 if (
mpp_pe() .eq. pelist(1) .and. .not. &
427 mpp_file(funit)%write_on_this_pe)
then
428 call mpp_error(fatal, &
429 "mpp_io_unstructured_write_r_3D:" &
430 //
" the root rank of the pelist must be allowed" &
431 //
" to perform the write.")
433 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
434 call mpp_error(fatal, &
435 "mpp_io_unstructured_write_r_3D:" &
436 //
" the non-root ranks of the pelist are not" &
437 //
" allowed to perform the write.")
442 allocate(sbuff(
size(fdata)))
443 dim_size_1 =
size(fdata,1)
444 dim_size_2 =
size(fdata,2)
445 dim_size_3 =
size(fdata,3)
449 sbuff((k-1)*dim_size_2*dim_size_1+(j-1)*dim_size_1+i) = fdata(i,j,k)
456 if (
mpp_pe() .eq. pelist(1))
then
457 nelems = sum(nelems_io)
458 allocate(rbuff(nelems*dim_size_2*dim_size_3))
464 call mpp_gather(sbuff, &
467 nelems_io*dim_size_2*dim_size_3, &
473 if (
mpp_pe() .eq. pelist(1))
then
474 allocate(cdata(nelems,dim_size_2,dim_size_3))
479 do k = 1,io_domain_npes
481 offset_r = (m-1)*dim_size_2*nelems_io(k) + &
482 (j-1)*nelems_io(k) + &
483 dim_size_2*dim_size_3*(sum(nelems_io(1:k-1)))
485 offset_r = (m-1)*dim_size_2*nelems_io(k) + &
488 do i = 1,nelems_io(k)
489 cdata(i+offset_c,j,m) = rbuff(i+offset_r)
491 offset_c = offset_c + nelems_io(k)
495 field%size(1) = nelems
496 call write_record_r8(funit, &
498 nelems*dim_size_2*dim_size_3, &
510 call mpp_clock_end(mpp_write_clock)
527 integer(i4_kind),
intent(in) :: funit
529 type(fieldtype),
intent(inout) :: field
530 type(domainug),
intent(inout) :: domain
532 real(KIND=r8_kind),
dimension(:,:,:,:),
intent(inout) :: fdata
533 integer,
dimension(:),
intent(in),
optional :: nelems_io_in
538 real(KIND=r8_kind),
intent(in),
optional :: tstamp
539 real(KIND=r8_kind),
intent(in),
optional :: default_data
542 real(KIND=r8_kind) :: fill
543 type(domainug),
pointer :: io_domain
544 integer(i4_kind) :: io_domain_npes
545 integer(i4_kind),
dimension(:),
allocatable :: pelist
546 integer(i4_kind),
dimension(:),
allocatable :: nelems_io
548 integer(i4_kind) :: compute_size
550 integer(i4_kind) :: size_fdata_dim_2
552 integer(i4_kind) :: size_fdata_dim_3
554 integer(i4_kind) :: size_fdata_dim_4
556 integer(i4_kind) :: mynelems
558 real(kind=r8_kind),
dimension(:),
allocatable :: sbuff
560 integer(i4_kind) :: nelems
563 real(kind=r8_kind),
dimension(:),
allocatable :: rbuff
565 real(kind=r8_kind),
dimension(:,:,:,:),
allocatable :: cdata
567 integer(i4_kind) :: i
568 integer(i4_kind) :: j
569 integer(i4_kind) :: k
570 integer(i4_kind) :: n
574 call mpp_clock_begin(mpp_write_clock)
577 if (.not. module_is_initialized)
then
578 call mpp_error(fatal, &
579 "mpp_io_unstructured_write_compressed_r_4D:" &
580 //
" you must first call mpp_io_init.")
585 if (.not. mpp_file(funit)%valid)
then
586 call mpp_error(fatal, &
587 "mpp_io_unstructured_write_compressed_r_4D:" &
588 //
" the inputted file unit is already in use.")
593 if (
present(default_data))
then
600 io_domain => mpp_get_ug_io_domain(domain)
603 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
604 allocate(pelist(io_domain_npes))
605 call mpp_get_ug_domain_pelist(io_domain, &
611 if (
mpp_pe() .eq. pelist(1) .and. .not. &
612 mpp_file(funit)%write_on_this_pe)
then
613 call mpp_error(fatal, &
614 "mpp_io_unstructured_write_compressed_r_4D:" &
615 //
" the root rank of the pelist must be allowed" &
616 //
" to perform the write.")
618 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
619 call mpp_error(fatal, &
620 "mpp_io_unstructured_write_compressed_r_4D:" &
621 //
" the non-root ranks of the pelist are not" &
622 //
" allowed to perform the write.")
632 if (
present(nelems_io_in))
then
633 allocate(nelems_io(
size(nelems_io_in)))
634 nelems_io = nelems_io_in
636 allocate(nelems_io(io_domain_npes))
638 call mpp_get_ug_compute_domains(io_domain, &
644 size_fdata_dim_2 =
size(fdata,2)
645 size_fdata_dim_3 =
size(fdata,3)
646 size_fdata_dim_4 =
size(fdata,4)
650 mynelems =
size(fdata,1)
651 allocate(sbuff(mynelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4))
652 if (
mpp_pe() .eq. pelist(1))
then
653 nelems = sum(nelems_io)
654 allocate(rbuff(nelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4))
662 do j = 1,size_fdata_dim_2
663 do i = 1,size_fdata_dim_3
664 do n = 1,size_fdata_dim_4
665 sbuff((k-1)*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4 &
666 + (j-1)*size_fdata_dim_3*size_fdata_dim_4 &
667 + (i-1)*size_fdata_dim_4 + n) = fdata(k,j,i,n)
674 call mpp_gather(sbuff, &
677 nelems_io*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4, &
682 if (
mpp_pe() .eq. pelist(1))
then
683 allocate(cdata(nelems,size_fdata_dim_2,size_fdata_dim_3,size_fdata_dim_4))
685 do n = 1,size_fdata_dim_4
686 do k = 1,size_fdata_dim_3
687 do j = 1,size_fdata_dim_2
689 cdata(i,j,k,n) = rbuff((i-1)*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4 &
690 + (j-1)*size_fdata_dim_3*size_fdata_dim_4 &
691 + (k-1)*size_fdata_dim_4 + n)
696 field%size(1) = nelems
697 call write_record_r8(funit, &
699 nelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4, &
709 deallocate(nelems_io)
712 call mpp_clock_end(mpp_write_clock)
733 integer(i4_kind),
intent(in) :: funit
735 type(fieldtype),
intent(inout) :: field
736 type(domainug),
intent(inout) :: domain
738 real(KIND=r4_kind),
dimension(:),
intent(inout) :: fdata
739 integer,
dimension(:),
intent(in) :: nelems_io
743 real(KIND=r4_kind),
intent(in),
optional :: tstamp
744 real(KIND=r4_kind),
intent(in),
optional :: default_data
747 real(KIND=r4_kind) :: fill
748 type(domainug),
pointer :: io_domain
749 integer(i4_kind) :: io_domain_npes
750 integer(i4_kind),
dimension(:),
allocatable :: pelist
751 integer(i4_kind) :: nelems
754 real(kind=r4_kind),
dimension(:),
allocatable :: rbuff
756 real(kind=r4_kind),
dimension(:),
allocatable :: cdata
758 integer(i4_kind) :: i
762 call mpp_clock_begin(mpp_write_clock)
765 if (.not. module_is_initialized)
then
766 call mpp_error(fatal, &
767 "mpp_io_unstructured_write_r_1D:" &
768 //
" you must first call mpp_io_init.")
773 if (.not. mpp_file(funit)%valid)
then
774 call mpp_error(fatal, &
775 "mpp_io_unstructured_write_r_1D:" &
776 //
" the inputted file unit is already in use.")
781 if (
present(default_data))
then
788 io_domain => mpp_get_ug_io_domain(domain)
791 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
792 allocate(pelist(io_domain_npes))
793 call mpp_get_ug_domain_pelist(io_domain, &
799 if (
mpp_pe() .eq. pelist(1) .and. .not. &
800 mpp_file(funit)%write_on_this_pe)
then
801 call mpp_error(fatal, &
802 "mpp_io_unstructured_write_r_1D:" &
803 //
" the root rank of the pelist must be allowed" &
804 //
" to perform the write.")
806 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
807 call mpp_error(fatal, &
808 "mpp_io_unstructured_write_r_1D:" &
809 //
" the non-root ranks of the pelist are not" &
810 //
" allowed to perform the write.")
815 if (
mpp_pe() .eq. pelist(1))
then
816 nelems = sum(nelems_io)
817 allocate(rbuff(nelems))
823 call mpp_gather(fdata, &
831 if (
mpp_pe() .eq. pelist(1))
then
832 allocate(cdata(nelems))
837 field%size(1) = nelems
838 call write_record_r4(funit, &
851 call mpp_clock_end(mpp_write_clock)
868 integer(i4_kind),
intent(in) :: funit
870 type(fieldtype),
intent(inout) :: field
871 type(domainug),
intent(inout) :: domain
873 real(KIND=r4_kind),
dimension(:,:),
intent(inout) :: fdata
874 integer,
dimension(:),
intent(in) :: nelems_io
878 real(KIND=r4_kind),
intent(in),
optional :: tstamp
879 real(KIND=r4_kind),
intent(in),
optional :: default_data
882 real(KIND=r4_kind) :: fill
883 type(domainug),
pointer :: io_domain
884 integer(i4_kind) :: io_domain_npes
885 integer(i4_kind),
dimension(:),
allocatable :: pelist
886 integer(i4_kind) :: dim_size_1
888 integer(i4_kind) :: dim_size_2
890 real(kind=r4_kind),
dimension(:),
allocatable :: sbuff
892 integer(i4_kind) :: nelems
895 real(kind=r4_kind),
dimension(:),
allocatable :: rbuff
897 real(kind=r4_kind),
dimension(:,:),
allocatable :: cdata
899 integer(i4_kind) :: offset_r
901 integer(i4_kind) :: offset_c
903 integer(i4_kind) :: i
904 integer(i4_kind) :: j
905 integer(i4_kind) :: k
909 call mpp_clock_begin(mpp_write_clock)
912 if (.not. module_is_initialized)
then
913 call mpp_error(fatal, &
914 "mpp_io_unstructured_write_r_2D:" &
915 //
" you must first call mpp_io_init.")
920 if (.not. mpp_file(funit)%valid)
then
921 call mpp_error(fatal, &
922 "mpp_io_unstructured_write_r_2D:" &
923 //
" the inputted file unit is already in use.")
928 if (
present(default_data))
then
935 io_domain => mpp_get_ug_io_domain(domain)
938 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
939 allocate(pelist(io_domain_npes))
940 call mpp_get_ug_domain_pelist(io_domain, &
946 if (
mpp_pe() .eq. pelist(1) .and. .not. &
947 mpp_file(funit)%write_on_this_pe)
then
948 call mpp_error(fatal, &
949 "mpp_io_unstructured_write_r_2D:" &
950 //
" the root rank of the pelist must be allowed" &
951 //
" to perform the write.")
953 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
954 call mpp_error(fatal, &
955 "mpp_io_unstructured_write_r_2D:" &
956 //
" the non-root ranks of the pelist are not" &
957 //
" allowed to perform the write.")
962 allocate(sbuff(
size(fdata)))
963 dim_size_1 =
size(fdata,1)
964 dim_size_2 =
size(fdata,2)
967 sbuff((j-1)*dim_size_1+i) = fdata(i,j)
973 if (
mpp_pe() .eq. pelist(1))
then
974 nelems = sum(nelems_io)
975 allocate(rbuff(nelems*dim_size_2))
981 call mpp_gather(sbuff, &
984 nelems_io*dim_size_2, &
990 if (
mpp_pe() .eq. pelist(1))
then
991 allocate(cdata(nelems,dim_size_2))
995 do k = 1,io_domain_npes
997 offset_r = (j-1)*nelems_io(k) + dim_size_2*(sum(nelems_io(1:k-1)))
999 offset_r = (j-1)*nelems_io(k)
1001 do i = 1,nelems_io(k)
1002 cdata(i+offset_c,j) = rbuff(i+offset_r)
1004 offset_c = offset_c + nelems_io(k)
1007 field%size(1) = nelems
1008 call write_record_r4(funit, &
1010 nelems*dim_size_2, &
1022 call mpp_clock_end(mpp_write_clock)
1039 integer(i4_kind),
intent(in) :: funit
1041 type(fieldtype),
intent(inout) :: field
1042 type(domainug),
intent(inout) :: domain
1044 real(KIND=r4_kind),
dimension(:,:,:),
intent(inout) :: fdata
1045 integer,
dimension(:),
intent(in) :: nelems_io
1049 real(KIND=r4_kind),
intent(in),
optional :: tstamp
1050 real(KIND=r4_kind),
intent(in),
optional :: default_data
1053 real(KIND=r4_kind) :: fill
1055 type(domainug),
pointer :: io_domain
1056 integer(i4_kind) :: io_domain_npes
1058 integer(i4_kind),
dimension(:),
allocatable :: pelist
1059 integer(i4_kind) :: dim_size_1
1061 integer(i4_kind) :: dim_size_2
1063 integer(i4_kind) :: dim_size_3
1065 real(kind=r4_kind),
dimension(:),
allocatable :: sbuff
1067 integer(i4_kind) :: nelems
1070 real(kind=r4_kind),
dimension(:),
allocatable :: rbuff
1072 real(kind=r4_kind),
dimension(:,:,:),
allocatable :: cdata
1074 integer(i4_kind) :: offset_r
1076 integer(i4_kind) :: offset_c
1078 integer(i4_kind) :: i
1079 integer(i4_kind) :: j
1080 integer(i4_kind) :: k
1081 integer(i4_kind) :: m
1085 call mpp_clock_begin(mpp_write_clock)
1088 if (.not. module_is_initialized)
then
1089 call mpp_error(fatal, &
1090 "mpp_io_unstructured_write_r_3D:" &
1091 //
" you must first call mpp_io_init.")
1096 if (.not. mpp_file(funit)%valid)
then
1097 call mpp_error(fatal, &
1098 "mpp_io_unstructured_write_r_3D:" &
1099 //
" the inputted file unit is already in use.")
1104 if (
present(default_data))
then
1111 io_domain => mpp_get_ug_io_domain(domain)
1114 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
1115 allocate(pelist(io_domain_npes))
1116 call mpp_get_ug_domain_pelist(io_domain, &
1122 if (
mpp_pe() .eq. pelist(1) .and. .not. &
1123 mpp_file(funit)%write_on_this_pe)
then
1124 call mpp_error(fatal, &
1125 "mpp_io_unstructured_write_r_3D:" &
1126 //
" the root rank of the pelist must be allowed" &
1127 //
" to perform the write.")
1129 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
1130 call mpp_error(fatal, &
1131 "mpp_io_unstructured_write_r_3D:" &
1132 //
" the non-root ranks of the pelist are not" &
1133 //
" allowed to perform the write.")
1138 allocate(sbuff(
size(fdata)))
1139 dim_size_1 =
size(fdata,1)
1140 dim_size_2 =
size(fdata,2)
1141 dim_size_3 =
size(fdata,3)
1145 sbuff((k-1)*dim_size_2*dim_size_1+(j-1)*dim_size_1+i) = fdata(i,j,k)
1152 if (
mpp_pe() .eq. pelist(1))
then
1153 nelems = sum(nelems_io)
1154 allocate(rbuff(nelems*dim_size_2*dim_size_3))
1160 call mpp_gather(sbuff, &
1163 nelems_io*dim_size_2*dim_size_3, &
1169 if (
mpp_pe() .eq. pelist(1))
then
1170 allocate(cdata(nelems,dim_size_2,dim_size_3))
1175 do k = 1,io_domain_npes
1177 offset_r = (m-1)*dim_size_2*nelems_io(k) + &
1178 (j-1)*nelems_io(k) + &
1179 dim_size_2*dim_size_3*(sum(nelems_io(1:k-1)))
1181 offset_r = (m-1)*dim_size_2*nelems_io(k) + &
1184 do i = 1,nelems_io(k)
1185 cdata(i+offset_c,j,m) = rbuff(i+offset_r)
1187 offset_c = offset_c + nelems_io(k)
1191 field%size(1) = nelems
1192 call write_record_r4(funit, &
1194 nelems*dim_size_2*dim_size_3, &
1206 call mpp_clock_end(mpp_write_clock)
1223 integer(i4_kind),
intent(in) :: funit
1225 type(fieldtype),
intent(inout) :: field
1226 type(domainug),
intent(inout) :: domain
1228 real(KIND=r4_kind),
dimension(:,:,:,:),
intent(inout) :: fdata
1229 integer,
dimension(:),
intent(in),
optional :: nelems_io_in
1234 real(KIND=r4_kind),
intent(in),
optional :: tstamp
1235 real(KIND=r4_kind),
intent(in),
optional :: default_data
1238 real(KIND=r4_kind) :: fill
1239 type(domainug),
pointer :: io_domain
1240 integer(i4_kind) :: io_domain_npes
1241 integer(i4_kind),
dimension(:),
allocatable :: pelist
1242 integer(i4_kind),
dimension(:),
allocatable :: nelems_io
1244 integer(i4_kind) :: compute_size
1246 integer(i4_kind) :: size_fdata_dim_2
1248 integer(i4_kind) :: size_fdata_dim_3
1250 integer(i4_kind) :: size_fdata_dim_4
1252 integer(i4_kind) :: mynelems
1254 real(kind=r4_kind),
dimension(:),
allocatable :: sbuff
1256 integer(i4_kind) :: nelems
1259 real(kind=r4_kind),
dimension(:),
allocatable :: rbuff
1261 real(kind=r4_kind),
dimension(:,:,:,:),
allocatable :: cdata
1263 integer(i4_kind) :: i
1264 integer(i4_kind) :: j
1265 integer(i4_kind) :: k
1266 integer(i4_kind) :: n
1270 call mpp_clock_begin(mpp_write_clock)
1273 if (.not. module_is_initialized)
then
1274 call mpp_error(fatal, &
1275 "mpp_io_unstructured_write_compressed_r_4D:" &
1276 //
" you must first call mpp_io_init.")
1281 if (.not. mpp_file(funit)%valid)
then
1282 call mpp_error(fatal, &
1283 "mpp_io_unstructured_write_compressed_r_4D:" &
1284 //
" the inputted file unit is already in use.")
1289 if (
present(default_data))
then
1296 io_domain => mpp_get_ug_io_domain(domain)
1299 io_domain_npes = mpp_get_ug_domain_npes(io_domain)
1300 allocate(pelist(io_domain_npes))
1301 call mpp_get_ug_domain_pelist(io_domain, &
1307 if (
mpp_pe() .eq. pelist(1) .and. .not. &
1308 mpp_file(funit)%write_on_this_pe)
then
1309 call mpp_error(fatal, &
1310 "mpp_io_unstructured_write_compressed_r_4D:" &
1311 //
" the root rank of the pelist must be allowed" &
1312 //
" to perform the write.")
1314 if (
mpp_pe() .ne. pelist(1) .and. mpp_file(funit)%write_on_this_pe)
then
1315 call mpp_error(fatal, &
1316 "mpp_io_unstructured_write_compressed_r_4D:" &
1317 //
" the non-root ranks of the pelist are not" &
1318 //
" allowed to perform the write.")
1328 if (
present(nelems_io_in))
then
1329 allocate(nelems_io(
size(nelems_io_in)))
1330 nelems_io = nelems_io_in
1332 allocate(nelems_io(io_domain_npes))
1334 call mpp_get_ug_compute_domains(io_domain, &
1340 size_fdata_dim_2 =
size(fdata,2)
1341 size_fdata_dim_3 =
size(fdata,3)
1342 size_fdata_dim_4 =
size(fdata,4)
1346 mynelems =
size(fdata,1)
1347 allocate(sbuff(mynelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4))
1348 if (
mpp_pe() .eq. pelist(1))
then
1349 nelems = sum(nelems_io)
1350 allocate(rbuff(nelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4))
1358 do j = 1,size_fdata_dim_2
1359 do i = 1,size_fdata_dim_3
1360 do n = 1,size_fdata_dim_4
1361 sbuff((k-1)*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4 &
1362 + (j-1)*size_fdata_dim_3*size_fdata_dim_4 &
1363 + (i-1)*size_fdata_dim_4 + n) = fdata(k,j,i,n)
1370 call mpp_gather(sbuff, &
1373 nelems_io*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4, &
1378 if (
mpp_pe() .eq. pelist(1))
then
1379 allocate(cdata(nelems,size_fdata_dim_2,size_fdata_dim_3,size_fdata_dim_4))
1381 do n = 1,size_fdata_dim_4
1382 do k = 1,size_fdata_dim_3
1383 do j = 1,size_fdata_dim_2
1385 cdata(i,j,k,n) = rbuff((i-1)*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4 &
1386 + (j-1)*size_fdata_dim_3*size_fdata_dim_4 &
1387 + (k-1)*size_fdata_dim_4 + n)
1392 field%size(1) = nelems
1393 call write_record_r4(funit, &
1395 nelems*size_fdata_dim_2*size_fdata_dim_3*size_fdata_dim_4, &
1405 deallocate(nelems_io)
1408 call mpp_clock_end(mpp_write_clock)
subroutine mpp_io_unstructured_write_r8_2d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 2D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r8_4d(funit, field, domain, fdata, nelems_io_in, tstamp, default_data)
Write data for a 4D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r8_3d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 3D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r4_4d(funit, field, domain, fdata, nelems_io_in, tstamp, default_data)
Write data for a 4D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r4_3d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 3D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r4_2d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 2D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r4_1d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 1D field associated with an unstructured mpp domain to a restart file.
subroutine mpp_io_unstructured_write_r8_1d(funit, field, domain, fdata, nelems_io, tstamp, default_data)
Write data for a 1D field associated with an unstructured mpp domain to a restart file.
integer function mpp_pe()
Returns processor ID.