Module dc_units

module dc_units

        ! Uses
    use dc_types, only: DP, TOKEN, STRING

        ! Types
    public type UNITS

        ! Interfaces
    public interface clear
    public interface deallocate
    public interface assignment(=)
    public interface operator(*)
    public interface operator(/)
    public interface operator(+)

        ! Subroutines and functions
    private subroutine units_simplify (u, name, power)
    private type (UNITS) function dcUnitsMul (u1, u2)
    private type (UNITS) function dcUnitsDiv (u1, u2)
    private type (UNITS) function dcUnitsAdd (u1, u2)
    public logical function add_okay (u1, u2)
    private subroutine dcunitsclear (u)
    private subroutine dcunitsdeallocate (u)
    private subroutine dcunitstostring (string, u)
    private subroutine dcunitsbuild (u, cunits)

end module dc_units

Description of Types

UNITS

public type UNITS
    real (kind=DP) :: factor
    integer :: nelems
    character (len=TOKEN), pointer, dimension (:) :: name
    character (len=TOKEN) :: offset
    real (kind=DP), pointer, dimension (:) :: power
end type UNITS

Description of Interfaces

clear

public interface clear
    module procedure dcunitsclear
end interface clear

deallocate

public interface deallocate
    module procedure dcunitsdeallocate
end interface deallocate

assignment(=)

public interface assignment(=)
    module procedure dcunitsbuild
    module procedure dcunitstostring
end interface assignment(=)

operator(*)

public interface operator(*)
    module procedure dcunitsmul
end interface operator(*)

operator(/)

public interface operator(/)
    module procedure dcunitsdiv
end interface operator(/)

operator(+)

public interface operator(+)
    module procedure dcunitsadd
end interface operator(+)

Description of Subroutines and Functions

units_simplify

private subroutine units_simplify (u, name, power)
    type (UNITS), intent(inout) :: u
    character (len=TOKEN), intent(in), dimension (u%nelems) :: name
    real (kind=DP), intent(in), dimension (u%nelems) :: power
end subroutine units_simplify

dcUnitsMul

private function dcUnitsMul (u1, u2) result (result)
    type (UNITS), intent(in) :: u1
    type (UNITS), intent(in) :: u2
    type (UNITS) :: result
    ! Calls: units_simplify
end function dcUnitsMul

dcUnitsDiv

private function dcUnitsDiv (u1, u2) result (result)
    type (UNITS), intent(in) :: u1
    type (UNITS), intent(in) :: u2
    type (UNITS) :: result
    ! Calls: units_simplify
end function dcUnitsDiv

dcUnitsAdd

private function dcUnitsAdd (u1, u2) result (result)
    type (UNITS), intent(in) :: u1
    type (UNITS), intent(in) :: u2
    type (UNITS) :: result
end function dcUnitsAdd

add_okay

public function add_okay (u1, u2) result (result)
    type (UNITS), intent(in) :: u1
    type (UNITS), intent(in) :: u2
    logical :: result
    ! Calls: clear, deallocate
end function add_okay

dcunitsclear

private subroutine dcunitsclear (u)
    type (UNITS), intent(inout) :: u
end subroutine dcunitsclear

dcunitsdeallocate

private subroutine dcunitsdeallocate (u)
    type (UNITS), intent(inout) :: u
end subroutine dcunitsdeallocate

dcunitstostring

private subroutine dcunitstostring (string, u)
    character (len=*), intent(out) :: string
    type (UNITS), intent(in) :: u
end subroutine dcunitstostring

dcunitsbuild

private subroutine dcunitsbuild (u, cunits)
    type (UNITS), intent(out) :: u
    character (len=STRING), intent(in) :: cunits
    ! Calls: cancel_exp, dcunitsgettoken, dcunitssetline, error, factor_next, power_next, pstack_clear, pstack_pop, pstack_push, units_finalize, units_simplify, ustack_clear, ustack_grow
end subroutine dcunitsbuild