@@ -254,79 +254,65 @@ subroutine test_io()
254
254
' write_bitset'
255
255
256
256
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 ' )
259
259
call set2 % write_bitset(unit)
260
260
call set1 % write_bitset(unit)
261
261
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 )
265
263
call set3 % read_bitset(unit)
266
264
call set5 % read_bitset(unit)
267
265
call set4 % read_bitset(unit)
268
266
if ( set4 /= set0 .or. set5 /= set1 .or. set3 /= set2 ) then
269
267
error stop procedure // ' transfer to and from units using ' // &
270
- ' bitset literals failed.'
268
+ ' bitset literals failed.'
271
269
else
272
270
write (* ,* ) ' Transfer to and from units using ' // &
273
271
' plain write_bitset_unit and read_bitset_unit succeeded.'
274
272
end if
275
273
276
- close ( unit )
274
+ rewind ( unit )
277
275
278
276
call set12 % from_string( bitstring_33 // bitstring_33 )
279
- open ( newunit= unit, file= ' test2.txt' , status= ' replace' , &
280
- form= ' formatted' , action= ' write' )
281
277
call set12 % write_bitset(unit)
282
278
call set11 % write_bitset(unit)
283
279
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 )
287
281
call set13 % read_bitset(unit)
288
282
call set15 % read_bitset(unit)
289
283
call set14 % read_bitset(unit)
290
284
if ( set14 /= set10 .or. set15 /= set11 .or. set3 /= set12 ) then
291
285
error stop procedure // ' transfer to and from units using ' // &
292
- ' bitset literals for bits > 64 failed.'
286
+ ' bitset literals for bits > 64 failed.'
293
287
else
294
288
write (* ,* ) ' Transfer bits > 64 to and from units using ' // &
295
289
' plain write_bitset_unit and read_bitset_unit succeeded.'
296
290
end if
297
291
298
- close ( unit )
292
+ rewind ( unit )
299
293
300
- open ( newunit= unit, file= ' test3.txt' , status= ' replace' , &
301
- form= ' formatted' , action= ' write' )
302
294
call set2 % write_bitset(unit, advance= ' no' )
303
295
call set1 % write_bitset(unit, advance= ' no' )
304
296
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 )
308
298
call set3 % read_bitset(unit, advance= ' no' )
309
299
call set4 % read_bitset(unit, advance= ' no' )
310
300
call set5 % read_bitset(unit)
311
301
if ( set5 /= set0 .or. set4 /= set1 .or. set3 /= set2 ) then
312
302
error stop procedure // ' transfer to and from units using ' // &
313
- ' bitset literals with advance == "no" failed.'
303
+ ' bitset literals with advance == "no" failed.'
314
304
else
315
305
write (* ,* ) ' Transfer to and from units using ' // &
316
306
' write_bitset_unit and read_bitset_unit with ' // &
317
307
' advance=="no" succeeded.'
318
308
end if
319
309
320
- close ( unit )
310
+ rewind ( unit )
321
311
322
- open ( newunit= unit, file= ' test4.txt' , status= ' replace' , &
323
- form= ' formatted' , action= ' write' )
324
312
call set12 % write_bitset(unit, advance= ' no' )
325
313
call set11 % write_bitset(unit, advance= ' no' )
326
314
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 )
330
316
call set13 % read_bitset(unit, advance= ' no' )
331
317
call set14 % read_bitset(unit, advance= ' no' )
332
318
call set15 % read_bitset(unit)
@@ -339,82 +325,76 @@ subroutine test_io()
339
325
' advance=="no" succeeded.'
340
326
end if
341
327
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' )
344
332
call set2 % output(unit)
345
333
call set1 % output(unit)
346
334
call set0 % output(unit)
347
- close ( unit )
348
- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
349
- form= ' unformatted' , action= ' read' )
335
+ rewind( unit )
350
336
call set5 % input(unit)
351
337
call set4 % input(unit)
352
338
call set3 % input(unit)
353
339
if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
354
340
error stop procedure // ' transfer to and from units using ' // &
355
- ' output and input failed.'
341
+ ' output and input failed.'
356
342
else
357
343
write (* ,* ) ' Transfer to and from units using ' // &
358
344
' output and input succeeded.'
359
345
end if
360
346
361
347
close ( unit )
362
348
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 ' )
365
351
call set2 % output(unit)
366
352
call set1 % output(unit)
367
353
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 )
371
355
call set5 % input(unit)
372
356
call set4 % input(unit)
373
357
call set3 % input(unit)
374
358
if ( set3 /= set0 .or. set4 /= set1 .or. set5 /= set2 ) then
375
359
error stop procedure // ' transfer to and from units using ' // &
376
- ' stream output and input failed.'
360
+ ' stream output and input failed.'
377
361
else
378
362
write (* ,* ) ' Transfer to and from units using ' // &
379
363
' stream output and input succeeded.'
380
364
end if
381
365
382
366
close ( unit )
383
367
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 ' )
386
370
call set12 % output(unit)
387
371
call set11 % output(unit)
388
372
call set10 % output(unit)
389
- close ( unit )
390
- open ( newunit= unit, file= ' test.bin' , status= ' old' , &
391
- form= ' unformatted' , action= ' read' )
373
+ rewind( unit )
392
374
call set15 % input(unit)
393
375
call set14 % input(unit)
394
376
call set13 % input(unit)
395
377
if ( set13 /= set10 .or. set14 /= set11 .or. set15 /= set12 ) then
396
378
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.'
398
380
else
399
381
write (* ,* ) ' Transfer to and from units using ' // &
400
382
' output and input succeeded for bits > 64.'
401
383
end if
402
384
close (unit)
403
385
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 ' )
406
388
call set12 % output(unit)
407
389
call set11 % output(unit)
408
390
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 )
412
392
call set15 % input(unit)
413
393
call set14 % input(unit)
414
394
call set13 % input(unit)
415
395
if ( set13 /= set10 .or. set14 /= set11 .or. set15 /= set12 ) then
416
396
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.'
418
398
else
419
399
write (* ,* ) ' Transfer to and from units using ' // &
420
400
' stream output and input succeeded for bits > 64.'
0 commit comments