IO: Use compression_bound() to determine the buffer size.
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
e4ffa62714
commit
9ddf7c7b44
@ -2806,7 +2806,7 @@ module io
|
||||
array_bytes, array_digest, &
|
||||
compressed_bytes, compressed_digest)
|
||||
|
||||
use compression, only : get_compression, compress
|
||||
use compression, only : get_compression, compression_bound, compress
|
||||
use hash , only : get_hash
|
||||
|
||||
implicit none
|
||||
@ -2841,10 +2841,11 @@ module io
|
||||
! try to compress array and write it
|
||||
!
|
||||
if (present(compressed_bytes) .and. get_compression() > 0) then
|
||||
allocate(buffer(array_bytes), stat = status)
|
||||
compressed_bytes = compression_bound(array_bytes)
|
||||
allocate(buffer(compressed_bytes), stat = status)
|
||||
if (status == 0) then
|
||||
call compress(array, array_bytes, buffer, compressed_bytes)
|
||||
if (compressed_bytes > 0) then
|
||||
if (compressed_bytes < array_bytes) then
|
||||
open(newunit = lun, file = fname, form = 'unformatted', &
|
||||
access = 'stream', status = 'replace')
|
||||
write(lun) buffer(1:compressed_bytes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user