Skip to content

Commit

Permalink
docs(model): fix docstrings for base model/pkg types (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli authored Dec 11, 2023
1 parent 5b12e3d commit 63001c6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 173 deletions.
120 changes: 19 additions & 101 deletions src/Model/BaseModel.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
!Highest level model class. All models inherit from this parent class.

module BaseModelModule

use KindModule, only: DP, I4B
Expand All @@ -11,9 +9,9 @@ module BaseModelModule
public :: BaseModelType, CastAsBaseModelClass, AddBaseModelToList, &
GetBaseModelFromList

!> @brief Highest level model type. All models extend this parent type.
type :: BaseModelType
character(len=LENMEMPATH) :: memoryPath !< the location in the memory manager where the variables are stored

character(len=LENMODELNAME), pointer :: name => null() !< name of the model
character(len=3), pointer :: macronym => null() !< 3 letter model acronym (GWF, GWT, ...)
integer(I4B), pointer :: idsoln => null() !< id of the solution model is in
Expand All @@ -37,90 +35,45 @@ module BaseModelModule

contains

!> @brief Define the model
!<
subroutine model_df(this)
! ******************************************************************************
! modeldf -- Define the model
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_df

!> @brief Allocate and read
!<
subroutine model_ar(this)
! ******************************************************************************
! modelar -- Allocate and read
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_ar

!> @brief Read and prepare
!<
subroutine model_rp(this)
! ******************************************************************************
! model_rp -- Read and prepare
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_rp

!> @brief Calculate time step length
!<
subroutine model_calculate_delt(this)
! ******************************************************************************
! model_calculate_delt -- Calculate time step length
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_calculate_delt

!> @brief Output results
!<
subroutine model_ot(this)
! ******************************************************************************
! model_ot -- output results
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_ot

!> @brief Write line to model iout
!<
subroutine model_message(this, line, fmt)
! ******************************************************************************
! model_message -- write line to model iout
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- dummy
class(BaseModelType) :: this
character(len=*), intent(in) :: line
character(len=*), intent(in), optional :: fmt
! -- local
character(len=LINELENGTH) :: cfmt
! ------------------------------------------------------------------------------
!
! -- process optional variables
if (present(fmt)) then
Expand All @@ -131,38 +84,22 @@ subroutine model_message(this, line, fmt)
!
! -- write line
write (this%iout, trim(cfmt)) trim(line)
!
! -- return
return
end subroutine model_message

!> @brief Final processing
!<
subroutine model_fp(this)
! ******************************************************************************
! model_fp -- Final processing
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- return
return
end subroutine model_fp

!> @brief Allocate scalar variables
!<
subroutine allocate_scalars(this, modelname)
! ******************************************************************************
! allocate_scalars
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use MemoryManagerModule, only: mem_allocate
! -- dummy
class(BaseModelType) :: this
character(len=*), intent(in) :: modelname
! ------------------------------------------------------------------------------
!
call mem_allocate(this%name, LENMODELNAME, 'NAME', this%memoryPath)
call mem_allocate(this%macronym, 3, 'MACRONYM', this%memoryPath)
Expand All @@ -183,23 +120,15 @@ subroutine allocate_scalars(this, modelname)
this%iprflow = 0
this%ipakcb = 0
this%inewton = 0 !default is standard formulation
!
! -- return
return
end subroutine allocate_scalars

!> @brief Deallocate
!<
subroutine model_da(this)
! ******************************************************************************
! deallocate
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use MemoryManagerModule, only: mem_deallocate
! -- dummy
class(BaseModelType) :: this
! ------------------------------------------------------------------------------
!
! -- Strings
call mem_deallocate(this%name, 'NAME', this%memoryPath)
Expand All @@ -213,13 +142,9 @@ subroutine model_da(this)
call mem_deallocate(this%iprflow)
call mem_deallocate(this%ipakcb)
call mem_deallocate(this%idsoln)
!
! -- return
return
end subroutine model_da

function CastAsBaseModelClass(obj) result(res)
implicit none
class(*), pointer, intent(inout) :: obj
class(BaseModelType), pointer :: res
!
Expand All @@ -230,11 +155,9 @@ function CastAsBaseModelClass(obj) result(res)
class is (BaseModelType)
res => obj
end select
return
end function CastAsBaseModelClass

subroutine AddBaseModelToList(list, model)
implicit none
! -- dummy
type(ListType), intent(inout) :: list
class(BaseModelType), pointer, intent(inout) :: model
Expand All @@ -243,12 +166,9 @@ subroutine AddBaseModelToList(list, model)
!
obj => model
call list%Add(obj)
!
return
end subroutine AddBaseModelToList

function GetBaseModelFromList(list, idx) result(res)
implicit none
! -- dummy
type(ListType), intent(inout) :: list
integer(I4B), intent(in) :: idx
Expand All @@ -258,8 +178,6 @@ function GetBaseModelFromList(list, idx) result(res)
!
obj => list%GetItem(idx)
res => CastAsBaseModelClass(obj)
!
return
end function GetBaseModelFromList

end module BaseModelModule
38 changes: 1 addition & 37 deletions src/Model/ExplicitModel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ module ExplicitModelModule
AddExplicitModelToList, &
GetExplicitModelFromList

!> @brief Derived type for the Explicit Model Type
!!
!! This derived type describes a parent class for explicit
!! models.
!!
!<
!> @brief Base type for explicit models.
type, extends(BaseModelType) :: ExplicitModelType
type(ListType), pointer :: bndlist => null() !< array of boundary packages for this model
class(DisBaseType), pointer :: dis => null() !< discretization object
Expand All @@ -45,18 +40,12 @@ module ExplicitModelModule
!<
subroutine model_ad(this)
class(ExplicitModelType) :: this
!
! -- return
return
end subroutine model_ad

!> @ brief Solve the model
!<
subroutine model_solve(this)
class(ExplicitModelType) :: this
!
! -- return
return
end subroutine model_solve

!> @ brief Calculate model flows
Expand All @@ -65,9 +54,6 @@ subroutine model_cq(this, icnvg, isuppress_output)
class(ExplicitModelType) :: this
integer(I4B), intent(in) :: icnvg
integer(I4B), intent(in) :: isuppress_output
!
! -- return
return
end subroutine model_cq

!> @ brief Calculate model budget
Expand All @@ -76,9 +62,6 @@ subroutine model_bd(this, icnvg, isuppress_output)
class(ExplicitModelType) :: this
integer(I4B), intent(in) :: icnvg
integer(I4B), intent(in) :: isuppress_output
!
! -- return
return
end subroutine model_bd

!> @ brief Deallocate the model
Expand All @@ -87,22 +70,13 @@ subroutine model_da(this)
! -- modules
use MemoryManagerModule, only: mem_deallocate
class(ExplicitModelType) :: this

! -- Scalars
!
! -- Arrays
!
! -- derived types
call this%bndlist%Clear()
deallocate (this%bndlist)
!
! -- nullify pointers
!
! -- BaseModelType
call this%BaseModelType%model_da()
!
! -- Return
return
end subroutine model_da

!> @ brief Allocate model scalar variables
Expand All @@ -117,11 +91,6 @@ subroutine allocate_scalars(this, modelname)
!
! -- allocate members from this type
allocate (this%bndlist)
!
! -- initialize
!
! -- return
return
end subroutine allocate_scalars

!> @ brief Cast a generic object into an explicit model
Expand All @@ -137,7 +106,6 @@ function CastAsExplicitModelClass(obj) result(res)
class is (ExplicitModelType)
res => obj
end select
return
end function CastAsExplicitModelClass

!> @ brief Add explicit model to a generic list
Expand All @@ -151,8 +119,6 @@ subroutine AddExplicitModelToList(list, model)
!
obj => model
call list%Add(obj)
!
return
end subroutine AddExplicitModelToList

!> @ brief Get generic object from list and return as explicit model
Expand All @@ -167,8 +133,6 @@ function GetExplicitModelFromList(list, idx) result(res)
!
obj => list%GetItem(idx)
res => CastAsExplicitModelClass(obj)
!
return
end function GetExplicitModelFromList

end module ExplicitModelModule
Loading

0 comments on commit 63001c6

Please sign in to comment.