maxdist.h90 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. !!----------------------------------------------------------------------
  2. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  3. !! $Id: maxdist.h90 2287 2010-10-18 07:53:52Z smasson $
  4. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  5. !!----------------------------------------------------------------------
  6. REAL FUNCTION maxdist( pxv, pyv )
  7. !!----------------------------------------------------------------------
  8. !! *** FUNCTION maxdist ***
  9. !!
  10. !! ** Purpose : Compute the maximum distance between any points within
  11. !! a cell
  12. !!
  13. !! ** Method : Call to grt_cir_dis
  14. !!
  15. !! ** Action :
  16. !!
  17. !! History :
  18. !! ! 2006-08 (K. Mogensen)
  19. !! ! 2006-10 (A. Weaver) Cleanup
  20. !!----------------------------------------------------------------------
  21. !! * Arguments
  22. REAL(KIND=wp), DIMENSION(4), INTENT(IN) :: &
  23. & pxv, & ! (lon, lat) of the surrounding cell
  24. & pyv
  25. !! * Local declarations
  26. REAL(KIND=wp), DIMENSION(4) :: &
  27. & zxv, &
  28. & zyv, &
  29. & za, &
  30. & zb, &
  31. & zc
  32. REAL(KIND=wp) :: zdist
  33. INTEGER :: ji
  34. INTEGER :: jj
  35. !-----------------------------------------------------------------------
  36. ! Convert data to radians
  37. !-----------------------------------------------------------------------
  38. DO ji = 1, 4
  39. zxv(ji) = pxv(ji) * rad
  40. zyv(ji) = pyv(ji) * rad
  41. END DO
  42. !-----------------------------------------------------------------------
  43. ! Prepare input to grt_cir_dis
  44. !-----------------------------------------------------------------------
  45. DO ji = 1, 4
  46. za(ji) = SIN( zyv(ji) )
  47. zb(ji) = COS( zyv(ji) ) * COS( zxv(ji) )
  48. zc(ji) = COS( zyv(ji) ) * SIN( zxv(ji) )
  49. END DO
  50. !-----------------------------------------------------------------------
  51. ! Get max distance between any points in the area
  52. !-----------------------------------------------------------------------
  53. maxdist = 0.0
  54. DO jj = 1, 4
  55. DO ji = jj+1, 4
  56. zdist = grt_cir_dis( za(jj), za(ji), zb(jj), &
  57. & zb(ji), zc(jj), zc(ji))
  58. IF ( zdist > maxdist ) THEN
  59. maxdist = zdist
  60. ENDIF
  61. END DO
  62. END DO
  63. !-----------------------------------------------------------------------
  64. ! Convert to degrees.
  65. !-----------------------------------------------------------------------
  66. maxdist = maxdist / rad
  67. END FUNCTION maxdist