From 7f2a478f030a0ef50a182c343f0a067b4d8c20a5 Mon Sep 17 00:00:00 2001 From: Austin Blevins Date: Thu, 1 Dec 2022 16:23:58 -0500 Subject: [PATCH] fixed a bug in array initiation, but now it segfaults when writing --- src/util/util_init_array.f90 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/util_init_array.f90 b/src/util/util_init_array.f90 index e1c2dc52..3ef9b688 100644 --- a/src/util/util_init_array.f90 +++ b/src/util/util_init_array.f90 @@ -44,12 +44,15 @@ subroutine util_init_array(regolayer,initstat) ! regolayer%regodata%porosity = 0.0_DP ! regolayer%regodata%age(:) = 0.0_SP if (allocated(regolayer)) deallocate(regolayer) - allocate(regolayer(1)) - regolayer(1)%thickness = sqrt(VBIG) ! This generates a buffer layer that the model should never reach if the run is structured properly - regolayer(1)%comp = 0.0_DP - regolayer(1)%meltfrac = 0.0_DP - regolayer(1)%porosity = 0.0_DP - regolayer(1)%age(:) = 0.0_SP + allocate(regolayer(1),stat=allocstat) + if (allocstat == 0) then + initstat = .true. + regolayer(1)%thickness = sqrt(VBIG) ! This generates a buffer layer that the model should never reach if the run is structured properly + regolayer(1)%comp = 0.0_DP + regolayer(1)%meltfrac = 0.0_DP + regolayer(1)%porosity = 0.0_DP + regolayer(1)%age(:) = 0.0_SP + end if ! else ! write(*,*) 'util_init_list: Initialization failed. Exhausted memory.' ! end if