gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dc_units::operator(+) Interface Reference

Public Member Functions

type(units) function dcunitsadd (u1, u2)
 

Detailed Description

Definition at line 107 of file dc_units.f90.

Member Function/Subroutine Documentation

◆ dcunitsadd()

type(units) function dc_units::operator(+)::dcunitsadd ( type(units), intent(in)  u1,
type(units), intent(in)  u2 
)

Add two UNITS (with dimension compatibility check)

Addition is only valid when both units have the same dimensions. If dimensions don't match, resultoffset is set to "MISMATCH".

Parameters
[in]u1First UNITS variable
[in]u2Second UNITS variable
Returns
Sum of two UNITS (or error if incompatible)

Definition at line 265 of file dc_units.f90.

266 type(UNITS), intent(in):: u1, u2
267 type(UNITS):: x
268 result%offset = u1%offset
269 result%nelems = u1%nelems
270 result%factor = u1%factor + u2%factor
271 x = u1 / u2
272 if (x%nelems == 0) then
273 nullify(result%name, result%power)
274 return
275 endif
276 if (all(abs(x%power(1:result%nelems)) < tiny(0.0_dp))) then
277 allocate(result%name(result%nelems), result%power(result%nelems))
278 result%name = u1%name
279 result%power = u1%power
280 return
281 endif
282 result%factor = 0.0
283 result%nelems = -1
284 result%offset = "MISMATCH"
285 nullify(result%name, result%power)

The documentation for this interface was generated from the following file: