Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5fget_name_f len_trim fix #826

Closed
2 changes: 1 addition & 1 deletion fortran/src/H5Fff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ INTEGER FUNCTION h5fget_name_c(obj_id, size, buf, buflen) &
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: buf
END FUNCTION h5fget_name_c
END INTERFACE
buflen = LEN_TRIM(buf)
buflen = LEN(buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, change the declaration (line 827):

CHARACTER(LEN=*), INTENT(OUT) :: buf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in new PR.

hdferr = h5fget_name_c(obj_id, size, buf, buflen)
END SUBROUTINE h5fget_name_f
!****s* H5F/h5fget_filesize_f
Expand Down
13 changes: 12 additions & 1 deletion fortran/test/tH5F.F90
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,24 @@ SUBROUTINE reopentest(cleanup, total_error)
!
CALL h5dopen_f(reopen_id, dsetname, dset_id, error)
CALL check("h5dopen_f",error,total_error)

! Populate filename buffer with whitespace
do i = 1,80
file_name(i:i) = " "
end do

!
!Get file name from the dataset identifier
!
CALL h5fget_name_f(dset_id, file_name, name_size, error)
CALL check("h5fget_name_f",error,total_error)
IF(file_name(1:name_size) .NE. fix_filename(1:name_size)) THEN
IF(name_size /= 9) THEN
write(*,*) "file name obtained from the dataset id has wrong length"
call check("h5fget_name_f",-1,total_error)
END IF
IF(file_name(1:name_size) /= fix_filename(1:name_size)) THEN
write(*,*) "file name obtained from the dataset id is incorrect"
call check("h5fget_name_f",-1,total_error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave in the old test and add a new test:

     CALL h5dopen_f(reopen_id, dsetname, dset_id, error)
          CALL check("h5dopen_f",error,total_error)
     !
     !Get file name from the dataset identifier
     !
     ! Use an uninitialized buffer
     CALL h5fget_name_f(dset_id, file_name, name_size, error)
     CALL check("h5fget_name_f",error,total_error)
     IF(name_size .NE. LEN_TRIM(fix_filename))THEN
        WRITE(*,*) "  file name size obtained from the dataset id is incorrect"
        total_error = total_error + 1
     ENDIF
     IF(file_name(1:name_size) .NE. TRIM(fix_filename)) THEN
        WRITE(*,*) "  file name obtained from the dataset id is incorrect"
        total_error = total_error + 1
     END IF
     ! Use an initialized buffer
     file_name(:) = " "
     CALL h5fget_name_f(dset_id, file_name, name_size, error)
     CALL check("h5fget_name_f",error,total_error)
     IF(name_size .NE. LEN_TRIM(fix_filename))THEN
        WRITE(*,*) "  file name size obtained from the dataset id is incorrect"
        total_error = total_error + 1
     ENDIF
     IF(file_name(1:name_size) .NE. TRIM(fix_filename)) THEN
        WRITE(*,*) "  file name obtained from the dataset id is incorrect"
        total_error = total_error + 1
     END IF

     !
     !Read the dataset.
     !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size should always be correct, just the filename would be wrong since the buffer size given was zero.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave in the old test and add a new test

I pushed some changes reverting my edits to reopentest and adding a new test focusing on h5fget_name_f.

END IF

!
Expand Down