FV3 Bundle
ufo_stericheight_tlad_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2018 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
6 !> Fortran module to handle steric height operator
7 
9 
10 use iso_c_binding
11 use ufo_vars_mod
13 use kinds
14 
15 implicit none
16 public :: ufo_stericheight_tlad
20 private
21 integer, parameter :: max_string=800
22 
23 !> Fortran derived type for steric height observation operator
25  integer :: nl = -1 !< number of levels for T & S
26 end type ufo_stericheight_tlad
27 
28 
29 ! ------------------------------------------------------------------------------
30 
31 contains
32 
33 ! ------------------------------------------------------------------------------
34 
35 subroutine ufo_stericheight_tlad_settraj(self, geovals)
36 implicit none
37 type(ufo_stericheight_tlad), intent(inout) :: self
38 type(ufo_geovals), intent(in) :: geovals
39 
40 character(len=*), parameter :: myname_="ufo_stericheight_tlad_settraj"
41 character(max_string) :: err_msg
42 
43 type(ufo_geoval), pointer :: geoval
44 
45 print *, myname_, ' nobs: ', geovals%nobs
46 
47 
48 call ufo_geovals_get_var(geovals, var_abs_topo, geoval)
49 
50 !call ufo_geovals_get_var(geovals, var_stericheight, geoval)
51 print *,'==========================================='
52 self%nl = geoval%nval
53 print *, myname_, ' nval: ', geoval%nval
54 
55 end subroutine ufo_stericheight_tlad_settraj
56 
57 
58 ! ------------------------------------------------------------------------------
59 
60 subroutine ufo_stericheight_simobs_tl(self, geovals, hofx)!, traj)
61 implicit none
62 type(ufo_stericheight_tlad), intent(in) :: self
63 type(ufo_geovals), intent(in) :: geovals
64 real(c_double), intent(inout) :: hofx(:)
65 !type(ufo_geovals), intent(in) :: traj
66 
67 character(len=*), parameter :: myname_="ufo_stericheight_simobs_tl"
68 character(max_string) :: err_msg
69 
70 integer :: iobs
71 type(ufo_geoval), pointer :: geoval
72 
73 print *, myname_, ' nobs: ', geovals%nobs, size(hofx,1)
74 
75 
76 ! check if nobs is consistent in geovals & hofx
77 if (geovals%nobs /= size(hofx,1)) then
78  write(err_msg,*) myname_, ' error: nobs inconsistent!'
79  call abor1_ftn(err_msg)
80 endif
81 
82 ! check if sea ice fraction variables is in geovals and get it
83 !call ufo_geovals_get_var(geovals, var_stericheight, geoval)
84 call ufo_geovals_get_var(geovals, var_abs_topo, geoval)
85 
86 ! total sea ice fraction obs operator
87 do iobs = 1, size(hofx,1)
88  hofx(iobs) = geoval%vals(1,iobs)
89 enddo
90 
91 end subroutine ufo_stericheight_simobs_tl
92 
93 ! ------------------------------------------------------------------------------
94 
95 subroutine ufo_stericheight_simobs_ad(self, geovals, hofx)
96 implicit none
97 type(ufo_stericheight_tlad), intent(in) :: self
98 type(ufo_geovals), intent(inout) :: geovals
99 real(c_double), intent(inout) :: hofx(:)
100 
101 character(len=*), parameter :: myname_="ufo_stericheight_simobs_ad"
102 character(max_string) :: err_msg
103 
104 integer :: iobs
105 type(ufo_geoval), pointer :: geoval
106 
107 print *,'&&&&&&&&&&&&7 in adjoint'
108 read(*,*)
109 
110 ! check if nobs is consistent in geovals & hofx
111 if (geovals%nobs /= size(hofx,1)) then
112  write(err_msg,*) myname_, ' error: nobs inconsistent!'
113  call abor1_ftn(err_msg)
114 endif
115 
116 call ufo_geovals_get_var(geovals, var_abs_topo, geoval)
117 
118 ! check if sea ice fraction variables is in geovals and get it
119 !call ufo_geovals_get_var(geovals, var_stericheight, geoval)
120 
121 if (.not.(allocated(geoval%vals))) then
122  if (self%nl < 1) then
123  !write(err_msg,*) myname_, ' unknown number of categories'
124  !call abor1_ftn(err_msg)
125  endif
126  !allocate(geoval%vals(self%ncat,size(hofx,1)))
127  allocate(geoval%vals(1,size(hofx,1)))
128 end if
129 
130 if (.not. geovals%linit ) geovals%linit=.true.
131 
132 ! backward steric height obs operator
133 geoval%vals=0.0
134 do iobs = 1, size(hofx,1)
135  geoval%vals(1,iobs) = geoval%vals(1,iobs) + size(hofx,1)
136 enddo
137 
138 end subroutine ufo_stericheight_simobs_ad
139 
140 end module ufo_stericheight_tlad_mod
subroutine, public ufo_geovals_get_var(self, varname, geoval, status)
integer, parameter max_string
subroutine, public ufo_stericheight_simobs_tl(self, geovals, hofx)
Fortran module to handle steric height operator.
subroutine, public ufo_stericheight_tlad_settraj(self, geovals)
type to hold interpolated fields required by the obs operators
character(len=maxvarlen), public var_abs_topo
Fortran derived type for steric height observation operator.
type to hold interpolated field for one variable, one observation
subroutine, public ufo_stericheight_simobs_ad(self, geovals, hofx)