MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
memorymanagermodule::mem_reallocate Interface Reference
Collaboration diagram for memorymanagermodule::mem_reallocate:
Collaboration graph

Private Member Functions

subroutine reallocate_int1d (aint, nrow, name, mem_path)
 Reallocate a 1-dimensional integer array. More...
 
subroutine reallocate_int2d (aint, ncol, nrow, name, mem_path)
 Reallocate a 2-dimensional integer array. More...
 
subroutine reallocate_dbl1d (adbl, nrow, name, mem_path)
 Reallocate a 1-dimensional real array. More...
 
subroutine reallocate_dbl2d (adbl, ncol, nrow, name, mem_path)
 Reallocate a 2-dimensional real array. More...
 
subroutine reallocate_str1d (astr, ilen, nrow, name, mem_path)
 Reallocate a 1-dimensional defined length string array. More...
 
subroutine reallocate_charstr1d (acharstr1d, ilen, nrow, name, mem_path)
 Reallocate a 1-dimensional deferred length string array. More...
 

Detailed Description

Definition at line 79 of file MemoryManager.f90.

Member Function/Subroutine Documentation

◆ reallocate_charstr1d()

subroutine memorymanagermodule::mem_reallocate::reallocate_charstr1d ( type(characterstringtype), dimension(:), intent(inout), pointer, contiguous  acharstr1d,
integer(i4b), intent(in)  ilen,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in,out]acharstr1dthe reallocated charstring array
[in]ilenstring length
[in]nrownumber of rows
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1181 of file MemoryManager.f90.

1182  type(CharacterStringType), dimension(:), pointer, contiguous, &
1183  intent(inout) :: acharstr1d !< the reallocated charstring array
1184  integer(I4B), intent(in) :: ilen !< string length
1185  integer(I4B), intent(in) :: nrow !< number of rows
1186  character(len=*), intent(in) :: name !< variable name
1187  character(len=*), intent(in) :: mem_path !< path where variable is stored
1188  ! -- local
1189  type(MemoryType), pointer :: mt
1190  logical(LGP) :: found
1191  type(CharacterStringType), dimension(:), allocatable :: astrtemp
1192  character(len=ilen) :: string
1193  integer(I4B) :: istat
1194  integer(I4B) :: isize
1195  integer(I4B) :: isize_old
1196  integer(I4B) :: nrow_old
1197  integer(I4B) :: n
1198  !
1199  ! -- Initialize string
1200  string = ''
1201  !
1202  ! -- Find and assign mt
1203  call get_from_memorystore(name, mem_path, mt, found)
1204  !
1205  ! -- reallocate astr1d
1206  if (found) then
1207  isize_old = mt%isize
1208  if (isize_old > 0) then
1209  nrow_old = size(acharstr1d)
1210  else
1211  nrow_old = 0
1212  end if
1213  !
1214  ! -- calculate isize
1215  isize = nrow
1216  !
1217  ! -- allocate astrtemp
1218  allocate (astrtemp(nrow), stat=istat, errmsg=errmsg)
1219  if (istat /= 0) then
1220  call allocate_error(name, mem_path, istat, isize)
1221  end if
1222  !
1223  ! -- copy existing values
1224  do n = 1, nrow_old
1225  astrtemp(n) = acharstr1d(n)
1226  end do
1227  !
1228  ! -- fill new values with missing values
1229  do n = nrow_old + 1, nrow
1230  astrtemp(n) = string
1231  end do
1232  !
1233  ! -- deallocate mt pointer, repoint, recalculate isize
1234  deallocate (acharstr1d)
1235  !
1236  ! -- allocate astr1d
1237  allocate (acharstr1d(nrow), stat=istat, errmsg=errmsg)
1238  if (istat /= 0) then
1239  call allocate_error(name, mem_path, istat, isize)
1240  end if
1241  !
1242  ! -- fill the reallocated character array
1243  do n = 1, nrow
1244  acharstr1d(n) = astrtemp(n)
1245  end do
1246  !
1247  ! -- deallocate temporary storage
1248  deallocate (astrtemp)
1249  !
1250  ! -- reset memory manager values
1251  mt%acharstr1d => acharstr1d
1252  mt%element_size = ilen
1253  mt%isize = isize
1254  mt%nrealloc = mt%nrealloc + 1
1255  mt%master = .true.
1256  nvalues_astr = nvalues_astr + isize - isize_old
1257  write (mt%memtype, "(a,' LEN=',i0,' (',i0,')')") 'STRING', ilen, nrow
1258  else
1259  errmsg = "Programming error, variable '"//trim(name)//"' from '"// &
1260  trim(mem_path)//"' is not defined in the memory manager. Use "// &
1261  "mem_allocate instead."
1262  call store_error(errmsg, terminate=.true.)
1263  end if
Here is the call graph for this function:

