MODFLOW 6
version 6.8.0.dev0
USGS Modular Hydrologic Model
Main Page
Modules
Data Types List
Files
File List
File Members
ScratchFileBuffer.f90
Go to the documentation of this file.
1
!> @brief Scratch-file particle event buffer module.
2
!<
3
module
scratchfilebuffermodule
4
5
use
kindmodule
,
only
: i4b
6
use
errorutilmodule
,
only
:
pstop
7
use
particletrackeventbuffermodule
,
only
:
particletrackeventbuffertype
, &
8
particletrackrecordtype
, &
9
particletrackfiletype
, &
10
save_record
11
12
implicit none
13
private
14
public
::
scratchfilebuffertype
15
16
!> @brief Scratch-file particle event buffer. Records are written to
17
!! an unformatted sequential scratch file that is rewound on discard
18
!! and read back sequentially on flush.
19
type
,
extends
(
particletrackeventbuffertype
) ::
scratchfilebuffertype
20
integer(I4B)
:: iun = 0
!< scratch file unit
21
contains
22
procedure
::
init
=>
scratch_init
23
procedure
:: append =>
scratch_append
24
procedure
:: flush =>
scratch_flush
25
procedure
:: discard =>
scratch_discard
26
procedure
:: destroy =>
scratch_destroy
27
end type
scratchfilebuffertype
28
29
contains
30
31
subroutine
scratch_init
(this)
32
class
(
scratchfilebuffertype
) :: this
33
integer(I4B)
:: istat
34
open
(newunit=this%iun, status=
'scratch'
, form=
'unformatted'
, &
35
access=
'sequential'
, iostat=istat)
36
if
(istat /= 0) &
37
call
pstop
(1,
'failed to open scratch track buffer file'
)
38
end subroutine
scratch_init
39
40
subroutine
scratch_append
(this, rec)
41
class
(
scratchfilebuffertype
) :: this
42
type
(
particletrackrecordtype
),
intent(in)
:: rec
43
write
(this%iun) rec
44
this%nrecords = this%nrecords + 1
45
end subroutine
scratch_append
46
47
subroutine
scratch_flush
(this, files)
48
class
(
scratchfilebuffertype
) :: this
49
type
(
particletrackfiletype
),
intent(in)
:: files(:)
50
integer(I4B)
:: n, i
51
type
(
particletrackrecordtype
) :: rec
52
53
rewind(this%iun)
54
do
n = 1, this%nrecords
55
read
(this%iun) rec
56
do
i = 1,
size
(files)
57
if
(files(i)%iun > 0 .and. &
58
(files(i)%iprp == -1 .or. files(i)%iprp == rec%iprp)) &
59
call
save_record
(files(i)%iun, rec, files(i)%csv)
60
end do
61
end do
62
rewind(this%iun)
63
this%nrecords = 0
64
end subroutine
scratch_flush
65
66
subroutine
scratch_discard
(this)
67
class
(
scratchfilebuffertype
) :: this
68
rewind(this%iun)
69
this%nrecords = 0
70
end subroutine
scratch_discard
71
72
subroutine
scratch_destroy
(this)
73
class
(
scratchfilebuffertype
) :: this
74
if
(this%iun > 0)
then
75
close
(this%iun)
76
this%iun = 0
77
end if
78
this%nrecords = 0
79
end subroutine
scratch_destroy
80
81
end module
scratchfilebuffermodule
init
subroutine init()
Definition:
GridSorting.f90:25
errorutilmodule
Definition:
ErrorUtil.f90:1
errorutilmodule::pstop
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
Definition:
ErrorUtil.f90:24
kindmodule
This module defines variable data types.
Definition:
kind.f90:8
particletrackeventbuffermodule
Particle event buffering strategies.
Definition:
ParticleTrackEventBuffer.f90:2
particletrackeventbuffermodule::save_record
subroutine save_record(iun, rec, csv)
Save an event record to a binary or CSV file.
Definition:
ParticleTrackEventBuffer.f90:68
scratchfilebuffermodule
Scratch-file particle event buffer module.
Definition:
ScratchFileBuffer.f90:3
scratchfilebuffermodule::scratch_destroy
subroutine scratch_destroy(this)
Definition:
ScratchFileBuffer.f90:73
scratchfilebuffermodule::scratch_append
subroutine scratch_append(this, rec)
Definition:
ScratchFileBuffer.f90:41
scratchfilebuffermodule::scratch_discard
subroutine scratch_discard(this)
Definition:
ScratchFileBuffer.f90:67
scratchfilebuffermodule::scratch_init
subroutine scratch_init(this)
Definition:
ScratchFileBuffer.f90:32
scratchfilebuffermodule::scratch_flush
subroutine scratch_flush(this, files)
Definition:
ScratchFileBuffer.f90:48
particletrackeventbuffermodule::particletrackeventbuffertype
Event buffering strategy.
Definition:
ParticleTrackEventBuffer.f90:30
particletrackeventbuffermodule::particletrackfiletype
Output file containing all or some particle pathlines.
Definition:
ParticleTrackEventBuffer.f90:22
particletrackeventbuffermodule::particletrackrecordtype
Flat record of a particle track event.
Definition:
ParticleTrackEventBuffer.f90:10
scratchfilebuffermodule::scratchfilebuffertype
Scratch-file particle event buffer. Records are written to an unformatted sequential scratch file tha...
Definition:
ScratchFileBuffer.f90:19
src
Solution
ParticleTracker
Particle
ScratchFileBuffer.f90
Generated on Fri Jun 26 2026 11:14:26 for MODFLOW 6 by
1.9.1