Blame view

m_measure.F90 1.99 KB
26362238   Dany Dumont   premier depot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module m_measure
contains
   subroutine measure(d,ref,vars,meas_action)
   use mod_dimensions
   use mod_states
   use mod_observations
   use mod_variances
   use m_random
   implicit none
   type(observations), intent(out)  :: d(nrobs,nrmes_t)
   type(states),       intent(in)   :: ref(ndim)
   type(lstates),      intent(in)   :: meas_action
   type(variances),    intent(in)   :: vars

   real workb(antvar)
   integer jz(nrmes_z)
   integer i,j,k,m,dkdim,iobs

! Note: integer-divisions
   dkdim=kdim/(nrmes_z+1)
   do k=1,nrmes_z
      jz(k)=k*dkdim - dkdim/2
   enddo
   print *,'measure: measurement depth indexes are: ',jz
   do k=1,nrmes_z
     print *,'measure: have measurements at ',jz(k)*dkdim,' meters'
   enddo

   do m=1,nrmes_t
      i=m*nres+1
      iobs=0
      do k=1,nrmes_z
         call random(workb,3)
         ! Nitrate observation
         iobs=iobs+1
         d(iobs,m)%k=jz(k)
! Adding noise
         d(iobs,m)%d=max(0.0,ref(i)%N(jz(k))+sqrt(vars%mes%N)*workb(1))
         d(iobs,m)%ch='N  '
         d(iobs,m)%var=vars%mes%N
         if (meas_action%N) then
            d(iobs,m)%action=.true.
         else
            d(iobs,m)%action=.false.
         endif

         ! Phyto-plankton observation
         iobs=iobs+1
         d(iobs,m)%k=jz(k)
! Adding noise
         d(iobs,m)%d=max(0.0,ref(i)%P(jz(k))+sqrt(vars%mes%P)*workb(2))
         d(iobs,m)%ch='P  '
         d(iobs,m)%var=vars%mes%P
         if (meas_action%P) then
            d(iobs,m)%action=.true.
         else
            d(iobs,m)%action=.false.
         endif

         ! Zoo-plankton observation
         iobs=iobs+1
         d(iobs,m)%k=jz(k)
! Adding noise
         d(iobs,m)%d=max(0.0,ref(i)%H(jz(k))+sqrt(vars%mes%H)*workb(3))
         d(iobs,m)%ch='H  '
         d(iobs,m)%var=vars%mes%H
         if (meas_action%H) then
            d(iobs,m)%action=.true.
         else
            d(iobs,m)%action=.false.
         endif
      enddo
   enddo

   print *,'measurements done!'

   end subroutine measure
end module m_measure