m_uobs.F90 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 = 19
  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. obsmatch = .false.
  47. do uo = 1, nuobs
  48. if (trim(tags(o)) == trim(unique_obs(uo))) then
  49. obsmatch = .true.
  50. nobseach(uo) = nobseach(uo) + 1
  51. exit
  52. end if
  53. end do
  54. if (.not. obsmatch) then
  55. nuobs = nuobs + 1
  56. nobseach(nuobs) = 1
  57. if (nuobs > MAXNUOBS) then
  58. if (master) then
  59. print *, 'ERROR: uobs_get(): # of unique obs = ', nuobs,&
  60. ' > MAXNUOBS = ', MAXNUOBS
  61. print *, ' obs # = ', o, ', tag = ', trim(tags(o))
  62. end if
  63. stop
  64. end if
  65. unique_obs(nuobs) = trim(tags(o))
  66. end if
  67. end do
  68. if (master) then
  69. do uo = 1, nuobs
  70. print '(a, i2, a, a, a, i7, a)', ' obs variable ', uo, ' -- ',&
  71. trim(unique_obs(uo)), ',', nobseach(uo), ' observations'
  72. end do
  73. end if
  74. uobs_begin(1) = 1
  75. uobs_end(1) = nobseach(1)
  76. do uo = 2, nuobs
  77. uobs_begin(uo) = uobs_end(uo - 1) + 1
  78. uobs_end(uo) = uobs_begin(uo) + nobseach(uo) - 1
  79. end do
  80. if (master) then
  81. do uo = 1, nuobs
  82. do o = uobs_begin(uo), uobs_end(uo)
  83. if (trim(tags(o)) /= trim(unique_obs(uo))) then
  84. print *, 'ERROR: uobs_get(): uinique observations not ',&
  85. 'continuous in observation array'
  86. stop
  87. end if
  88. end do
  89. end do
  90. end if
  91. if (master) then
  92. print *
  93. end if
  94. end subroutine uobs_get
  95. end module m_uobs