m_pivotp.F90 1.3 KB

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