From 78a246b44ac78276d5586e52c413925ec5a033b4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 5 Dec 2020 12:46:48 +0100 Subject: [PATCH] avoid constant reallocation, it is slow for large vtr files --- src/grid/discretization_grid.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index 93fd4d82b..1b3700c14 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -404,12 +404,12 @@ subroutine readVTR(grid,geomSize,origin,material) size_deflated = temp(4:) bytes_inflated = base64_to_bytes(base64_str(base64_nChar(headerLen)+1_pI64:)) - allocate(bytes(0)) + allocate(bytes(sum(size_inflated))) e = 0_pI64 do b = 1, nBlock s = e + 1_pI64 e = s + size_deflated(b) - 1_pI64 - bytes = [bytes,zlib_inflate(bytes_inflated(s:e),size_inflated(b))] + bytes(sum(size_inflated(:b-1))+1_pI64:sum(size_inflated(:b))) = zlib_inflate(bytes_inflated(s:e),size_inflated(b)) enddo end function asBytes_compressed