m_uobs.f90 3.0 KB

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