Skip to content

Commit

Permalink
more cleanup, convert type-bound proc -> pointer function
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jul 9, 2024
1 parent cb93957 commit 11f3fb4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
31 changes: 16 additions & 15 deletions src/Model/ModelUtilities/ReleaseSchedule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module ReleaseScheduleModule
implicit none
private
public :: ReleaseScheduleType
public :: create_release_schedule

!> @brief Particle release scheduling utility.
!!
Expand All @@ -25,8 +26,9 @@ module ReleaseScheduleModule
!! an infinite supply: an arbitrary number can be released, only
!! one at a time.
!!
!! The release schedule must be reinitialized for each time step.
!! This is achieved by calling advance().
!! The release schedule must be refreshed each time step. This is
!! necessary to advance the time selection and can be achieved by
!! calling advance().
!<
type :: ReleaseScheduleType
real(DP), allocatable :: schedule(:) !< release schedule
Expand All @@ -37,34 +39,33 @@ module ReleaseScheduleModule
procedure :: any
procedure :: count
procedure :: deallocate
procedure :: init
procedure :: log
end type ReleaseScheduleType

contains

!> @brief Create a new release schedule object.
function create_release_schedule() result(sched)
type(ReleaseScheduleType), pointer :: sched !< schedule pointer
allocate (sched)
allocate (sched%schedule(0))
allocate (sched%time_select)
allocate (sched%step_select)
call sched%time_select%init()
call sched%step_select%init()
end function create_release_schedule

!> @brief Deallocate the release schedule.
subroutine deallocate (this)
class(ReleaseScheduleType) :: this !< this instance

deallocate (this%schedule)
call this%time_select%deallocate()
call this%step_select%deallocate()
deallocate (this%time_select)
deallocate (this%step_select)
end subroutine deallocate

!> @brief Initialize the release schedule.
subroutine init(this)
class(ReleaseScheduleType) :: this !< this instance

if (allocated(this%schedule)) deallocate (this%schedule)
allocate (this%schedule(0))
allocate (this%time_select)
allocate (this%step_select)
call this%time_select%init()
call this%step_select%init()
end subroutine init

!> @brief Write the release schedule to the given output unit.
subroutine log(this, iout)
! dummy
Expand Down
2 changes: 0 additions & 2 deletions src/Model/ModelUtilities/TimeStepSelect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ end subroutine log

!> @brief Read a line of input and prepare the selection object.
subroutine read (this, line)
! dummy
class(TimeStepSelectType) :: this !< this instance
character(len=*), intent(in) :: line !< input line
! local

character(len=len(line)) :: l
integer(I4B) :: n, lloc, istart, istop, ival
Expand Down
9 changes: 4 additions & 5 deletions src/Model/ParticleTracking/prt-prp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module PrtPrpModule
use GeomUtilModule, only: point_in_polygon, get_ijk, get_jk
use MemoryManagerModule, only: mem_allocate, mem_deallocate, &
mem_reallocate
use ReleaseScheduleModule, only: ReleaseScheduleType
use ReleaseScheduleModule, only: ReleaseScheduleType, create_release_schedule
use DisModule, only: DisType
use DisvModule, only: DisvType
use ErrorUtilModule, only: pstop
Expand Down Expand Up @@ -225,11 +225,10 @@ end subroutine prp_allocate_arrays
subroutine prp_allocate_scalars(this)
class(PrtPrpType) :: this

! Allocate release time selection
allocate (this%releases)
call this%releases%init()
! Create release schedule
this%releases => create_release_schedule()

! call standard BndType allocate scalars
! Allocate parent's scalars
call this%BndType%allocate_scalars()

! Allocate scalars for this type
Expand Down

0 comments on commit 11f3fb4

Please sign in to comment.