m_uobs.F90 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ! File: m_uobs.F90
  2. !
  3. ! Created: 11 August 2010
  4. !
  5. ! Last modified: 11.8.2010
  6. !
  7. ! Author: Pavel Sakov
  8. ! NERSC
  9. !
  10. ! Purpose: Handle different observation types.
  11. !
  12. ! Description: This module is in charge of sorting of observations by types
  13. ! and storing the results
  14. !
  15. ! Modifications: None
  16. module m_uobs
  17. #if defined (QMPI)
  18. use qmpi
  19. #else
  20. use qmpi_fake
  21. #endif
  22. use mod_measurement
  23. implicit none
  24. public uobs_get
  25. integer, parameter, private :: MAXNUOBS = 1900
  26. integer, public :: nuobs
  27. character(OBSTYPESTRLEN), public :: unique_obs(MAXNUOBS)
  28. integer, public :: nobseach(MAXNUOBS)
  29. integer :: uobs_begin(MAXNUOBS), uobs_end(MAXNUOBS)
  30. contains
  31. subroutine uobs_get(tags, nrobs, master)
  32. implicit none
  33. integer , intent(in) :: nrobs
  34. logical , intent(in) :: master
  35. character(OBSTYPESTRLEN), intent(in) :: tags(nrobs)
  36. logical :: obsmatch
  37. integer :: o, uo
  38. nobseach = 0
  39. ! check for unique obs
  40. if (master) then
  41. print '(a)', ' EnKF: getting unique observations '
  42. end if
  43. nuobs = 0
  44. unique_obs = ''
  45. do o = 1, nrobs
  46. !PRINT *, o
  47. !PRINT *, '...', nuobs
  48. obsmatch = .false.
  49. do uo = 1, nuobs
  50. !PRINT *, '-->', uo
  51. if (trim(tags(o)) == trim(unique_obs(uo))) then
  52. obsmatch = .true.
  53. nobseach(uo) = nobseach(uo) + 1
  54. exit
  55. end if
  56. end do
  57. if (.not. obsmatch) then
  58. nuobs = nuobs + 1
  59. nobseach(nuobs) = 1
  60. if (nuobs > MAXNUOBS) then
  61. if (master) then
  62. print *, 'ERROR: uobs_get(): # of unique obs = ', nuobs,&
  63. ' > MAXNUOBS = ', MAXNUOBS
  64. print *, ' obs # = ', o, ', tag = ', trim(tags(o))
  65. end if
  66. stop
  67. end if
  68. unique_obs(nuobs) = trim(tags(o))
  69. end if
  70. end do
  71. if (master) then
  72. do uo = 1, nuobs
  73. print '(a, i2, a, a, a, i7, a)', ' obs variable ', uo, ' -- ',&
  74. trim(unique_obs(uo)), ',', nobseach(uo), ' observations'
  75. end do
  76. end if
  77. uobs_begin(1) = 1
  78. uobs_end(1) = nobseach(1)
  79. do uo = 2, nuobs
  80. uobs_begin(uo) = uobs_end(uo - 1) + 1
  81. uobs_end(uo) = uobs_begin(uo) + nobseach(uo) - 1
  82. end do
  83. if (master) then
  84. do uo = 1, nuobs
  85. do o = uobs_begin(uo), uobs_end(uo)
  86. if (trim(tags(o)) /= trim(unique_obs(uo))) then
  87. print *, trim(tags(o))
  88. print *, trim(unique_obs(uo))
  89. print *, 'ERROR: uobs_get(): uinique observations not ',&
  90. 'continuous in observation array'
  91. stop
  92. end if
  93. end do
  94. end do
  95. end if
  96. if (master) then
  97. print *
  98. end if
  99. end subroutine uobs_get
  100. end module m_uobs