@@ -254,79 +254,65 @@ subroutine test_io()
254254 ' write_bitset'
255255
256256 call set2 % from_string( bitstring_33 )
257- open ( newunit= unit, file = ' test1.txt ' , status = ' replace ' , &
258- form = ' formatted ' , action= ' write ' )
257+ open ( newunit= unit, status = ' scratch ' , form = ' formatted ' , &
258+ action= ' readwrite ' )
259259 call set2 % write_bitset(unit)
260260 call set1 % write_bitset(unit)
261261 call set0 % write_bitset(unit)
262- close ( unit )
263- open ( newunit= unit, file= ' test1.txt' , status= ' old' , &
264- form= ' formatted' , action= ' read' )
262+ rewind( unit )
265263 call set3 % read_bitset(unit)
266264 call set5 % read_bitset(unit)
267265 call set4 % read_bitset(unit)
268266 if ( set4 /= set0 .or. set5 /= set1 .or. set3 /= set2 ) then
269267 error stop procedure // ' transfer to and from units using ' // &
270- ' bitset literals failed.'
268+ ' bitset literals failed.'
271269 else
272270 write (* ,* ) ' Transfer to and from units using ' // &
273271 ' plain write_bitset_unit and read_bitset_unit succeeded.'
274272 end if
275273
276- close ( unit )
274+ rewind ( unit )
277275
278276 call set12 % from_string( bitstring_33 // bitstring_33 )
279- open ( newunit= unit, file= ' test2.txt' , status= ' replace' , &
280- form= ' formatted' , action= ' write' )
281277 call set12 % write_bitset(unit)
282278 call set11 % write_bitset(unit)
283279 call set10 % write_bitset(unit)
284- close ( unit )
285- open ( newunit= unit, file= ' test2.txt' , status= ' old' , &
286- form= ' formatted' , action= ' read' )
280+ rewind( unit )
287281 call set13 % read_bitset(unit)
288282 call set15 % read_bitset(unit)
289283 call set14 % read_bitset(unit)
290284 if ( set14 /= set10 .or. set15 /= set11 .or. set3 /= set12 ) then
291285 error stop procedure // ' transfer to and from units using ' // &
292- ' bitset literals for bits > 64 failed.'
286+ ' bitset literals for bits > 64 failed.'
293287 else
294288 write (* ,* ) ' Transfer bits > 64 to and from units using ' // &
295289 ' plain write_bitset_unit and read_bitset_unit succeeded.'
296290 end if
297291
298- close ( unit )
292+ rewind ( unit )
299293
300- open ( newunit= unit, file= ' test3.txt' , status= ' replace' , &
301- form= ' formatted' , action= ' write' )
302294 call set2 % write_bitset(unit, advance= ' no' )
303295 call set1 % write_bitset(unit, advance= ' no' )
304296 call set0 % write_bitset(unit)
305- close ( unit )
306- open ( newunit= unit, file= ' test3.txt' , status= ' old' , &
307- form= ' formatted' , action= ' read' )
297+ rewind( unit )
308298 call set3 % read_bitset(unit, advance= ' no' )
309299 call set4 % read_bitset(unit, advance= ' no' )
310300 call set5 % read_bitset(unit)
311301 if ( set5 /= set0 .or. set4 /= set1 .or. set3 /= set2 ) then
312302 error stop procedure // ' transfer to and from units using ' // &
313- ' bitset literals with advance == "no" failed.'
303+ ' bitset literals with advance == "no" failed.'
314304 else
315305 write (* ,* ) ' Transfer to and from units using ' // &
316306 ' write_bitset_unit and read_bitset_unit with ' // &
317307 ' advance=="no" succeeded.'
318308 end if
319309
320- close ( unit )
310+ rewind ( unit )
321311
322- open ( newunit= unit, file= ' test4.txt' , status= ' replace' , &
323- form= ' formatted' , action= ' write' )
324312 call set12 % write_bitset(unit, advance= ' no' )
325313 call set11 % write_bitset(unit, advance= ' no' )
326314 call set10 % write_bitset(unit)
327- close ( unit )
328- open ( newunit= unit, file= ' test4.txt' , status= ' old' , &
329- form= ' formatted' , action= ' read' )
315+ rewind( unit )
330316 call set13 % read_bitset(unit, advance= ' no' )
331317 call set14 % read_bitset(unit, advance= ' no' )
332318 call set15 % read_bitset(unit)
@@ -339,82 +325,76 @@ subroutine test_io()
339325 ' advance=="no" succeeded.'
340326 end if
341327
342- open ( newunit= unit, file= ' test.bin' , status= ' replace' , &
343- form= ' unformatted' , action= ' write' )
328+ close (unit)
329+
330+ open ( newunit= unit, form= ' unformatted' , status= ' scratch' , &
331+ action= ' readwrite' )
344332 call set2 % output(unit)
345333 call set1 % output(unit)
346334 call set0 % output(unit)
347- close ( unit )
348- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
349- form= ' unformatted' , action= ' read' )
335+ rewind( unit )
350336 call set5 % input(unit)
351337 call set4 % input(unit)
352338 call set3 % input(unit)
353339 if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
354340 error stop procedure // ' transfer to and from units using ' // &
355- ' output and input failed.'
341+ ' output and input failed.'
356342 else
357343 write (* ,* ) ' Transfer to and from units using ' // &
358344 ' output and input succeeded.'
359345 end if
360346
361347 close ( unit )
362348
363- open ( newunit= unit, file = ' test.bin ' , status = ' replace ' , &
364- form = ' unformatted ' , access = ' stream ' , action= ' write ' )
349+ open ( newunit= unit, form = ' unformatted ' , access = ' stream ' , &
350+ status = ' scratch ' , action= ' readwrite ' )
365351 call set2 % output(unit)
366352 call set1 % output(unit)
367353 call set0 % output(unit)
368- close ( unit )
369- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
370- form= ' unformatted' , access= ' stream' , action= ' read' )
354+ rewind( unit )
371355 call set5 % input(unit)
372356 call set4 % input(unit)
373357 call set3 % input(unit)
374358 if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
375359 error stop procedure // ' transfer to and from units using ' // &
376- ' stream output and input failed.'
360+ ' stream output and input failed.'
377361 else
378362 write (* ,* ) ' Transfer to and from units using ' // &
379363 ' stream output and input succeeded.'
380364 end if
381365
382366 close ( unit )
383367
384- open ( newunit= unit, file = ' test.bin ' , status= ' replace ' , &
385- form = ' unformatted ' , action= ' write ' )
368+ open ( newunit= unit, form = ' unformatted ' , status= ' scratch ' , &
369+ action= ' readwrite ' )
386370 call set12 % output(unit)
387371 call set11 % output(unit)
388372 call set10 % output(unit)
389- close ( unit )
390- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
391- form= ' unformatted' , action= ' read' )
373+ rewind( unit )
392374 call set15 % input(unit)
393375 call set14 % input(unit)
394376 call set13 % input(unit)
395377 if ( set13 /= set10 .or. set14 /= set11 .or. set15 /= set12 ) then
396378 error stop procedure // ' transfer to and from units using ' // &
397- ' output and input failed for bits . 64.'
379+ ' output and input failed for bits . 64.'
398380 else
399381 write (* ,* ) ' Transfer to and from units using ' // &
400382 ' output and input succeeded for bits > 64.'
401383 end if
402384 close (unit)
403385
404- open ( newunit= unit, file = ' test.bin ' , status = ' replace ' , &
405- form = ' unformatted ' , access = ' stream ' , action= ' write ' )
386+ open ( newunit= unit, form = ' unformatted ' , access = ' stream ' , &
387+ status = ' scratch ' , action= ' readwrite ' )
406388 call set12 % output(unit)
407389 call set11 % output(unit)
408390 call set10 % output(unit)
409- close ( unit )
410- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
411- form= ' unformatted' , access= ' stream' , action= ' read' )
391+ rewind( unit )
412392 call set15 % input(unit)
413393 call set14 % input(unit)
414394 call set13 % input(unit)
415395 if ( set13 /= set10 .or. set14 /= set11 .or. set15 /= set12 ) then
416396 error stop procedure // ' transfer to and from units using ' // &
417- ' stream output and input failed for bits . 64.'
397+ ' stream output and input failed for bits . 64.'
418398 else
419399 write (* ,* ) ' Transfer to and from units using ' // &
420400 ' stream output and input succeeded for bits > 64.'
0 commit comments