MODFLOW 6  version 6.7.0.dev1
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 1180 of file MemoryManager.f90.

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

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

1402  real(DP), dimension(:, :), pointer, contiguous, intent(inout) :: adbl !< the reallocated 2d real array
1403  integer(I4B), intent(in) :: ncol !< number of columns
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), dimension(2) :: ishape
1412  integer(I4B) :: i
1413  integer(I4B) :: j
1414  integer(I4B) :: isize
1415  integer(I4B) :: isizeold
1416  ! -- code
1417  !
1418  ! -- Find and assign mt
1419  call get_from_memorystore(name, mem_path, mt, found)
1420  !
1421  ! -- Allocate adbl and then refill
1422  ishape = shape(mt%adbl2d)
1423  isize = nrow * ncol
1424  isizeold = ishape(1) * ishape(2)
1425  allocate (adbl(ncol, 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, ishape(2)
1430  do j = 1, ishape(1)
1431  adbl(j, i) = mt%adbl2d(j, i)
1432  end do
1433  end do
1434  !
1435  ! -- deallocate mt pointer, repoint, recalculate isize
1436  deallocate (mt%adbl2d)
1437  mt%adbl2d => adbl
1438  mt%element_size = dp
1439  mt%isize = isize
1440  mt%nrealloc = mt%nrealloc + 1
1441  mt%master = .true.
1442  nvalues_adbl = nvalues_adbl + isize - isizeold
1443  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 1269 of file MemoryManager.f90.

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

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

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

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