MODFLOW 6  version 6.8.0.dev0
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 82 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 1272 of file MemoryManager.f90.

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

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

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

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

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

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

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

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