@@ -870,24 +870,28 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
870
870
871
871
ng = maxval (maxIndexPTile)
872
872
if (tiles) then
873
- lnx = nx
874
- lny = ny
875
- lntile = ng/ (lnx* lny)
876
- write (tmpstr,* ) subname, ' ng,lnx,lny,lntile = ' ,ng,lnx,lny,lntile
877
- call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
878
- if (lntile /= ntile) then
879
- call ESMF_LogWrite(trim (subname)// ' ERROR: grid2d size and ntile are not consistent ' , ESMF_LOGMSG_INFO)
880
- call ESMF_Finalize(endflag= ESMF_END_ABORT)
881
- endif
873
+ lnx = ng
874
+ lny = 1
875
+ lntile = 1
876
+ if (nx > 0 ) lnx = nx
877
+ if (ny > 0 ) lny = ny
878
+ if (ntile > 0 ) lntile = ntile
879
+ write (tmpstr,* ) subname, ' ng,lnx,lny,lntile = ' ,ng,lnx,lny,lntile
880
+ call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
881
+ if (lnx* lny* lntile /= ng) then
882
+ write (tmpstr,* ) subname,' ERROR: grid size not consistent ' ,ng,lnx,lny,lntile
883
+ call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
884
+ call ESMF_Finalize(endflag= ESMF_END_ABORT)
885
+ end if
882
886
else
883
- lnx = ng
884
- lny = 1
885
- if (nx > 0 ) lnx = nx
886
- if (ny > 0 ) lny = ny
887
- if (lnx* lny /= ng) then
888
- write (tmpstr,* ) subname,' WARNING: grid2d size not consistent ' ,ng,lnx,lny
889
- call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
890
- endif
887
+ lnx = ng
888
+ lny = 1
889
+ if (nx > 0 ) lnx = nx
890
+ if (ny > 0 ) lny = ny
891
+ if (lnx* lny /= ng) then
892
+ write (tmpstr,* ) subname,' WARNING: grid2d size not consistent ' ,ng,lnx,lny
893
+ call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
894
+ endif
891
895
end if
892
896
deallocate (minIndexPTile, maxIndexPTile)
893
897
@@ -902,7 +906,7 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
902
906
if (tiles) then
903
907
rcode = pio_def_dim(io_file, trim (lpre)// ' _nx' , lnx, dimid3(1 ))
904
908
rcode = pio_def_dim(io_file, trim (lpre)// ' _ny' , lny, dimid3(2 ))
905
- rcode = pio_def_dim(io_file, trim (lpre)// ' _ntile' , ntile , dimid3(3 ))
909
+ rcode = pio_def_dim(io_file, trim (lpre)// ' _ntile' , lntile , dimid3(3 ))
906
910
if (present (nt)) then
907
911
dimid4(1 :3 ) = dimid3
908
912
rcode = pio_inq_dimid(io_file, ' time' , dimid4(4 ))
@@ -1020,10 +1024,18 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
1020
1024
write (tmpstr,* ) subname,' dof = ' ,ns,size (dof),dof(1 ),dof(ns) ! ,minval(dof),maxval(dof)
1021
1025
call ESMF_LogWrite(trim (tmpstr), ESMF_LOGMSG_INFO)
1022
1026
if (tiles) then
1023
- call pio_initdecomp(io_subsystem, pio_double, (/ lnx,lny,ntile/ ), dof, iodesc)
1027
+ if (luse_float) then
1028
+ call pio_initdecomp(io_subsystem, pio_real, (/ lnx,lny,lntile/ ), dof, iodesc)
1029
+ else
1030
+ call pio_initdecomp(io_subsystem, pio_double, (/ lnx,lny,lntile/ ), dof, iodesc)
1031
+ end if
1024
1032
else
1025
- call pio_initdecomp(io_subsystem, pio_double, (/ lnx,lny/ ), dof, iodesc)
1026
- ! call pio_writedof(lpre, (/lnx,lny/), int(dof,kind=PIO_OFFSET_KIND), mpicom)
1033
+ if (luse_float) then
1034
+ call pio_initdecomp(io_subsystem, pio_real, (/ lnx,lny/ ), dof, iodesc)
1035
+ else
1036
+ call pio_initdecomp(io_subsystem, pio_double, (/ lnx,lny/ ), dof, iodesc)
1037
+ end if
1038
+ ! call pio_writedof(lpre, (/lnx,lny/), int(dof,kind=PIO_OFFSET_KIND), mpicom)
1027
1039
end if
1028
1040
deallocate (dof)
1029
1041
@@ -1056,10 +1068,18 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
1056
1068
rcode = pio_inq_varid(io_file, trim (name1), varid)
1057
1069
call pio_setframe(io_file,varid,frame)
1058
1070
1059
- if (gridToFieldMap(1 ) == 1 ) then
1060
- call pio_write_darray(io_file, varid, iodesc, fldptr2(:,n), rcode, fillval= lfillvalue)
1061
- else if (gridToFieldMap(1 ) == 2 ) then
1062
- call pio_write_darray(io_file, varid, iodesc, fldptr2(n,:), rcode, fillval= lfillvalue)
1071
+ if (luse_float) then
1072
+ if (gridToFieldMap(1 ) == 1 ) then
1073
+ call pio_write_darray(io_file, varid, iodesc, real (fldptr2(:,n),r4 ), rcode, fillval= real (lfillvalue,r4 ))
1074
+ else if (gridToFieldMap(1 ) == 2 ) then
1075
+ call pio_write_darray(io_file, varid, iodesc, real (fldptr2(n,:),r4 ), rcode, fillval= real (lfillvalue,r4 ))
1076
+ end if
1077
+ else
1078
+ if (gridToFieldMap(1 ) == 1 ) then
1079
+ call pio_write_darray(io_file, varid, iodesc, fldptr2(:,n), rcode, fillval= lfillvalue)
1080
+ else if (gridToFieldMap(1 ) == 2 ) then
1081
+ call pio_write_darray(io_file, varid, iodesc, fldptr2(n,:), rcode, fillval= lfillvalue)
1082
+ end if
1063
1083
end if
1064
1084
end do
1065
1085
else if (rank == 1 .or. rank == 0 ) then
@@ -1068,7 +1088,11 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
1068
1088
call pio_setframe(io_file,varid,frame)
1069
1089
! fix for writing data on exchange grid, which has no data in some PETs
1070
1090
if (rank == 0 ) nullify(fldptr1)
1071
- call pio_write_darray(io_file, varid, iodesc, fldptr1, rcode, fillval= lfillvalue)
1091
+ if (luse_float) then
1092
+ call pio_write_darray(io_file, varid, iodesc, real (fldptr1,r4 ), rcode, fillval= real (lfillvalue,r4 ))
1093
+ else
1094
+ call pio_write_darray(io_file, varid, iodesc, fldptr1, rcode, fillval= lfillvalue)
1095
+ end if
1072
1096
end if ! end if rank is 2 or 1 or 0
1073
1097
1074
1098
end if ! end if not "hgt"
@@ -1077,12 +1101,19 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, &
1077
1101
! Fill coordinate variables - why is this being done each time?
1078
1102
rcode = pio_inq_varid(io_file, trim (coordvarnames(1 )), varid)
1079
1103
call pio_setframe(io_file,varid,frame)
1080
- call pio_write_darray(io_file, varid, iodesc, ownedElemCoords_x, rcode, fillval= lfillvalue)
1104
+ if (luse_float) then
1105
+ call pio_write_darray(io_file, varid, iodesc, real (ownedElemCoords_x,r4 ), rcode, fillval= real (lfillvalue,r4 ))
1106
+ else
1107
+ call pio_write_darray(io_file, varid, iodesc, ownedElemCoords_x, rcode, fillval= lfillvalue)
1108
+ end if
1081
1109
1082
1110
rcode = pio_inq_varid(io_file, trim (coordvarnames(2 )), varid)
1083
1111
call pio_setframe(io_file,varid,frame)
1084
- call pio_write_darray(io_file, varid, iodesc, ownedElemCoords_y, rcode, fillval= lfillvalue)
1085
-
1112
+ if (luse_float) then
1113
+ call pio_write_darray(io_file, varid, iodesc, real (ownedElemCoords_y,r4 ), rcode, fillval= real (lfillvalue,r4 ))
1114
+ else
1115
+ call pio_write_darray(io_file, varid, iodesc, ownedElemCoords_y, rcode, fillval= lfillvalue)
1116
+ end if
1086
1117
call pio_syncfile(io_file)
1087
1118
call pio_freedecomp(io_file, iodesc)
1088
1119
endif
0 commit comments