Loading [MathJax]/jax/input/TeX/config.js
MPAS-JEDI
All Classes Namespaces Files Functions Variables Typedefs Macros Pages
mpas_covariance_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017 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 
7 
8 !oops
9 use kinds, only: kind_real
10 
11 !ufo
12 use ufo_vars_mod, only: maxvarlen
13 
14 implicit none
15 
16 !> Fortran derived type to hold configuration data for the background/model covariance
17 type :: mpas_covar
18  integer :: nothing_yet
19  character(len=MAXVARLEN), allocatable :: var_scaling_variables(:)
20  real (kind=kind_real), allocatable :: var_scaling_magnitudes(:)
21 end type mpas_covar
22 
23 #define LISTED_TYPE mpas_covar
24 
25 !> Linked list interface - defines registry_t type
26 #include <oops/util/linkedList_i.f>
27 
28 !> Global registry
29 type(registry_t) :: mpas_covar_registry
30 
31 ! ------------------------------------------------------------------------------
32 contains
33 ! ------------------------------------------------------------------------------
34 !> Linked list implementation
35 #include <oops/util/linkedList_c.f>
36 ! ------------------------------------------------------------------------------
37 
38 ! ------------------------------------------------------------------------------
39 
40 !> Setup for the model's 3d error covariance matrices (B and Q_i)
41 
42 !> This routine queries the configuration for the parameters that define the
43 !! covariance matrix, and stores the relevant values in the
44 !! error covariance structure.
45 
46 subroutine mpas_covar_setup(self, geom, f_conf)
47 use fckit_configuration_module, only: fckit_configuration
48 use mpas_geom_mod
49 use iso_c_binding
50 
51 implicit none
52 type(mpas_covar), intent(inout) :: self !< Covariance structure
53 type(fckit_configuration), intent(in) :: f_conf !< Configuration
54 type(mpas_geom), intent(in) :: geom !< Geometry
55 
56 character(kind=c_char,len=:), allocatable :: char_array(:)
57 real(kind=c_float), allocatable :: real_array(:)
58 
59 if (f_conf%has("var_scaling_variables") .and. f_conf%has("var_scaling_magnitudes")) then
60  call f_conf%get_or_die("var_scaling_variables",char_array)
61  call f_conf%get_or_die("var_scaling_magnitudes",real_array)
62  if(size(real_array) /= size(char_array)) then
63  call abor1_ftn("--> mpas_b_setup_f90: var_scaling_variables and var_scaling_magnitudes have different sizes")
64  end if
65 
66  if(len(char_array) > maxvarlen) then
67  call abor1_ftn("--> mpas_b_setup_f90: length of strings in var_scaling_variables greater than MAXVARLEN")
68  end if
69  allocate(self % var_scaling_variables(size(char_array)))
70  self % var_scaling_variables = char_array
71  allocate(self % var_scaling_magnitudes(size(real_array)))
72  self % var_scaling_magnitudes = real(real_array,kind=kind_real)
73 else
74  allocate(self % var_scaling_variables(0))
75  allocate(self % var_scaling_magnitudes(0))
76 end if
77 
78 end subroutine mpas_covar_setup
79 
80 ! ------------------------------------------------------------------------------
81 
82 subroutine mpas_covar_delete(self)
83 implicit none
84 type(mpas_covar), intent(inout) :: self !< Covariance structure
85 
86 deallocate(self % var_scaling_variables)
87 deallocate(self % var_scaling_magnitudes)
88 
89 end subroutine mpas_covar_delete
90 
91 ! ------------------------------------------------------------------------------
92 
93 !> Multiply streamfunction by inverse(sqrt(C)), where C is 3d covariance matrix
94 
95 subroutine mpas_covar_sqrt_inv_mult(self, xctl, xincr)
97 
98 implicit none
99 type(mpas_covar), intent(in) :: self
100 real, intent(inout) :: xctl
101 type(mpas_fields), intent(in) :: xincr
102 
103 end subroutine mpas_covar_sqrt_inv_mult
104 
105 ! ------------------------------------------------------------------------------
106 
107 !> Multiply streamfunction by inverse(sqrt(C)) - Adjoint
108 
109 subroutine mpas_covar_sqrt_inv_mult_ad(self, xctl, xincr)
110 use mpas_fields_mod, only: mpas_fields
111 
112 implicit none
113 type(mpas_covar), intent(in) :: self
114 type(mpas_fields), intent(inout) :: xincr
115 real, intent(in) :: xctl
116 
117 end subroutine mpas_covar_sqrt_inv_mult_ad
118 
119 ! ------------------------------------------------------------------------------
120 
121 !> Multiply streamfunction by sqrt(C), where C is a 3d covariance matrix
122 
123 subroutine mpas_covar_sqrt_mult(self, xincr, xctl)
124 use mpas_fields_mod, only: mpas_fields
125 
126 implicit none
127 type(mpas_covar), intent(in) :: self
128 type(mpas_fields), intent(inout) :: xincr
129 real, intent(in) :: xctl
130 
131 end subroutine mpas_covar_sqrt_mult
132 
133 ! ------------------------------------------------------------------------------
134 
135 !> Multiply streamfunction by sqrt(C) - Adjoint
136 
137 subroutine mpas_covar_sqrt_mult_ad(self, xincr, xctl)
138 use mpas_fields_mod, only: mpas_fields
139 
140 implicit none
141 type(mpas_covar), intent(in) :: self
142 real, intent(inout) :: xctl
143 type(mpas_fields), intent(in) :: xincr
144 
145 end subroutine mpas_covar_sqrt_mult_ad
146 
147 ! ------------------------------------------------------------------------------
148 
149 end module mpas_covariance_mod
subroutine mpas_covar_sqrt_inv_mult(self, xctl, xincr)
Multiply streamfunction by inverse(sqrt(C)), where C is 3d covariance matrix.
subroutine mpas_covar_sqrt_inv_mult_ad(self, xctl, xincr)
Multiply streamfunction by inverse(sqrt(C)) - Adjoint.
subroutine mpas_covar_delete(self)
subroutine mpas_covar_sqrt_mult(self, xincr, xctl)
Multiply streamfunction by sqrt(C), where C is a 3d covariance matrix.
type(registry_t) mpas_covar_registry
Linked list interface - defines registry_t type.
subroutine mpas_covar_setup(self, geom, f_conf)
Linked list implementation.
subroutine mpas_covar_sqrt_mult_ad(self, xincr, xctl)
Multiply streamfunction by sqrt(C) - Adjoint.
Fortran derived type to hold configuration data for the background/model covariance.
Fortran derived type to hold MPAS field.
Fortran derived type to hold geometry definition.