9 use fckit_log_module,
only: fckit_log
10 use kinds,
only: kind_real
11 use oops_variables_mod
36 procedure :: diff_incr=> soca_state_diff_incr
39 procedure :: add_incr => soca_state_add_incr
48 procedure :: rotate => soca_state_rotate
51 procedure :: convert => soca_state_convert
54 procedure :: logexpon => soca_state_logexpon
73 subroutine soca_state_rotate(self, coordinate, uvars, vvars)
75 character(len=*),
intent(in) :: coordinate
76 type(oops_variables),
intent(in) :: uvars
77 type(oops_variables),
intent(in) :: vvars
81 real(kind=kind_real),
allocatable :: un(:,:,:), vn(:,:,:)
82 character(len=64) :: u_names, v_names
86 u_names = trim(uvars%variable(i))
87 v_names = trim(vvars%variable(i))
88 if (self%has(u_names).and.self%has(v_names))
then
89 call fckit_log%info(
"rotating "//trim(u_names)//
" "//trim(v_names))
90 call self%get(u_names, uocn)
91 call self%get(v_names, vocn)
94 call fckit_log%info(
"not rotating "//trim(u_names)//
" "//trim(v_names))
97 allocate(un(
size(uocn%val,1),
size(uocn%val,2),
size(uocn%val,3)))
98 allocate(vn(
size(uocn%val,1),
size(uocn%val,2),
size(uocn%val,3)))
102 select case(trim(coordinate))
106 (self%geom%cos_rot(:,:)*un(:,:,z) + self%geom%sin_rot(:,:)*vn(:,:,z)) * uocn%mask(:,:)
108 (- self%geom%sin_rot(:,:)*un(:,:,z) + self%geom%cos_rot(:,:)*vn(:,:,z)) * vocn%mask(:,:)
113 (self%geom%cos_rot(:,:)*un(:,:,z) - self%geom%sin_rot(:,:)*vn(:,:,z)) * uocn%mask(:,:)
115 (self%geom%sin_rot(:,:)*un(:,:,z) + self%geom%cos_rot(:,:)*vn(:,:,z)) * vocn%mask(:,:)
121 call uocn%update_halo(self%geom)
122 call vocn%update_halo(self%geom)
124 end subroutine soca_state_rotate
132 subroutine soca_state_add_incr(self, rhs)
139 real(kind=kind_real) :: min_ice = 1e-6_kind_real
140 real(kind=kind_real) :: amin = 1e-6_kind_real
141 real(kind=kind_real) :: amax = 10.0_kind_real
142 real(kind=kind_real),
allocatable :: alpha(:,:), aice_bkg(:,:), aice_ana(:,:)
146 call rhs%check_subset(self)
153 do i=1,
size(incr%fields)
154 fld_r => incr%fields(i)
155 call self%get(fld_r%name, fld)
156 fld%val = fld%val + fld_r%val
159 end subroutine soca_state_add_incr
168 subroutine soca_state_diff_incr(x1, x2, inc)
177 call inc%check_subset(x2)
178 call x2%check_subset(x1)
181 do i=1,
size(inc%fields)
182 call x1%get(inc%fields(i)%name, f1)
183 call x2%get(inc%fields(i)%name, f2)
184 inc%fields(i)%val = f1%val - f2%val
186 end subroutine soca_state_diff_incr
198 subroutine soca_state_convert(self, rhs)
204 type(
soca_field),
pointer :: field1, field2, hocn1, hocn2, layer_depth
206 call rhs%get(
"hocn", hocn1)
207 call self%get(
"hocn", hocn2)
208 call convert_state%setup(rhs%geom, self%geom, hocn1, hocn2)
209 do n = 1,
size(rhs%fields)
210 if (rhs%fields(n)%name==
'layer_depth') cycle
211 field1 => rhs%fields(n)
212 call self%get(trim(field1%name),field2)
213 if (field1%metadata%io_file==
"ocn" .or. field1%metadata%io_file==
"sfc" .or. field1%metadata%io_file==
"ice") &
214 call convert_state%change_resol(field1, field2, rhs%geom, self%geom)
216 if (rhs%fields(n)%metadata%property==
'positive_definite')
then
217 where (field2%val<0.0)
224 call self%get(
"layer_depth", layer_depth)
225 call self%geom%thickness2depth(hocn2%val, layer_depth%val)
226 call convert_state%clean()
227 end subroutine soca_state_convert
234 subroutine soca_state_logexpon(self, transfunc, trvars)
236 character(len=*),
intent(in) :: transfunc
237 type(oops_variables),
intent(in) :: trvars
241 real(kind=kind_real),
allocatable :: trn(:,:,:)
242 real(kind=kind_real) :: min_val = 1e-6_kind_real
243 character(len=64) :: tr_names
245 do i=1, trvars%nvars()
247 tr_names = trim(trvars%variable(i))
248 if (self%has(tr_names))
then
249 call fckit_log%info(
"transforming "//trim(tr_names))
250 call self%get(tr_names, trocn)
253 call fckit_log%info(
"not transforming "//trim(tr_names))
256 allocate(trn(
size(trocn%val,1),
size(trocn%val,2),
size(trocn%val,3)))
259 select case(trim(transfunc))
261 trocn%val = log(trn + min_val)
263 trocn%val = exp(trn) - min_val
267 call trocn%update_halo(self%geom)
272 end subroutine soca_state_logexpon
Handle fields for the model.
resolution change for fields
Holds all data and metadata related to a single field variable.
A collection of soca_field types representing a collective state or increment.