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

Private Member Functions

subroutine reallocate_logical1d (alog, nrow, name, mem_path)
 Reallocate a 1-dimensional logical array. More...
 
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 81 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 1271 of file MemoryManager.f90.

1272  type(CharacterStringType), dimension(:), pointer, contiguous, &
1273  intent(inout) :: acharstr1d !< the reallocated charstring array
1274  integer(I4B), intent(in) :: ilen !< string length
1275  integer(I4B), intent(in) :: nrow !< number of rows
1276  character(len=*), intent(in) :: name !< variable name
1277  character(len=*), intent(in) :: mem_path !< path where variable is stored
1278  ! -- local
1279  type(MemoryType), pointer :: mt
1280  logical(LGP) :: found
1281  type(CharacterStringType), dimension(:), allocatable :: astrtemp
1282  character(len=ilen) :: string
1283  integer(I4B) :: istat
1284  integer(I4B) :: isize
1285  integer(I4B) :: isize_old
1286  integer(I4B) :: nrow_old
1287  integer(I4B) :: n
1288  !
1289  ! -- Initialize string
1290  string = ''
1291  !
1292  ! -- Find and assign mt
1293  call get_from_memorystore(name, mem_path, mt, found)
1294  !
1295  ! -- reallocate astr1d
1296  if (found) then
1297  isize_old = mt%isize
1298  if (isize_old > 0) then
1299  nrow_old = size(acharstr1d)
1300  else
1301  nrow_old = 0
1302  end if
1303  !
1304  ! -- calculate isize
1305  isize = nrow
1306  !
1307  ! -- allocate astrtemp
1308  allocate (astrtemp(nrow), stat=istat, errmsg=errmsg)
1309  if (istat /= 0) then
1310  call allocate_error(name, mem_path, istat, isize)
1311  end if
1312  !
1313  ! -- copy existing values
1314  do n = 1, nrow_old
1315  astrtemp(n) = acharstr1d(n)
1316  call acharstr1d(n)%destroy()
1317  end do
1318  !
1319  ! -- fill new values with missing values
1320  do n = nrow_old + 1, nrow
1321  astrtemp(n) = string
1322  end do
1323  !
1324  ! -- deallocate mt pointer, repoint, recalculate isize
1325  deallocate (acharstr1d)
1326  !
1327  ! -- allocate astr1d
1328  allocate (acharstr1d(nrow), stat=istat, errmsg=errmsg)
1329  if (istat /= 0) then
1330  call allocate_error(name, mem_path, istat, isize)
1331  end if
1332  !
1333  ! -- fill the reallocated character array
1334  do n = 1, nrow
1335  acharstr1d(n) = astrtemp(n)
1336  call astrtemp(n)%destroy()
1337  end do
1338  !
1339  ! -- deallocate temporary storage
1340  deallocate (astrtemp)
1341  !
1342  ! -- reset memory manager values
1343  mt%acharstr1d => acharstr1d
1344  mt%element_size = ilen
1345  mt%isize = isize
1346  mt%nrealloc = mt%nrealloc + 1
1347  mt%master = .true.
1348  nvalues_astr = nvalues_astr + isize - isize_old
1349  write (mt%memtype, "(a,' LEN=',i0,' (',i0,')')") 'STRING', ilen, nrow
1350  else
1351  errmsg = "Programming error, variable '"//trim(name)//"' from '"// &
1352  trim(mem_path)//"' is not defined in the memory manager. Use "// &
1353  "mem_allocate instead."
1354  call store_error(errmsg, terminate=.true.)
1355  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 1491 of file MemoryManager.f90.