◆ reallocate_dbl1d()

subroutine memorymanagermodule::mem_reallocate::reallocate_dbl1d ( real(dp), dimension(:), intent(inout), pointer, contiguous  adbl,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in,out]adblthe reallocated 1d real array
[in]nrownumber of rows
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1357 of file MemoryManager.f90.

1358  real(DP), dimension(:), pointer, contiguous, intent(inout) :: adbl !< the reallocated 1d real array
1359  integer(I4B), intent(in) :: nrow !< number of rows
1360  character(len=*), intent(in) :: name !< variable name
1361  character(len=*), intent(in) :: mem_path !< path where variable is stored
1362  ! -- local
1363  type(MemoryType), pointer :: mt
1364  integer(I4B) :: istat
1365  integer(I4B) :: isize
1366  integer(I4B) :: i
1367  integer(I4B) :: isizeold
1368  integer(I4B) :: ifill
1369  logical(LGP) :: found
1370  ! -- code
1371  !
1372  ! -- Find and assign mt
1373  call get_from_memorystore(name, mem_path, mt, found)
1374  !
1375  ! -- Allocate adbl and then refill
1376  isize = nrow
1377  isizeold = size(mt%adbl1d)
1378  ifill = min(isizeold, isize)
1379  allocate (adbl(nrow), stat=istat, errmsg=errmsg)
1380  if (istat /= 0) then
1381  call allocate_error(name, mem_path, istat, isize)
1382  end if
1383  do i = 1, ifill
1384  adbl(i) = mt%adbl1d(i)
1385  end do
1386  !
1387  ! -- deallocate mt pointer, repoint, recalculate isize
1388  deallocate (mt%adbl1d)
1389  mt%adbl1d => adbl
1390  mt%element_size = dp
1391  mt%isize = isize
1392  mt%nrealloc = mt%nrealloc + 1
1393  mt%master = .true.
1394  nvalues_adbl = nvalues_adbl + isize - isizeold
1395  write (mt%memtype, "(a,' (',i0,')')") 'DOUBLE', isize
Here is the call graph for this function:

◆ reallocate_dbl2d()

subroutine memorymanagermodule::mem_reallocate::reallocate_dbl2d ( real(dp), dimension(:, :), intent(inout), pointer, contiguous  adbl,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in,out]adblthe reallocated 2d real array
[in]ncolnumber of columns
[in]nrownumber of rows
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1400 of file MemoryManager.f90.

1401  real(DP), dimension(:, :), pointer, contiguous, intent(inout) :: adbl !< the reallocated 2d real array
1402  integer(I4B), intent(in) :: ncol !< number of columns
1403  integer(I4B), intent(in) :: nrow !< number of rows
1404  character(len=*), intent(in) :: name !< variable name
1405  character(len=*), intent(in) :: mem_path !< path where variable is stored
1406  ! -- local
1407  type(MemoryType), pointer :: mt
1408  logical(LGP) :: found
1409  integer(I4B) :: istat
1410  integer(I4B), dimension(2) :: ishape
1411  integer(I4B) :: i
1412  integer(I4B) :: j
1413  integer(I4B) :: isize
1414  integer(I4B) :: isizeold
1415  ! -- code
1416  !
1417  ! -- Find and assign mt
1418  call get_from_memorystore(name, mem_path, mt, found)
1419  !
1420  ! -- Allocate adbl and then refill
1421  ishape = shape(mt%adbl2d)
1422  isize = nrow * ncol
1423  isizeold = ishape(1) * ishape(2)
1424  allocate (adbl(ncol, nrow), stat=istat, errmsg=errmsg)
1425  if (istat /= 0) then
1426  call allocate_error(name, mem_path, istat, isize)
1427  end if
1428  do i = 1, ishape(2)
1429  do j = 1, ishape(1)
1430  adbl(j, i) = mt%adbl2d(j, i)
1431  end do
1432  end do
1433  !
1434  ! -- deallocate mt pointer, repoint, recalculate isize
1435  deallocate (mt%adbl2d)
1436  mt%adbl2d => adbl
1437  mt%element_size = dp
1438  mt%isize = isize
1439  mt%nrealloc = mt%nrealloc + 1
1440  mt%master = .true.
1441  nvalues_adbl = nvalues_adbl + isize - isizeold
1442  write (mt%memtype, "(a,' (',i0,',',i0,')')") 'DOUBLE', ncol, nrow
Here is the call graph for this function:

◆ reallocate_int1d()

subroutine memorymanagermodule::mem_reallocate::reallocate_int1d ( integer(i4b), dimension(:), intent(inout), pointer, contiguous  aint,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in,out]aintthe reallocated integer array
[in]nrownumber of rows
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1268 of file MemoryManager.f90.

1269  integer(I4B), dimension(:), pointer, contiguous, intent(inout) :: aint !< the reallocated integer array
1270  integer(I4B), intent(in) :: nrow !< number of rows
1271  character(len=*), intent(in) :: name !< variable name
1272  character(len=*), intent(in) :: mem_path !< path where variable is stored
1273  ! -- local
1274  type(MemoryType), pointer :: mt
1275  logical(LGP) :: found
1276  integer(I4B) :: istat
1277  integer(I4B) :: isize
1278  integer(I4B) :: i
1279  integer(I4B) :: isizeold
1280  integer(I4B) :: ifill
1281  ! -- code
1282  !
1283  ! -- Find and assign mt
1284  call get_from_memorystore(name, mem_path, mt, found)
1285  !
1286  ! -- Allocate aint and then refill
1287  isize = nrow
1288  isizeold = size(mt%aint1d)
1289  ifill = min(isizeold, isize)
1290  allocate (aint(nrow), stat=istat, errmsg=errmsg)
1291  if (istat /= 0) then
1292  call allocate_error(name, mem_path, istat, isize)
1293  end if
1294  do i = 1, ifill
1295  aint(i) = mt%aint1d(i)
1296  end do
1297  !
1298  ! -- deallocate mt pointer, repoint, recalculate isize
1299  deallocate (mt%aint1d)
1300  mt%aint1d => aint
1301  mt%element_size = i4b
1302  mt%isize = isize
1303  mt%nrealloc = mt%nrealloc + 1
1304  mt%master = .true.
1305  nvalues_aint = nvalues_aint + isize - isizeold
Here is the call graph for this function:

◆ reallocate_int2d()

subroutine memorymanagermodule::mem_reallocate::reallocate_int2d ( integer(i4b), dimension(:, :), intent(inout), pointer, contiguous  aint,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in,out]aintthe reallocated 2d integer array
[in]ncolnumber of columns
[in]nrownumber of rows
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1310 of file MemoryManager.f90.

1311  integer(I4B), dimension(:, :), pointer, contiguous, intent(inout) :: aint !< the reallocated 2d integer array
1312  integer(I4B), intent(in) :: ncol !< number of columns
1313  integer(I4B), intent(in) :: nrow !< number of rows
1314  character(len=*), intent(in) :: name !< variable name
1315  character(len=*), intent(in) :: mem_path !< path where variable is stored
1316  ! -- local
1317  type(MemoryType), pointer :: mt
1318  logical(LGP) :: found
1319  integer(I4B) :: istat
1320  integer(I4B), dimension(2) :: ishape
1321  integer(I4B) :: i
1322  integer(I4B) :: j
1323  integer(I4B) :: isize
1324  integer(I4B) :: isizeold
1325  ! -- code
1326  !
1327  ! -- Find and assign mt
1328  call get_from_memorystore(name, mem_path, mt, found)
1329  !
1330  ! -- Allocate aint and then refill
1331  ishape = shape(mt%aint2d)
1332  isize = nrow * ncol
1333  isizeold = ishape(1) * ishape(2)
1334  allocate (aint(ncol, nrow), stat=istat, errmsg=errmsg)
1335  if (istat /= 0) then
1336  call allocate_error(name, mem_path, istat, isize)
1337  end if
1338  do i = 1, ishape(2)
1339  do j = 1, ishape(1)
1340  aint(j, i) = mt%aint2d(j, i)
1341  end do
1342  end do
1343  !
1344  ! -- deallocate mt pointer, repoint, recalculate isize
1345  deallocate (mt%aint2d)
1346  mt%aint2d => aint
1347  mt%element_size = i4b
1348  mt%isize = isize
1349  mt%nrealloc = mt%nrealloc + 1
1350  mt%master = .true.
1351  nvalues_aint = nvalues_aint + isize - isizeold
1352  write (mt%memtype, "(a,' (',i0,',',i0,')')") 'INTEGER', ncol, nrow
Here is the call graph for this function:

◆ reallocate_str1d()

subroutine memorymanagermodule::mem_reallocate::reallocate_str1d ( character(len=ilen), dimension(:), intent(inout), pointer, contiguous  astr,
integer(i4b), intent(in)  ilen,
integer(i4b), intent(in)  nrow,
character(len=*), intent(in)  name,
character(len=*), intent(in)  mem_path 
)
private
Parameters
[in]ilenstring length
[in]nrownumber of rows
[in,out]astrthe reallocated string array
[in]namevariable name
[in]mem_pathpath where variable is stored

Definition at line 1100 of file MemoryManager.f90.

1101  integer(I4B), intent(in) :: ilen !< string length
1102  integer(I4B), intent(in) :: nrow !< number of rows
1103  character(len=ilen), dimension(:), pointer, contiguous, intent(inout) :: astr !< the reallocated string array
1104  character(len=*), intent(in) :: name !< variable name
1105  character(len=*), intent(in) :: mem_path !< path where variable is stored
1106  ! -- local
1107  type(MemoryType), pointer :: mt
1108  logical(LGP) :: found
1109  character(len=ilen), dimension(:), allocatable :: astrtemp
1110  integer(I4B) :: istat
1111  integer(I4B) :: isize
1112  integer(I4B) :: isize_old
1113  integer(I4B) :: nrow_old
1114  integer(I4B) :: n
1115  !
1116  ! -- Find and assign mt
1117  call get_from_memorystore(name, mem_path, mt, found)
1118  !
1119  ! -- reallocate astr1d
1120  if (found) then
1121  isize_old = mt%isize
1122  if (isize_old > 0) then
1123  nrow_old = size(astr)
1124  else
1125  nrow_old = 0
1126  end if
1127  !
1128  ! -- calculate isize
1129  isize = nrow
1130  !
1131  ! -- allocate astrtemp
1132  allocate (astrtemp(nrow), stat=istat, errmsg=errmsg)
1133  if (istat /= 0) then
1134  call allocate_error(name, mem_path, istat, isize)
1135  end if
1136  !
1137  ! -- copy existing values
1138  do n = 1, nrow_old
1139  astrtemp(n) = astr(n)
1140  end do
1141  !
1142  ! -- fill new values with missing values
1143  do n = nrow_old + 1, nrow
1144  astrtemp(n) = ''
1145  end do
1146  !
1147  ! -- deallocate mt pointer, repoint, recalculate isize
1148  deallocate (astr)
1149  !
1150  ! -- allocate astr1d
1151  allocate (astr(nrow), stat=istat, errmsg=errmsg)
1152  if (istat /= 0) then
1153  call allocate_error(name, mem_path, istat, isize)
1154  end if
1155  !
1156  ! -- fill the reallocate character array
1157  do n = 1, nrow
1158  astr(n) = astrtemp(n)
1159  end do
1160  !
1161  ! -- deallocate temporary storage
1162  deallocate (astrtemp)
1163  !
1164  ! -- reset memory manager values
1165  mt%element_size = ilen
1166  mt%isize = isize
1167  mt%nrealloc = mt%nrealloc + 1
1168  mt%master = .true.
1169  nvalues_astr = nvalues_astr + isize - isize_old
1170  write (mt%memtype, "(a,' LEN=',i0,' (',i0,')')") 'STRING', ilen, nrow
1171  else
1172  errmsg = "Programming error, variable '"//trim(name)//"' from '"// &
1173  trim(mem_path)//"' is not defined in the memory manager. Use "// &
1174  "mem_allocate instead."
1175  call store_error(errmsg, terminate=.true.)
1176  end if
Here is the call graph for this function:

The documentation for this interface was generated from the following file: