this subroutine breaks a d.p. number into a d.p. integer and a d.p. fractional part.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | tt |
d.p. input number |
||
real(kind=wp), | intent(out), | dimension(2) | :: | fr |
d.p. 2-word output array. fr(1) contains integer part fr(2) contains fractional part for negative input numbers, fr(1) contains the next more negative integer; fr(2) contains a positive fraction. |
subroutine split(tt,fr) implicit none real(wp),intent(in) :: tt !! d.p. input number real(wp),dimension(2),intent(out) :: fr !! d.p. 2-word output array. !! fr(1) contains integer part !! fr(2) contains fractional part !! for negative input numbers, fr(1) contains the next !! more negative integer; fr(2) contains a positive fraction. ! get integer and fractional parts fr(1) = int(tt) fr(2) = tt-fr(1) if (tt>=0.0_wp .or. fr(2)==0.0_wp) return ! make adjustments for negative input number fr(1) = fr(1) - 1.0_wp fr(2) = fr(2) + 1.0_wp end subroutine split