Commit 7649058e authored by Graham, Aaron's avatar Graham, Aaron
Browse files

Fix 0-size string warning in HDF5 (#4703)

parent af2449ad
Pipeline #162397 passed with stage
in 2 minutes and 4 seconds
...@@ -3300,17 +3300,23 @@ SUBROUTINE write_st0(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in) ...@@ -3300,17 +3300,23 @@ SUBROUTINE write_st0(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in)
INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: cnt_in INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: cnt_in
INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: offset_in INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: offset_in
#ifdef FUTILITY_HAVE_HDF5 #ifdef FUTILITY_HAVE_HDF5
CHARACTER(LEN=LEN_TRIM(vals)) :: valss
CHARACTER(LEN=LEN(dsetname)+1) :: path CHARACTER(LEN=LEN(dsetname)+1) :: path
INTEGER(HSIZE_T) :: write_size
INTEGER(HSIZE_T),DIMENSION(1) :: ldims,gdims,offset,cnt INTEGER(HSIZE_T),DIMENSION(1) :: ldims,gdims,offset,cnt
INTEGER,PARAMETER :: rank=0 INTEGER,PARAMETER :: rank=0
TYPE(StringType) :: write_vals
INTEGER :: error INTEGER :: error
INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id
path=dsetname path=dsetname
! Fill character array IF(LEN_TRIM(vals) == 0) THEN
valss=TRIM(vals) write_size=1
write_vals=C_NULL_CHAR
ELSE
write_size=LEN_TRIM(vals)
write_vals=TRIM(vals)
ENDIF
! stash offset ! stash offset
offset(1)=0 offset(1)=0
...@@ -3330,11 +3336,12 @@ SUBROUTINE write_st0(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in) ...@@ -3330,11 +3336,12 @@ SUBROUTINE write_st0(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in)
CALL h5tcopy_f(H5T_NATIVE_CHARACTER,mem,error) CALL h5tcopy_f(H5T_NATIVE_CHARACTER,mem,error)
CALL h5tset_strpad_f(mem,0,error) CALL h5tset_strpad_f(mem,0,error)
CALL h5tset_size_f(mem,INT(LEN_TRIM(vals),SDK),error) CALL h5tset_size_f(mem,write_size,error)
CALL preWrite(thisHDF5File,rank,gdims,ldims,path,mem,dset_id,dspace_id, & CALL preWrite(thisHDF5File,rank,gdims,ldims,path,mem,dset_id,dspace_id, &
gspace_id,plist_id,error,cnt,offset) gspace_id,plist_id,error,cnt,offset)
IF(error == 0) & IF(error == 0) THEN
CALL h5dwrite_f(dset_id,mem,valss,gdims,error,dspace_id,gspace_id,plist_id) CALL h5dwrite_f(dset_id,mem,CHAR(write_vals),gdims,error,dspace_id,gspace_id,plist_id)
ENDIF
CALL postWrite(thisHDF5File,error,dset_id,dspace_id,gspace_id,plist_id) CALL postWrite(thisHDF5File,error,dset_id,dspace_id,gspace_id,plist_id)
CALL h5tclose_f(mem,error) CALL h5tclose_f(mem,error)
#endif #endif
...@@ -3360,7 +3367,7 @@ SUBROUTINE write_st1_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in ...@@ -3360,7 +3367,7 @@ SUBROUTINE write_st1_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in
INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: offset_in INTEGER(SIK),DIMENSION(1),INTENT(IN),OPTIONAL :: offset_in
INTEGER(SIK) :: local_gdims(1) INTEGER(SIK) :: local_gdims(1)
length_max=0 length_max=1
DO i=1,SIZE(vals) DO i=1,SIZE(vals)
length_max=MAX(LEN_TRIM(vals(i)),length_max) length_max=MAX(LEN_TRIM(vals(i)),length_max)
ENDDO ENDDO
...@@ -3399,10 +3406,16 @@ SUBROUTINE write_st1(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse ...@@ -3399,10 +3406,16 @@ SUBROUTINE write_st1(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse
INTEGER :: error INTEGER :: error
INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id
REQUIRE(length_max > 0)
path=dsetname path=dsetname
! Fill character array ! Fill character array
DO j=1,SIZE(vals,DIM=1) DO j=1,SIZE(vals,DIM=1)
valss(j)=TRIM(vals(j)) IF(LEN_TRIM(vals(j)) == 0) THEN
valss(j)=C_NULL_CHAR
ELSE
valss(j)=TRIM(vals(j))
ENDIF
ENDDO ENDDO
! stash offset ! stash offset
...@@ -3452,7 +3465,7 @@ SUBROUTINE write_st2_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in ...@@ -3452,7 +3465,7 @@ SUBROUTINE write_st2_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in
INTEGER(SIK),DIMENSION(2),INTENT(IN),OPTIONAL :: cnt_in INTEGER(SIK),DIMENSION(2),INTENT(IN),OPTIONAL :: cnt_in
INTEGER(SIK),DIMENSION(2),INTENT(IN),OPTIONAL :: offset_in INTEGER(SIK),DIMENSION(2),INTENT(IN),OPTIONAL :: offset_in
length_max=0 length_max=1
DO j=1,SIZE(vals,1) DO j=1,SIZE(vals,1)
DO i=1,SIZE(vals,2) DO i=1,SIZE(vals,2)
length_max=MAX(LEN_TRIM(vals(j,i)),length_max) length_max=MAX(LEN_TRIM(vals(j,i)),length_max)
...@@ -3496,10 +3509,16 @@ SUBROUTINE write_st2(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse ...@@ -3496,10 +3509,16 @@ SUBROUTINE write_st2(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse
INTEGER :: error INTEGER :: error
INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id
REQUIRE(length_max > 0)
path=dsetname path=dsetname
DO k=1,SIZE(vals,2) DO k=1,SIZE(vals,2)
DO j=1,SIZE(vals,1) DO j=1,SIZE(vals,1)
valss(j,k)=TRIM(vals(j,k)) IF(LEN_TRIM(vals(j,k)) == 0) THEN
valss(j,k)=C_NULL_CHAR
ELSE
valss(j,k)=TRIM(vals(j,k))
ENDIF
ENDDO ENDDO
ENDDO ENDDO
...@@ -3551,7 +3570,7 @@ SUBROUTINE write_st3_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in ...@@ -3551,7 +3570,7 @@ SUBROUTINE write_st3_helper(thisHDF5File,dsetname,vals,gdims_in,cnt_in,offset_in
INTEGER(SIK),DIMENSION(3),INTENT(IN),OPTIONAL :: cnt_in INTEGER(SIK),DIMENSION(3),INTENT(IN),OPTIONAL :: cnt_in
INTEGER(SIK),DIMENSION(3),INTENT(IN),OPTIONAL :: offset_in INTEGER(SIK),DIMENSION(3),INTENT(IN),OPTIONAL :: offset_in
length_max=0 length_max=1
DO k=1,SIZE(vals,3) DO k=1,SIZE(vals,3)
DO j=1,SIZE(vals,1) DO j=1,SIZE(vals,1)
DO i=1,SIZE(vals,2) DO i=1,SIZE(vals,2)
...@@ -3597,11 +3616,17 @@ SUBROUTINE write_st3(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse ...@@ -3597,11 +3616,17 @@ SUBROUTINE write_st3(thisHDF5File,dsetname,vals,length_max,gdims_in,cnt_in,offse
INTEGER :: error INTEGER :: error
INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id INTEGER(HID_T) :: mem,dspace_id,dset_id,gspace_id,plist_id
REQUIRE(length_max > 0)
path=dsetname path=dsetname
DO l=1,SIZE(vals,3) DO l=1,SIZE(vals,3)
DO k=1,SIZE(vals,2) DO k=1,SIZE(vals,2)
DO j=1,SIZE(vals,1) DO j=1,SIZE(vals,1)
valss(j,k,l)=TRIM(vals(j,k,l)) IF(LEN_TRIM(vals(j,k,l)) == 0) THEN
valss(j,k,l)=C_NULL_CHAR
ELSE
valss(j,k,l)=TRIM(vals(j,k,l))
ENDIF
ENDDO ENDDO
ENDDO ENDDO
ENDDO ENDDO
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment