2D AMRCLAW
resize_alloc.f90
Go to the documentation of this file.
1 ! ============================================================================
2 ! Program: AMRClaw
3 ! File: resize_storage.f90
4 ! Created: 2009-01-21
5 ! Author: Kyle Mandli and Marsha Berger
6 ! ============================================================================
7 ! Description: Resize the alloc array for AMR storage
8 ! ============================================================================
9 
10 
11 ! NOTE: Older f90 compilers (e.g. gfortran prior to 4.2?)
12 ! may not implement move_alloc. If this fails, you may need to use
13 ! resize_storage_static.f90 instead of this routine and set the
14 ! allocation large enough in init_alloc.f90 to avoid running out of space.
15 
16 
17 subroutine resize_storage(new_size,status)
18 
19  use amr_module
20  implicit none
21 
22  integer, intent(out) :: status
23  integer, intent(in) :: new_size
24 
25  real(kind=8), allocatable, target, dimension(:) :: new_storage
26 
27 
28  if (memsize < new_size) then
29  print *, "Expanding storage from ", memsize," to ", new_size
30  allocate(new_storage(new_size),stat=status)
31  if (status > 0) then
32  return
33  endif
34 ! new_storage(1:memsize) = storage !old way, changed mjb sept. 2014
35  new_storage(1:memsize) = alloc ! new way, use allocatable, not pointer
36 
37 ! call move_alloc(new_storage,storage)
38  call move_alloc(new_storage,alloc)
39 
40 ! alloc => storage
41  memsize = new_size
42  else
43  print *,'new_size < memsize,'
44  print *,'new_size = ',new_size
45  print *,'memsize = ',memsize
46  stop
47  endif
48 
49  return
50 
51 end subroutine resize_storage
integer memsize
Definition: amr_module.f90:219
subroutine resize_storage(new_size, status)
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21
real(kind=8), dimension(:), allocatable alloc
Definition: amr_module.f90:218