FV3 Bundle
qg_bstddev_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2009-2016 ECMWF.
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 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 
9 !> Structure holding configuration variables for the 3d error
10 !! std dev matrices of the QG analysis.
11 
13 
14 use kinds
15 implicit none
16 
17 !> Fortran derived type to hold configuration data for the QG background/model std dev
19  real(kind=kind_real) :: sigma !< Standard deviation
20 end type qg_3d_bstddev_config
21 
22 #define LISTED_TYPE qg_3d_bstddev_config
23 
24 !> Linked list interface - defines registry_t type
25 #include "oops/util/linkedList_i.f"
26 
27 !> Global registry
28 type(registry_t) :: qg_3d_bstddev_registry
29 
30 ! ------------------------------------------------------------------------------
31 contains
32 ! ------------------------------------------------------------------------------
33 !> Linked list implementation
34 #include "oops/util/linkedList_c.f"
35 ! ------------------------------------------------------------------------------
36 
37 ! ------------------------------------------------------------------------------
38 
39 !> Setup for the QG model's 3d error std dev matrices (B and Q_i)
40 
41 !> This routine queries the configuration for the parameters that define the
42 !! std dev matrix, and stores the relevant values in the
43 !! error std dev structure.
44 
45 subroutine qg_3d_bstddev_setup(c_model, config)
46 
47 use qg_constants
48 use qg_geom_mod
49 use iso_c_binding
50 use config_mod
51 use kinds
52 use fckit_log_module, only : fckit_log
53 
54 implicit none
55 type(c_ptr), intent(in) :: c_model !< The configuration
56 type(qg_3d_bstddev_config), intent(inout) :: config !< The std dev structure
57 
58 config%sigma = config_get_real(c_model,"standard_deviation")
59 
60 return
61 end subroutine qg_3d_bstddev_setup
62 
63 ! ------------------------------------------------------------------------------
64 
65 !> Delete for the QG model's 3d error std dev matrices
66 
67 subroutine qg_3d_bstddev_delete(self)
68 implicit none
69 type(qg_3d_bstddev_config) :: self
70 
71 end subroutine qg_3d_bstddev_delete
72 
73 ! ------------------------------------------------------------------------------
74 
75 !> Multiply by inverse of std dev matrix
76 
77 subroutine qg_3d_bstddev_inv_mult(xin,xout,config)
78 use iso_c_binding
79 use kinds
80 use qg_fields
81 
82 implicit none
83 type(qg_field), intent(in) :: xin
84 type(qg_field), intent(inout) :: xout
85 type(qg_3d_bstddev_config), intent(in) :: config !< bstddev config structure
86 
87 integer :: i, j, k
88 real(kind=kind_real) :: zc
89 
90 !--- multiply by inverse standard deviation
91 
92 zc = 1.0_kind_real/config%sigma
93 do k=1,2
94  do j=1,xout%geom%ny
95  do i=1,xout%geom%nx
96  xout%x(i,j,k) = zc * xin%x(i,j,k)
97  enddo
98  enddo
99 enddo
100 
101 end subroutine qg_3d_bstddev_inv_mult
102 
103 ! ------------------------------------------------------------------------------
104 
105 !> Multiply by std dev matrix
106 
107 subroutine qg_3d_bstddev_mult(xin,xout,config)
108 use iso_c_binding
109 use kinds
110 use qg_fields
111 
112 implicit none
113 type(qg_field), intent(in) :: xin
114 type(qg_field), intent(inout) :: xout
115 type(qg_3d_bstddev_config), intent(in) :: config !< bstddev config structure
116 
117 integer :: i, j, k
118 
119 !--- multiply by standard deviation
120 
121 do k=1,2
122  do j=1,xout%geom%ny
123  do i=1,xout%geom%nx
124  xout%x(i,j,k) = config%sigma * xin%x(i,j,k)
125  enddo
126  enddo
127 enddo
128 
129 end subroutine qg_3d_bstddev_mult
130 
131 ! ------------------------------------------------------------------------------
132 
133 end module qg_bstddev_mod
type(registry_t) qg_3d_bstddev_registry
Linked list interface - defines registry_t type.
subroutine qg_3d_bstddev_inv_mult(xin, xout, config)
Multiply by inverse of std dev matrix.
Constants for the QG model.
Structure holding configuration variables for the 3d error std dev matrices of the QG analysis...
Fortran module handling geometry for the QG model.
Definition: qg_geom_mod.F90:11
subroutine qg_3d_bstddev_mult(xin, xout, config)
Multiply by std dev matrix.
Fortran derived type to hold configuration data for the QG background/model std dev.
Handle fields for the QG model.
Definition: qg_fields.F90:11
subroutine qg_3d_bstddev_setup(c_model, config)
Linked list implementation.
subroutine qg_3d_bstddev_delete(self)
Delete for the QG model&#39;s 3d error std dev matrices.