! ! File: barrier_def.f95 ! Author: josephalevin ! ! Created on August 1, 2011, 3:19 PM ! module barrier_def implicit none private public :: Barrier public :: barrier_new public :: barrier_destroy public :: barrier_print type Barrier real :: x, y, height, width, porosity character(len=100) :: name end type contains !barrier constructor function barrier_new() type(barrier), pointer :: barrier_new !allocate the memory allocate (barrier_new) !init the variables barrier_new%x = 0 barrier_new%y = 0 barrier_new%height = 0 barrier_new%width = 0 barrier_new%porosity = 0 barrier_new%name = "" end function !barrier destruction subroutine barrier_destroy(mp) type(barrier), pointer :: mp if (.not.associated(mp)) return !TODO: handle variables ? deallocate (mp) end subroutine !debug subroutine prints the contents of the barrier subroutine barrier_print(mp, depth) use model_util type(barrier), pointer, intent(in) :: mp integer, intent(in), optional :: depth integer :: d = 0, i !just quit if there is no barrier if (.not.associated(mp)) then call modelPrint(unit=6, depth=d, root=.true., name="BARRIER (NULL)") return end if if(present(depth)) then d = depth end if call modelPrint(unit=6, depth=d, root=.true., name="BARRIER") call modelPrint(unit=6, depth=d, name="name", value=mp%name) call modelPrint(unit=6, depth=d, name="x", value=mp%x) call modelPrint(unit=6, depth=d, name="y", value=mp%y) call modelPrint(unit=6, depth=d, name="height", value=mp%height) call modelPrint(unit=6, depth=d, name="width", value=mp%width) call modelPrint(unit=6, depth=d, name="porosity", value=mp%porosity) end subroutine end module !generic trick by using an include file module barrierlist_def use barrier_def, LIST_DATA => Barrier implicit none include "util/list.inc" end module