Research Article

High-Performance Design Patterns for Modern Fortran

Listing 13

pure function add(lhs, rhs) result(total)
class(local_tensor), intent(in):: lhs, rhs
type(local_tensor):: total
! Requires
if (lhs%user_defined() .and. &
  rhs%user_defined()) then
total%f = lhs%f + rhs%f
 ! Ensures
call total%mark_as_defined
 end if
end function