mod_measurement.F90 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. module mod_measurement
  2. integer, parameter, public :: OBSTYPESTRLEN = 8
  3. integer, parameter, private :: MAXNUOBS = 9
  4. integer, public :: nuobs
  5. character(OBSTYPESTRLEN), public :: unique_obs(MAXNUOBS)
  6. integer, public :: nobseach(MAXNUOBS)
  7. integer :: uobs_begin(MAXNUOBS), uobs_end(MAXNUOBS)
  8. type measurement
  9. real d ! Measurement value
  10. real var ! Error variance of measurement
  11. character(OBSTYPESTRLEN) id ! Type of measurement ('a_i_htc1', 'a_i_tot ', 'u_ice ', 'v_ice ')
  12. real lon ! Longitude position
  13. real lat ! Latitude position
  14. real depths ! depths of position
  15. integer ipiv ! i-pivot point in grid
  16. integer jpiv ! j-pivot point in grid
  17. integer ns ! representativity in mod cells (meas. support)
  18. ! ns=0 means: point measurements
  19. ! used in m_Generate_element_Sij.F90
  20. real a1 ! bilinear coeffisients (if ni=0)
  21. real a2 ! bilinear coeffisients
  22. real a3 ! bilinear coeffisients
  23. real a4 ! bilinear coeffisients
  24. logical status ! active or not
  25. integer i_orig_grid ! KAL - ice drift needs orig grid index as well
  26. integer j_orig_grid ! KAL - ice drift needs orig grid index as well
  27. real h ! PS - layer thickness, sorry for that
  28. integer date ! FanF- age of the data
  29. integer orig_id ! PS used in superobing
  30. end type measurement
  31. contains
  32. subroutine get_unique_obs(tags, nrobs, master)
  33. implicit none
  34. integer , intent(in) :: nrobs
  35. logical , intent(in) :: master
  36. character(OBSTYPESTRLEN), intent(in) :: tags(nrobs)
  37. logical :: obsmatch
  38. integer :: o, uo
  39. nobseach = 0
  40. ! check for unique obs
  41. if (master) then
  42. print *
  43. print *, '(get_unique_obs) Getting unique obs '
  44. end if
  45. nuobs = 0
  46. unique_obs = ''
  47. do o = 1, nrobs
  48. obsmatch = .false.
  49. do uo = 1, MAXNUOBS
  50. if (trim(tags(o)) == trim(unique_obs(uo))) then
  51. obsmatch = .true.
  52. nobseach(uo) = nobseach(uo) + 1
  53. exit
  54. end if
  55. end do
  56. if (.not. obsmatch) then
  57. nuobs = nuobs + 1
  58. nobseach(nuobs) = 1
  59. if (nuobs > MAXNUOBS) then
  60. if (master) then
  61. print *, '(get_unique_obs) ERROR: # of unique obs > MAXNUOBS'
  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 *, '(get_unique_obs) obs variable ', uo, ' -- ', trim(unique_obs(uo)),&
  71. ',', 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 *, '(get_unique_obs) ERROR: unique observations not ',&
  85. 'continuous in observation array'
  86. stop
  87. end if
  88. end do
  89. end do
  90. end if
  91. end subroutine get_unique_obs
  92. end module mod_measurement