m_pivotp.f90 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # 0 "<stdin>"
  2. # 0 "<built-in>"
  3. # 0 "<command-line>"
  4. # 1 "/usr/include/stdc-predef.h" 1 3 4
  5. # 17 "/usr/include/stdc-predef.h" 3 4
  6. # 2 "<command-line>" 2
  7. # 1 "<stdin>"
  8. # 10 "<stdin>"
  9. module m_pivotp
  10. use m_confmap
  11. implicit none
  12. contains
  13. ! This subroutine computes the pivot point of each of the observations
  14. ! in the temporary array tmpobs of type observation. The pivot point
  15. ! is the biggest i and the biggest j, (i,j) is the computation points/
  16. ! the grid, that is less than the position of the observation.
  17. !
  18. subroutine pivotp(lon, lat, ipiv, jpiv)
  19. real, intent(in) :: lon, lat
  20. integer, intent(out) :: ipiv, jpiv
  21. real :: tmptan
  22. real :: lontmp
  23. if (.not. confmap_initialised) then
  24. print *, 'ERROR: oldtonew(): confmap not initialised'
  25. stop
  26. end if
  27. ! fix for wrap-around
  28. ! Knut: For some exotic grids the wrap-around
  29. ! is not needed. By exotic grid I mean Conman,
  30. ! where the poles are on the other side of the earth,
  31. ! and the eastern limit is actually WEST of the western
  32. ! limit.... (di < 0)
  33. !if (lon < wlim) then
  34. if (lon < wlim .and. di > 0. ) then
  35. lontmp = lon + 360.0
  36. else
  37. lontmp = lon
  38. endif
  39. ipiv = int((lontmp - wlim) / di) + 1
  40. if (mercator) then
  41. if (abs(lat) < 89.999) then
  42. tmptan = tan(0.5 * rad * lat + 0.25 * pi_1)
  43. jpiv = int((log(tmptan) - slim * rad) / (rad * dj)) + 1
  44. else
  45. jpiv= - 999
  46. endif
  47. else
  48. jpiv = int((lat - slim) / dj) + 1
  49. endif
  50. end subroutine pivotp
  51. end module m_pivotp