MODFLOW 6  version 6.7.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  call acharstr1d(n)%destroy()
1227  end do
1228  !
1229  ! -- fill new values with missing values
1230  do n = nrow_old + 1, nrow
1231  astrtemp(n) = string
1232  end do
1233  !
1234  ! -- deallocate mt pointer, repoint, recalculate isize
1235  deallocate (acharstr1d)
1236  !
1237  ! -- allocate astr1d
1238  allocate (acharstr1d(nrow), stat=istat, errmsg=errmsg)
1239  if (istat /= 0) then
1240  call allocate_error(name, mem_path, istat, isize)
1241  end if
1242  !
1243  ! -- fill the reallocated character array
1244  do n = 1, nrow
1245  acharstr1d(n) = astrtemp(n)
1246  call astrtemp(n)%destroy()
1247  end do
1248  !
1249  ! -- deallocate temporary storage
1250  deallocate (astrtemp)
1251  !
1252  ! -- reset memory manager values
1253  mt%acharstr1d => acharstr1d
1254  mt%element_size = ilen
1255  mt%isize = isize
1256  mt%nrealloc = mt%nrealloc + 1
1257  mt%master = .true.
1258  nvalues_astr = nvalues_astr + isize - isize_old
1259  write (mt%memtype, "(a,' LEN=',i0,' (',i0,')')") 'STRING', ilen, nrow
1260  else
1261  errmsg = "Programming error, variable '"//trim(name)//"' from '"// &
1262  trim(mem_path)//"' is not defined in the memory manager. Use "// &
1263  "mem_allocate instead."
1264  call store_error(errmsg, terminate=.true.)
1265  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 1359 of file MemoryManager.f90.

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

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

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

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