mod_measurement.f90 3.7 KB

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