@@ -12,8 +12,6 @@ program test_string
1212
1313character (2 ) :: value
1414character (1024 ) :: val1k
15- character (:), allocatable :: final
16- integer :: i
1715character (* ), parameter :: path= ' test_string.nc'
1816
1917call h% open (path, action= ' w' )
@@ -26,23 +24,19 @@ program test_string
2624call h% open (path, action= ' r' )
2725call h% read (' little' , value)
2826
29- if (value /= ' 42' ) then
30- write (stderr,* ) ' test_string: read/write verification failure. Value: ' // value
31- error stop
32- endif
27+ if (value /= ' 42' ) error stop ' test_string: read/write verification failure. Value: ' // value
3328
3429print * ,' test_string_rw: reading too much data'
3530! ! try reading too much data, then truncating to first C_NULL
3631call h% read (' little' , val1k)
37- i = index (val1k, c_null_char)
38- final = val1k(:i-1 )
3932
40- if (len (final) /= 2 ) then
41- write (stderr, * ) ' trimming str to c_null did not work, got len() = ' , len (final)
42- write (stderr, * ) iachar (final(3 :3 ))
33+ if (len_trim (val1k) /= 2 ) then
34+ write (stderr, * ) ' expected len_trim 2, got len_trim = ' , len (val1k)
4335 error stop
4436endif
4537
4638call h% close ()
4739
40+ print * , ' OK: test_string'
41+
4842end program
0 commit comments