[svn-r22825] Fix for: HDFFV-7903 Fortran problem writing control character to a dataset

Tested: (jam, gfortran)
This commit is contained in:
Scot Breitenfeld 2012-09-27 14:20:09 -05:00
parent a81cc2ac7e
commit 32a131ea70
8 changed files with 46 additions and 11 deletions

View File

@ -219,7 +219,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@ -234,7 +233,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@

View File

@ -190,7 +190,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@ -205,7 +204,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@

View File

@ -53,7 +53,7 @@ HD5f2cstring(_fcd fdesc, size_t len)
/* Search for the end of the string */
str = _fcdtocp(fdesc);
for(i = (int)len - 1; i >= 0 && !HDisgraph((int)str[i]); i--)
for(i = (int)len - 1; i >= 0 && HDisspace((int)str[i]) && str[i] == ' '; i--)
/*EMPTY*/;
/* Allocate C string */

View File

@ -307,7 +307,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@ -322,7 +321,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@

View File

@ -290,7 +290,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@ -305,7 +304,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@

View File

@ -116,6 +116,10 @@ PROGRAM fortranlibtest_F03
CALL t_string(ret_total_error)
CALL write_test_status(ret_total_error, ' Testing writing/reading string datatypes, using C_LOC', total_error)
ret_total_error = 0
CALL vl_test_special_char(ret_total_error)
CALL write_test_status(ret_total_error, ' Testing string datatypes containing control characters', total_error)
ret_total_error = 0
CALL test_create(ret_total_error)
CALL write_test_status(ret_total_error, &

View File

@ -2800,6 +2800,47 @@ SUBROUTINE t_string(total_error)
END SUBROUTINE t_string
SUBROUTINE vl_test_special_char(cleanup, total_error)
USE hdf5
IMPLICIT NONE
INTERFACE
SUBROUTINE setup_buffer(data_in, line_lengths, char_type)
USE hdf5
USE ISO_C_BINDING
IMPLICIT NONE
CHARACTER(len=*), DIMENSION(:) :: data_in
INTEGER(size_t), DIMENSION(:) :: line_lengths
CHARACTER(KIND=C_CHAR,LEN=*) :: char_type
END SUBROUTINE setup_buffer
END INTERFACE
LOGICAL, INTENT(IN) :: cleanup
INTEGER, INTENT(OUT) :: total_error
CHARACTER(LEN=16), PARAMETER :: filename = "t_controlchar.h5"
INTEGER, PARAMETER :: line_length = 10
INTEGER(hid_t) :: file
INTEGER(hid_t) :: dataset0
CHARACTER(len=line_length), DIMENSION(1:100) :: data_in
CHARACTER(len=line_length), DIMENSION(1:100) :: data_out
INTEGER(size_t), DIMENSION(1:100) :: line_lengths
INTEGER(hid_t) :: string_id, space, dcpl
INTEGER(hsize_t), DIMENSION(1:1) :: dims = (/0/)
INTEGER(hsize_t), DIMENSION(1:1) :: max_dims = (/0/)
INTEGER(hsize_t), DIMENSION(1:2) :: data_dims = (/0,0/)
INTEGER(hsize_t), DIMENSION(1:1) :: chunk =(/10/)
INTEGER, PARAMETER :: ncontrolchar = 7
CHARACTER(KIND=C_CHAR,LEN=1), DIMENSION(1:ncontrolchar) :: controlchar = &
(/C_ALERT, C_BACKSPACE,C_CARRIAGE_RETURN, C_FORM_FEED,C_HORIZONTAL_TAB,C_VERTICAL_TAB, C_NEW_LINE/)
INTEGER :: i, j, n, error
n = 8
!
! Create a new file using the default properties.
!
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file, error)
CALL check("h5fcreate_f",error, total_error)
!-------------------------------------------------------------------------
! Function: test_nbit

View File

@ -217,7 +217,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@ -232,7 +231,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@