SOCA
soca_bkgerrutil_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2021 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 !> bakground error bounds
8 
9 use fckit_configuration_module, only: fckit_configuration
10 use kinds, only: kind_real
12 use soca_utils, only: soca_adjust
13 
14 implicit none
15 private
16 
17 !> bounds for background error
18 !!
19 !! Used by soca_bkgerrgodas_mod::soca_bkgerrgodas_config and soca_bkgerr_mod::soca_bkgerr_config
20 !! \todo cleanup and remove hardcoded variable names
21 type, public :: soca_bkgerr_bounds_type
22  real(kind=kind_real) :: t_min, t_max
23  real(kind=kind_real) :: s_min, s_max
24  real(kind=kind_real) :: ssh_min, ssh_max
25  real(kind=kind_real) :: cicen_min, cicen_max
26  real(kind=kind_real) :: hicen_min, hicen_max
27  real(kind=kind_real) :: swh_min, swh_max
28  real(kind=kind_real) :: chl_min, chl_max
29  real(kind=kind_real) :: biop_min, biop_max
30 contains
31 
32  !> \copybrief soca_bkgerr_readbounds \see soca_bkgerr_readbounds
33  procedure :: read => soca_bkgerr_readbounds
34 
35  !> \copybrief soca_bkgerr_applybounds \see soca_bkgerr_applybounds
36  procedure :: apply => soca_bkgerr_applybounds
37 
39 
40 contains
41 
42 
43 ! ------------------------------------------------------------------------------
44 !> Read bounds from config
45 !!
46 !! \relates soca_bkgerrutil_mod::soca_bkgerr_bounds_type
47 subroutine soca_bkgerr_readbounds(self, f_conf)
48  class(soca_bkgerr_bounds_type), intent(inout) :: self
49  type(fckit_configuration), intent(in) :: f_conf
50 
51  ! Get bounds from configuration
52  if(.not. f_conf%get("t_min", self%t_min)) self%t_min = 0.0
53  if(.not. f_conf%get("t_max", self%t_max)) self%t_min = huge(0.0)
54  if(.not. f_conf%get("s_min", self%s_min)) self%s_min = 0.0
55  if(.not. f_conf%get("s_max", self%s_max)) self%s_max = huge(0.0)
56  if(.not. f_conf%get("ssh_min", self%ssh_min)) self%ssh_min = 0.0
57  if(.not. f_conf%get("ssh_max", self%ssh_max)) self%ssh_max = huge(0.0)
58  if(.not. f_conf%get("cicen_min", self%cicen_min)) self%cicen_min = 0.0
59  if(.not. f_conf%get("cicen_max", self%cicen_max)) self%cicen_max = huge(0.0)
60  if(.not. f_conf%get("hicen_min", self%hicen_min)) self%hicen_min = 0.0
61  if(.not. f_conf%get("hicen_max", self%hicen_max)) self%hicen_max = huge(0.0)
62  if(.not. f_conf%get("chl_min", self%chl_min)) self%chl_min = 0.0
63  if(.not. f_conf%get("chl_max", self%chl_max)) self%chl_max = huge(0.0)
64  if(.not. f_conf%get("biop_min", self%biop_min)) self%biop_min = 0.0
65  if(.not. f_conf%get("biop_max", self%biop_max)) self%biop_max = huge(0.0)
66  if(.not. f_conf%get("swh_min", self%swh_min)) self%swh_min = 0.0
67  if(.not. f_conf%get("swh_max", self%swh_max)) self%swh_max = huge(0.0)
68 end subroutine soca_bkgerr_readbounds
69 
70 
71 ! ------------------------------------------------------------------------------
72 !> Setup the static background error
73 !!
74 !! \relates soca_bkgerrutil_mod::soca_bkgerr_bounds_type
75 subroutine soca_bkgerr_applybounds(self, fld)
76  class(soca_bkgerr_bounds_type), intent(inout) :: self
77  type(soca_fields), intent(inout) :: fld !< fields to apply bound to
78 
79  type(soca_field), pointer :: field
80 
81  integer :: isc, iec, jsc, jec, i, j, n
82  real(kind=kind_real) :: vmin, vmax
83 
84  ! Apply config bounds to background error
85  isc = fld%geom%isc ; iec = fld%geom%iec
86  jsc = fld%geom%jsc ; jec = fld%geom%jec
87 
88  do n=1,size(fld%fields)
89  field => fld%fields(n)
90  select case(field%name)
91  case ("tocn")
92  vmin = self%t_min!! \relates soca_bkgerrutil_mod::soca_bkgerr_bounds_type
93  vmax = self%t_max
94  case ("socn")
95  vmin = self%s_min
96  vmax = self%s_max
97  case ("ssh")
98  vmin = self%ssh_min
99  vmax = self%ssh_max
100  case ("cicen")
101  vmin = self%cicen_min
102  vmax = self%cicen_max
103  case ("hicen")
104  vmin = self%hicen_min
105  vmax = self%hicen_max
106  case ("chl")
107  vmin = self%chl_min
108  vmax = self%chl_max
109  case ("biop")
110  vmin = self%biop_min
111  vmax = self%biop_max
112  case ("swh")
113  vmin = self%swh_min
114  vmax = self%swh_max
115  case default
116  cycle
117  end select
118 
119  do i = isc, iec
120  do j = jsc, jec
121  field%val(i,j,:) = soca_adjust(field%val(i,j,:), vmin, vmax)
122  end do
123  end do
124  end do
125 
126 end subroutine soca_bkgerr_applybounds
127 
128 end module soca_bkgerrutil_mod
bakground error bounds
Handle fields for the model.
various utility functions
Definition: soca_utils.F90:7
elemental real(kind=kind_real) function, public soca_adjust(std, minstd, maxstd)
Apply bounds.
Definition: soca_utils.F90:169
Holds all data and metadata related to a single field variable.
A collection of soca_field types representing a collective state or increment.