UFO
ufo_seaicethickness_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 for seaicethickness observation operator
7 
9 
10  use fckit_configuration_module, only: fckit_configuration
11  use iso_c_binding
12  use kinds
13 
15  use ufo_basis_mod, only: ufo_basis
16  use ufo_vars_mod
17  use obsspace_mod
18  use oops_variables_mod
19 
20  implicit none
21  private
22 
23  integer, parameter :: max_string=800
24 
25 !> Fortran derived type for the observation type
26  type, extends(ufo_basis), public :: ufo_seaicethickness
27  type(oops_variables), public :: obsvars
28  real(kind=kind_real) :: rho_ice = 905.0 !< [kg/m3]
29  real(kind=kind_real) :: rho_snow = 330.0 !< [kg/m3]
30  real(kind=kind_real) :: rho_water= 1000.0!< [kg/m3]
31  contains
32  procedure :: setup => ufo_seaicethickness_setup
33  procedure :: delete => ufo_seaicethickness_delete
34  procedure :: simobs => ufo_seaicethickness_simobs
35  end type ufo_seaicethickness
36 
37 contains
38 
39 ! ------------------------------------------------------------------------------
40 subroutine ufo_seaicethickness_setup(self, f_conf)
41 implicit none
42 class(ufo_seaicethickness), intent(inout) :: self
43 type(fckit_configuration), intent(in) :: f_conf
44 integer :: ivar, nvars
45 character(max_string) :: err_msg
46 
47 nvars = self%obsvars%nvars()
48 if (nvars /= 1) then
49  write(err_msg,*) 'ufo_seaicethickness_setup error: only variables size 1 supported!'
50  call abor1_ftn(err_msg)
51 endif
52 
53 end subroutine ufo_seaicethickness_setup
54 
55 ! ------------------------------------------------------------------------------
57 implicit none
58 class(ufo_seaicethickness), intent(inout) :: self
59 
60 end subroutine ufo_seaicethickness_delete
61 
62 ! ------------------------------------------------------------------------------
63 subroutine ufo_seaicethickness_simobs(self, geovals, hofx, obss)
64 implicit none
65 class(ufo_seaicethickness), intent(in) :: self
66 type(ufo_geovals), intent(in) :: geovals
67 real(c_double), intent(inout) :: hofx(:)
68 type(c_ptr), value, intent(in) :: obss
69 
70  character(len=*), parameter :: myname_="ufo_seaicethick_simobs"
71  character(max_string) :: err_msg
72 
73  integer :: iobs, icat, ncat
74  type(ufo_geoval), pointer :: icethick, icefrac, snowthick
75  real(kind=kind_real) :: rho_wiw, rho_wsw
76 
77  ! check if nlocs is consistent in geovals & hofx
78  if (geovals%nlocs /= size(hofx,1)) then
79  write(err_msg,*) myname_, ' error: nlocs inconsistent!'
80  call abor1_ftn(err_msg)
81  endif
82 
83  if (trim(self%obsvars%variable(1)) == "sea_ice_freeboard") then
84  rho_wiw = (self%rho_water-self%rho_ice)/self%rho_water
85  rho_wsw = (self%rho_water-self%rho_snow)/self%rho_water
86  endif
87 
88  ! check if sea ice fraction variable is in geovals and get it
89  call ufo_geovals_get_var(geovals, var_seaicefrac, icefrac)
90  ! check if snow thickness variable is in geovals and get it
91  if (trim(self%obsvars%variable(1)) == "sea_ice_freeboard") &
92  call ufo_geovals_get_var(geovals, var_seaicesnowthick, snowthick)
93  ! check if sea ice thickness variable is in geovals and get it
94  call ufo_geovals_get_var(geovals, var_seaicethick, icethick)
95 
96  ncat = icefrac%nval
97  hofx = 0.0
98 
99  ! total sea ice fraction obs operator
100  select case (trim(self%obsvars%variable(1)))
101  case ("sea_ice_freeboard")
102  do iobs = 1, size(hofx,1)
103  do icat = 1, ncat
104  hofx(iobs) = hofx(iobs)+ rho_wiw*icefrac%vals(icat,iobs) * icethick%vals(icat,iobs)&
105  + rho_wsw*icefrac%vals(icat,iobs) * snowthick%vals(icat,iobs)
106  enddo
107  enddo
108  case ("sea_ice_thickness")
109  do iobs = 1, size(hofx,1)
110  do icat = 1, ncat
111  hofx(iobs) = hofx(iobs) + icefrac%vals(icat,iobs) * icethick%vals(icat,iobs)
112  enddo
113  enddo
114  case default
115  write(err_msg,*) myname_, ' error: no match seaice thickness_option!'
116  call abor1_ftn(err_msg)
117  end select
118 
119 end subroutine ufo_seaicethickness_simobs
120 
121 end module ufo_seaicethickness_mod
ufo_avgkernel_mod::max_string
integer, parameter max_string
Definition: ufo_avgkernel_mod.F90:17
ufo_seaicethickness_mod::ufo_seaicethickness_simobs
subroutine ufo_seaicethickness_simobs(self, geovals, hofx, obss)
Definition: ufo_seaicethickness_mod.F90:64
ufo_basis_mod
Definition: ufo_basis_mod.F90:6
ufo_seaicethickness_mod
Fortran module for seaicethickness observation operator.
Definition: ufo_seaicethickness_mod.F90:8
ufo_vars_mod::var_seaicethick
character(len=maxvarlen), public var_seaicethick
Definition: ufo_variables_mod.F90:138
ufo_vars_mod::var_seaicefrac
character(len=maxvarlen), public var_seaicefrac
Definition: ufo_variables_mod.F90:137
ufo_geovals_mod
Definition: ufo_geovals_mod.F90:7
ufo_seaicethickness_mod::ufo_seaicethickness_setup
subroutine ufo_seaicethickness_setup(self, f_conf)
Definition: ufo_seaicethickness_mod.F90:41
ufo_basis_mod::ufo_basis
Definition: ufo_basis_mod.F90:12
ufo_vars_mod
Definition: ufo_variables_mod.F90:8
ufo_geovals_mod::ufo_geovals_get_var
subroutine, public ufo_geovals_get_var(self, varname, geoval)
Definition: ufo_geovals_mod.F90:128
ufo_geovals_mod::ufo_geovals
type to hold interpolated fields required by the obs operators
Definition: ufo_geovals_mod.F90:47
ufo_seaicethickness_mod::ufo_seaicethickness
Fortran derived type for the observation type.
Definition: ufo_seaicethickness_mod.F90:26
ufo_seaicethickness_mod::ufo_seaicethickness_delete
subroutine ufo_seaicethickness_delete(self)
Definition: ufo_seaicethickness_mod.F90:57
ufo_geovals_mod::ufo_geoval
type to hold interpolated field for one variable, one observation
Definition: ufo_geovals_mod.F90:40
ufo_vars_mod::var_seaicesnowthick
character(len=maxvarlen), public var_seaicesnowthick
Definition: ufo_variables_mod.F90:139