Scientific Programming / 2015 / Article / Lst 6

Research Article

High-Performance Design Patterns for Modern Fortran

Listing 6

pure function add(lhs, rhs) result(total)
class(local_tensor), intent(in):: lhs, rhs
type(local_tensor):: total
 total%f = 1hs%f + rhs%f
end function
pure subroutine assign_local(lhs, rhs)
class(local_tensor), intent(inout):: lhs
real, intent(in):: rhs(:)
 lhs%f = rhs
end subroutine
pure function state(this) result(my_data)
class(local_tensor), intent(in):: this
real:: my_data(local_grid_size)
 my_data = this%f
end function
pure function subtract(lhs, rhs) &
class(local_tensor), intent(in):: lhs, rhs
type(local_tensor):: difference
 difference%f = 1hs%f − rhs%f
end function

We are committed to sharing findings related to COVID-19 as quickly as possible. We will be providing unlimited waivers of publication charges for accepted research articles as well as case reports and case series related to COVID-19. Review articles are excluded from this waiver policy. Sign up here as a reviewer to help fast-track new submissions.