1492  real(DP), dimension(:), pointer, contiguous, intent(inout) :: adbl !< the reallocated 1d real array
1493  integer(I4B), intent(in) :: nrow !< number of rows
1494  character(len=*), intent(in) :: name !< variable name
1495  character(len=*), intent(in) :: mem_path !< path where variable is stored
1496  ! -- local
1497  type(MemoryType), pointer :: mt
1498  integer(I4B) :: istat
1499  integer(I4B) :: isize
1500  integer(I4B) :: i
1501  integer(I4B) :: isizeold
1502  integer(I4B) :: ifill
1503  logical(LGP) :: found
1504  ! -- code
1505  !
1506  ! -- Find and assign mt
1507  call get_from_memorystore(name, mem_path, mt, found)
1508  !
1509  ! -- Allocate adbl and then refill
1510  isize = nrow
1511  isizeold = size(mt%adbl1d)
1512  ifill = min(isizeold, isize)
1513  allocate (adbl(nrow), stat=istat, errmsg=errmsg)
1514  if (istat /= 0) then
1515  call allocate_error(name, mem_path, istat, isize)
1516  end if
1517  do i = 1, ifill
1518  adbl(i) = mt%adbl1d(i)
1519  end do
1520  !
1521  ! -- deallocate mt pointer, repoint, recalculate isize
1522  deallocate (mt%adbl1d)
1523  mt%adbl1d => adbl
1524  mt%element_size = dp
1525  mt%isize = isize
1526  mt%nrealloc = mt%nrealloc + 1
1527  mt%master = .true.
1528  nvalues_adbl = nvalues_adbl + isize - isizeold
1529  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 1534 of file MemoryManager.f90.

1535  real(DP), dimension(:, :), pointer, contiguous, intent(inout) :: adbl !< the reallocated 2d real array
1536  integer(I4B), intent(in) :: ncol !< number of columns
1537  integer(I4B), intent(in) :: nrow !< number of rows
1538  character(len=*), intent(in) :: name !< variable name
1539  character(len=*), intent(in) :: mem_path !< path where variable is stored
1540  ! -- local
1541  type(MemoryType), pointer :: mt
1542  logical(LGP) :: found
1543  integer(I4B) :: istat
1544  integer(I4B), dimension(2) :: ishape
1545  integer(I4B) :: i
1546  integer(I4B) :: j
1547  integer(I4B) :: isize
1548  integer(I4B) :: isizeold
1549  ! -- code
1550  !
1551  ! -- Find and assign mt
1552  call get_from_memorystore(name, mem_path, mt, found)
1553  !
1554  ! -- Allocate adbl and then refill
1555  ishape = shape(mt%adbl2d)
1556  isize = nrow * ncol
1557  isizeold = ishape(1) * ishape(2)
1558  allocate (adbl(ncol, nrow), stat=istat, errmsg=errmsg)
1559  if (istat /= 0) then
1560  call allocate_error(name, mem_path, istat, isize)
1561  end if
1562  do i = 1, ishape(2)
1563  do j = 1, ishape(1)
1564  adbl(j, i) = mt%adbl2d(j, i)
1565  end do
1566  end do
1567  !
1568  ! -- deallocate mt pointer, repoint, recalculate isize
1569  deallocate (mt%adbl2d)
1570  mt%adbl2d => adbl
1571  mt%element_size = dp
1572  mt%isize = isize
1573  mt%nrealloc = mt%nrealloc + 1
1574  mt%master = .true.
1575  nvalues_adbl = nvalues_adbl + isize - isizeold
1576  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 1402 of file MemoryManager.f90.

