File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1515fn = Path (P .file ).expanduser ()
1616
1717with h5py .File (fn , "w" ) as f :
18- f ["/str" ] = "Hello World!"
18+ f ["/variable" ] = "Hello World!"
19+ f .create_dataset ("/nullpad" , dtype = "S40" , data = "Hello World!" )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ program main
44
55implicit none (type, external )
66
7- character (1000 ) :: pyp, str
7+ character (1000 ) :: pyp, vstr, fstr
88integer :: i
99
1010type (hdf5_file) :: h
@@ -14,12 +14,14 @@ program main
1414
1515call h% open (pyp, " r" )
1616
17- call h% read (" /str" , str)
17+ call h% read (" /variable" , vstr)
18+ if (vstr /= " Hello World!" ) error stop " h5py read variable length failed: " // trim (vstr)
1819
19- call h% close ()
20+ call h% read (" /nullpad" , fstr)
21+ if (fstr /= " Hello World!" ) error stop " h5py read null pad failed: " // trim (fstr)
2022
21- if (str /= " Hello World! " ) error stop " h5py read failed: " // trim (str )
23+ call h % close ( )
2224
23- print * , " OK: variable length string read"
25+ print * , " OK: variable/nullpad length string read"
2426
2527end program
You can’t perform that action at this time.
0 commit comments