mod_angles.F90 613 B

12345678910111213141516171819202122232425262728293031
  1. ! Subprograms for the conversion of angles.
  2. module mod_angles
  3. contains
  4. function ang360(ang)
  5. ! Maps arbitrary angle to [0, 360) degrees.
  6. real ang360
  7. real, intent(in) :: ang
  8. ang360 = mod(ang, 360.0) - (sign(1.0,ang)-1.0)*180.0
  9. end function ang360
  10. function ang180(ang)
  11. ! Maps arbitrary angle to [-180, 180) degrees.
  12. ! Use this whenever two angles are subtracted.
  13. ! Requires ang360.
  14. real ang180
  15. real, intent(in) :: ang
  16. ang180 = ang360(ang)
  17. ang180 = ang180 - 180.0*(sign(1.0,ang180-180.0)+1.0)
  18. end function ang180
  19. end module mod_angles