1403  integer(I4B), dimension(:), pointer, contiguous, intent(inout) :: aint !< the reallocated integer array
1404  integer(I4B), intent(in) :: nrow !< number of rows
1405  character(len=*), intent(in) :: name !< variable name
1406  character(len=*), intent(in) :: mem_path !< path where variable is stored
1407  ! -- local
1408  type(MemoryType), pointer :: mt
1409  logical(LGP) :: found
1410  integer(I4B) :: istat
1411  integer(I4B) :: isize
1412  integer(I4B) :: i
1413  integer(I4B) :: isizeold
1414  integer(I4B) :: ifill
1415  ! -- code
1416  !
1417  ! -- Find and assign mt
1418  call get_from_memorystore(name, mem_path, mt, found)
1419  !
1420  ! -- Allocate aint and then refill
1421  isize = nrow
1422  isizeold = size(mt%aint1d)
1423  ifill = min(isizeold, isize)
1424  allocate (aint(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, ifill
1429  aint(i) = mt%aint1d(i)
1430  end do
1431  !
1432  ! -- deallocate mt pointer, repoint, recalculate isize
1433  deallocate (mt%aint1d)
1434  mt%aint1d => aint
1435  mt%element_size = i4b
1436  mt%isize = isize
1437  mt%nrealloc = mt%nrealloc + 1
1438  mt%master = .true.
1439  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 1444 of file MemoryManager.f90.

1445  integer(I4B), dimension(:, :), pointer, contiguous, intent(inout) :: aint !< the reallocated 2d integer array
1446  integer(I4B), intent(in) :: ncol !< number of columns
1447  integer(I4B), intent(in) :: nrow !< number of rows
1448  character(len=*), intent(in) :: name !< variable name
1449  character(len=*), intent(in) :: mem_path !< path where variable is stored
1450  ! -- local
1451  type(MemoryType), pointer :: mt
1452  logical(LGP) :: found
1453  integer(I4B) :: istat
1454  integer(I4B), dimension(2) :: ishape
1455  integer(I4B) :: i
1456  integer(I4B) :: j
1457  integer(I4B) :: isize
1458  integer(I4B) :: isizeold
1459  ! -- code
1460  !
1461  ! -- Find and assign mt
1462  call get_from_memorystore(name, mem_path, mt, found)
1463  !
1464  ! -- Allocate aint and then refill
1465  ishape = shape(mt%aint2d)
1466  isize = nrow * ncol
1467  isizeold = ishape(1) * ishape(2)
1468  allocate (aint(ncol, nrow), stat=istat, errmsg=errmsg)
1469  if (istat /= 0) then
1470  call allocate_error(name, mem_path, istat, isize)
1471  end if
1472  do i = 1, ishape(2)
1473  do j = 1, ishape(1)
1474  aint(j, i) = mt%aint2d(j, i)
1475  end do
1476  end do
1477  !
1478  ! -- deallocate mt pointer, repoint, recalculate isize
1479  deallocate (mt%aint2d)
1480  mt%aint2d => aint
1481  mt%element_size = i4b
1482  mt%isize = isize
1483  mt%nrealloc = mt%nrealloc + 1
1484  mt%master = .true.
1485  nvalues_aint = nvalues_aint + isize - isizeold
1486  write (mt%memtype, "(a,' (',i0,',',i0,')')") 'INTEGER', ncol, nrow
Here is the call graph for this function:

◆ reallocate_logical1d()

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

Definition at line 1360 of file MemoryManager.f90.

1361  logical(LGP), dimension(:), pointer, contiguous, intent(inout) :: alog !< the reallocated logical array
1362  integer(I4B), intent(in) :: nrow !< number of rows
1363  character(len=*), intent(in) :: name !< variable name
1364  character(len=*), intent(in) :: mem_path !< path where variable is stored
1365  ! -- local
1366  type(MemoryType), pointer :: mt
1367  logical(LGP) :: found
1368  integer(I4B) :: istat
1369  integer(I4B) :: isize
1370  integer(I4B) :: i
1371  integer(I4B) :: isizeold
1372  integer(I4B) :: ifill
1373  ! -- code
1374  !
1375  ! -- Find and assign mt
1376  call get_from_memorystore(name, mem_path, mt, found)
1377  !
1378  ! -- Allocate aint and then refill
1379  isize = nrow
1380  isizeold = size(mt%alogical1d)
1381  ifill = min(isizeold, isize)
1382  allocate (alog(nrow), stat=istat, errmsg=errmsg)
1383  if (istat /= 0) then
1384  call allocate_error(name, mem_path, istat, isize)
1385  end if
1386  do i = 1, ifill
1387  alog(i) = mt%alogical1d(i)
1388  end do
1389  !
1390  ! -- deallocate mt pointer, repoint, recalculate isize
1391  deallocate (mt%alogical1d)
1392  mt%alogical1d => alog
1393  mt%element_size = lgp
1394  mt%isize = isize
1395  mt%nrealloc = mt%nrealloc + 1
1396  mt%master = .true.
1397  nvalues_alogical = nvalues_alogical + isize - isizeold
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 1189 of file MemoryManager.f90.

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

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