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 use ufo_utils_mod, only: cmp_strings
65 implicit none
66 class(ufo_seaicethickness), intent(in) :: self
67 type(ufo_geovals), intent(in) :: geovals
68 real(c_double), intent(inout) :: hofx(:)
69 type(c_ptr), value, intent(in) :: obss
70 
71  character(len=*), parameter :: myname_="ufo_seaicethick_simobs"
72  character(max_string) :: err_msg
73 
74  integer :: iobs, icat, ncat
75  type(ufo_geoval), pointer :: icethick, icefrac, snowthick
76  real(kind=kind_real) :: rho_wiw, rho_wsw
77 
78  ! check if nlocs is consistent in geovals & hofx
79  if (geovals%nlocs /= size(hofx,1)) then
80  write(err_msg,*) myname_, ' error: nlocs inconsistent!'
81  call abor1_ftn(err_msg)
82  endif
83 
84  if (cmp_strings(self%obsvars%variable(1), "sea_ice_freeboard")) then
85  rho_wiw = (self%rho_water-self%rho_ice)/self%rho_water
86  rho_wsw = (-self%rho_snow)/self%rho_water
87  endif
88 
89  ! check if sea ice fraction variable is in geovals and get it
90  call ufo_geovals_get_var(geovals, var_seaicefrac, icefrac)
91  ! check if snow thickness variable is in geovals and get it
92  if (cmp_strings(self%obsvars%variable(1), "sea_ice_freeboard")) &
93  call ufo_geovals_get_var(geovals, var_seaicesnowthick, snowthick)
94  ! check if sea ice thickness variable is in geovals and get it
95  call ufo_geovals_get_var(geovals, var_seaicethick, icethick)
96 
97  ncat = icefrac%nval
98  hofx = 0.0
99 
100  ! total sea ice fraction obs operator
101  select case (trim(self%obsvars%variable(1)))
102  case ("sea_ice_freeboard")
103  do iobs = 1, size(hofx,1)
104  do icat = 1, ncat
105  hofx(iobs) = hofx(iobs)+ rho_wiw*icefrac%vals(icat,iobs) * icethick%vals(icat,iobs)&
106  + rho_wsw*icefrac%vals(icat,iobs) * snowthick%vals(icat,iobs)
107  enddo
108  enddo
109  case ("sea_ice_thickness")
110  do iobs = 1, size(hofx,1)
111  do icat = 1, ncat
112  hofx(iobs) = hofx(iobs) + icefrac%vals(icat,iobs) * icethick%vals(icat,iobs)
113  enddo
114  enddo
115  case default
116  write(err_msg,*) myname_, ' error: no match seaice thickness_option!'
117  call abor1_ftn(err_msg)
118  end select
119 
120 end subroutine ufo_seaicethickness_simobs
121 
122 end module ufo_seaicethickness_mod
subroutine, public ufo_geovals_get_var(self, varname, geoval)
Fortran module for seaicethickness observation operator.
subroutine ufo_seaicethickness_delete(self)
subroutine ufo_seaicethickness_setup(self, f_conf)
subroutine ufo_seaicethickness_simobs(self, geovals, hofx, obss)
Fortran module with various useful routines.
logical function, public cmp_strings(str1, str2)
character(len=maxvarlen), public var_seaicesnowthick
character(len=maxvarlen), public var_seaicethick
character(len=maxvarlen), public var_seaicefrac
type to hold interpolated field for one variable, one observation
type to hold interpolated fields required by the obs operators
Fortran derived type for the observation type.