30 integer,
allocatable :: indx(:)
31 real(kind=kind_real),
allocatable :: values(:,:)
32 character(len=1),
allocatable :: variables(:)
36 #define LISTED_TYPE qg_goms 39 #include "oops/util/linkedList_i.f" 48 #include "oops/util/linkedList_c.f" 52 subroutine c_qg_gom_setup(c_key_self, c_key_locs, c_vars) bind(c,name='qg_gom_setup_f90')
54 integer(c_int),
intent(inout) :: c_key_self
55 integer(c_int),
intent(inout) :: c_key_locs
56 integer(c_int),
dimension(*),
intent(in) :: c_vars
58 type(qg_goms),
pointer :: self
59 type(qg_locs),
pointer :: locs
76 integer(c_int),
intent(inout) :: c_key_self
78 type(qg_goms),
pointer :: self
91 type(
qg_goms),
intent(inout) :: self
92 type(
qg_vars),
intent(in) :: vars
93 integer,
intent(in) :: kobs(:)
99 allocate(self%indx(self%nobs))
102 allocate(self%variables(self%nvar))
103 self%variables(:)=vars%fldnames(:)
105 allocate(self%values(self%nvar,self%nobs))
113 subroutine c_qg_gom_delete(c_key_self) bind(c,name='qg_gom_delete_f90')
116 integer(c_int),
intent(inout) :: c_key_self
118 type(qg_goms),
pointer :: self
121 if (self%lalloc)
then 122 deallocate(self%values)
123 deallocate(self%indx)
124 deallocate(self%variables)
132 subroutine c_qg_gom_assign(c_key_self, c_key_other) bind(c,name='qg_gom_assign_f90')
134 integer(c_int),
intent(in) :: c_key_self
135 integer(c_int),
intent(in) :: c_key_other
136 type(qg_goms),
pointer :: self
137 type(qg_goms),
pointer :: other
143 self%nobs = other%nobs
144 self%nvar = other%nvar
146 if (.not. self%lalloc)
then 147 allocate(self%variables(self%nvar))
148 allocate(self%values(self%nvar,self%nobs))
149 allocate(self%indx(self%nobs))
153 self%variables = other%variables
154 self%values = other%values
155 self%indx = other%indx
156 self%used = other%used
162 subroutine c_qg_gom_zero(c_key_self) bind(c,name='qg_gom_zero_f90')
164 integer(c_int),
intent(in) :: c_key_self
165 type(qg_goms),
pointer :: self
167 self%values(:,:)=0.0_kind_real
172 subroutine c_qg_gom_abs(c_key_self) bind(c,name='qg_gom_abs_f90')
174 integer(c_int),
intent(in) :: c_key_self
175 type(qg_goms),
pointer :: self
177 self%values(:,:)=abs(self%values(:,:))
182 subroutine c_qg_gom_random(c_key_self) bind(c,name='qg_gom_random_f90')
185 integer(c_int),
intent(in) :: c_key_self
186 type(qg_goms),
pointer :: self
193 subroutine c_qg_gom_mult(c_key_self, zz) bind(c,name='qg_gom_mult_f90')
195 integer(c_int),
intent(in) :: c_key_self
196 real(c_double),
intent(in) :: zz
197 type(qg_goms),
pointer :: self
203 self%values(jv,jo) = zz * self%values(jv,jo)
211 subroutine c_qg_gom_add(c_key_self, c_key_other) bind(c,name='qg_gom_add_f90')
213 integer(c_int),
intent(in) :: c_key_self
214 integer(c_int),
intent(in) :: c_key_other
215 type(qg_goms),
pointer :: self
216 type(qg_goms),
pointer :: other
223 self%values(jv,jo) = self%values(jv,jo) + other%values(jv,jo)
231 subroutine c_qg_gom_diff(c_key_self, c_key_other) bind(c,name='qg_gom_diff_f90')
233 integer(c_int),
intent(in) :: c_key_self
234 integer(c_int),
intent(in) :: c_key_other
235 type(qg_goms),
pointer :: self
236 type(qg_goms),
pointer :: other
243 self%values(jv,jo) = self%values(jv,jo) - other%values(jv,jo)
252 subroutine c_qg_gom_divide(c_key_self, c_key_other) bind(c,name='qg_gom_divide_f90')
254 integer(c_int),
intent(in) :: c_key_self
255 integer(c_int),
intent(in) :: c_key_other
256 type(qg_goms),
pointer :: self
257 type(qg_goms),
pointer :: other
258 real(kind_real) :: tol
259 integer :: jloc, jvar, ii
267 do jvar = 1, self%nvar
268 write(*,*)
'qg_gom_divide variable =', trim(self%variables(jvar))
269 do jloc = 1, self%nobs
270 if (abs(other%values(jvar,jloc)) > tol)
then 271 write(*,*)
'qg_gom_divide self, other = ',self%values(jvar,jloc), other%values(jvar,jloc), &
272 & self%values(jvar,jloc) / other%values(jvar,jloc)
273 self%values(jvar,jloc) = self%values(jvar,jloc) / other%values(jvar,jloc)
275 write(*,*)
'qg_gom_divide self, other = ',self%values(jvar,jloc), other%values(jvar,jloc)
276 self%values(jvar,jloc) = 0.0
286 subroutine c_qg_gom_rms(c_key_self, rms) bind(c,name='qg_gom_rms_f90')
288 integer(c_int),
intent(in) :: c_key_self
289 real(c_double),
intent(inout) :: rms
290 type(qg_goms),
pointer :: self
298 rms=rms+self%values(jv,jo)**2
302 rms = sqrt(rms/(self%nobs*self%nvar))
308 subroutine c_qg_gom_dotprod(c_key_self, c_key_other, prod) bind(c,name='qg_gom_dotprod_f90')
310 integer(c_int),
intent(in) :: c_key_self, c_key_other
311 real(c_double),
intent(inout) :: prod
312 type(qg_goms),
pointer :: self, other
320 prod=prod+self%values(jv,jo)*other%values(jv,jo)
328 subroutine c_qg_gom_minmaxavg(c_key_self, kobs, pmin, pmax, prms) bind(c,name='qg_gom_minmaxavg_f90')
330 integer(c_int),
intent(in) :: c_key_self
331 integer(c_int),
intent(inout) :: kobs
332 real(c_double),
intent(inout) :: pmin, pmax, prms
333 type(qg_goms),
pointer :: self
338 pmin=minval(self%values(:,:))
339 pmax=maxval(self%values(:,:))
340 prms=sqrt(sum(self%values(:,:)**2)/
real(self%nobs*self%nvar,kind_real))
346 subroutine c_qg_gom_maxloc(c_key_self, mxval, iloc, ivar) bind(c,name='qg_gom_maxloc_f90')
348 integer(c_int),
intent(in) :: c_key_self
349 real(c_double),
intent(inout) :: mxval
350 integer(c_int),
intent(inout) :: iloc
351 integer(c_int),
intent(inout) :: ivar
353 type(qg_goms),
pointer :: self
358 mxval=maxval(self%values(:,:))
359 mxloc=maxloc(self%values(:,:))
370 use fckit_log_module,
only : fckit_log
372 integer(c_int),
intent(in) :: c_key_self
373 type(c_ptr),
intent(in) :: c_conf
374 type(qg_goms),
pointer :: self
376 integer,
parameter :: iunit=10
377 integer,
parameter :: max_string_length=250
378 character(len=max_string_length) :: filename, record
379 character(len=4) :: cnx
380 character(len=17) :: fmtn
381 character(len=11) :: fmt1=
'(X,ES24.16)' 382 integer :: jj, jo, jv
385 if (self%lalloc)
call abor1_ftn(
"qg_gom_read_file gom alredy allocated")
387 filename = config_get_string(c_conf,len(filename),
"filename")
388 write(record,*)
'qg_gom_read_file: opening '//trim(filename)
389 call fckit_log%info(record)
390 open(unit=iunit, file=trim(filename), form=
'formatted', action=
'read')
392 read(iunit,*) self%nobs, self%nvar, self%used
393 allocate(self%indx(self%nobs))
394 allocate(self%variables(self%nvar))
395 allocate(self%values(self%nvar,self%nobs))
397 read(iunit,*) self%indx(:)
399 read(iunit,*) self%variables(jv)
402 if (self%nvar>9999)
call abor1_ftn(
"Format too small")
403 write(cnx,
'(I4)')self%nvar
404 fmtn=
'('//trim(cnx)//fmt1//
')' 407 read(iunit,fmtn) (self%values(jj,jo), jj=1,self%nvar)
419 use fckit_log_module,
only : fckit_log
421 integer(c_int),
intent(in) :: c_key_self
422 type(c_ptr),
intent(in) :: c_conf
423 type(qg_goms),
pointer :: self
425 integer,
parameter :: iunit=10
426 integer,
parameter :: max_string_length=250
427 character(len=max_string_length) :: filename, record
428 character(len=4) :: cnx
429 character(len=17) :: fmtn
430 character(len=11) :: fmt1=
'(X,ES24.16)' 431 integer :: jj, jo, jv
434 if (.not.self%lalloc)
call abor1_ftn(
"qg_gom_write_file gom not allocated")
436 filename = config_get_string(c_conf,len(filename),
"filename")
437 write(record,*)
'qg_gom_write_file: opening '//trim(filename)
438 call fckit_log%info(record)
439 open(unit=iunit, file=trim(filename), form=
'formatted', action=
'write')
441 write(iunit,*) self%nobs, self%nvar, self%used
442 write(iunit,*) self%indx(:)
444 write(iunit,*) self%variables(jv)
447 if (self%nvar>9999)
call abor1_ftn(
"Format too small")
448 write(cnx,
'(I4)')self%nvar
449 fmtn=
'('//trim(cnx)//fmt1//
')' 452 write(iunit,fmtn) (self%values(jj,jo), jj=1,self%nvar)
476 use fckit_log_module,
only : fckit_log
479 integer(c_int),
intent(in) :: c_key_self
480 integer(c_int),
intent(in) :: c_key_locs
481 type(c_ptr),
intent(in) :: c_conf
483 type(qg_goms),
pointer :: self
484 type(qg_locs),
pointer :: locs
486 character(len=30) :: ic
487 character(len=1024) :: buf
488 real(kind_real) :: d1, d2, height(2), klon, klat, kx, ky, kz, xx, yy
489 real(kind_real) :: pi = acos(-1.0_kind_real)
490 real(kind_real) :: p0,u0,v0,x0,w0,t0,phis0,ps0,rho0,hum0,q1,q2,q3,q4
491 real(kind_real) :: lat_range(2),lon_range(2)
492 integer :: iloc, ivar
502 if (.not. self%lalloc) &
503 call abor1_ftn(
"qg_gom_analytic init: gom not allocated")
505 ic = config_get_string(c_conf,len(ic),
"analytic_init")
506 write(buf,*)
'qg_gom_analytic_init: ic '//trim(ic)
507 call fckit_log%info(buf)
514 d1 = config_get_real(c_conf,
"top_layer_depth")
515 d2 = config_get_real(c_conf,
"bottom_layer_depth")
516 height(2) = 0.5_kind_real*d2
517 height(1) = d2 + 0.5_kind_real*d1
523 lat_range = (/ -28.0_kind_real, 28.0_kind_real /)
524 lon_range = (/ 0.0_kind_real, 107.0_kind_real /)
526 do iloc = 1, locs%nloc
529 klat = (lat_range(1) + locs%xyz(2,iloc)*(lat_range(2)-lat_range(1)))*pi/180.0_kind_real
530 klon = (lon_range(1) + locs%xyz(1,iloc)*(lon_range(2)-lon_range(1)))*pi/180.0_kind_real
531 kz = height(nint(locs%xyz(3,iloc)))
533 init_option:
select case (ic)
535 case (
"large-vortices")
537 xx = locs%xyz(1,iloc)
538 yy = locs%xyz(2,iloc)
540 ky = 2.0_kind_real * pi
541 u0 = -ky*sin(kx*xx)*cos(ky*yy)
542 v0 = kx*cos(kx*xx)*sin(ky*yy)
543 x0 = sin(kx*xx)*sin(ky*yy)
545 case (
"dcmip-test-1-1")
548 t0,phis0,ps0,rho0,hum0,q1,q2,q3,q4)
554 case (
"dcmip-test-1-2")
557 t0,phis0,ps0,rho0,hum0,q1)
565 write(buf,*)
"qg_gom_analytic_init: unknown init = " // ic
566 call fckit_log%error(buf)
569 end select init_option
571 do ivar = 1,self%nvar
573 variable:
select case(trim(self%variables(ivar)))
575 self%values(ivar,iloc) = u0
577 self%values(ivar,iloc) = v0
579 self%values(ivar,iloc) = 0.0_kind_real
Fortran derived type to represent QG model variables.
Fortran generic for generating random 1d, 2d and 3d arrays.
subroutine c_qg_gom_mult(c_key_self, zz)
subroutine c_qg_gom_diff(c_key_self, c_key_other)
Fortran derived type to hold interpolated fields required by the obs operators.
type(registry_t), public qg_locs_registry
Linked list interface - defines registry_t type.
subroutine test1_advection_deformation(lon, lat, p, z, zcoords, u, v, w, t, phis, ps, rho, q, q1, q2, q3, q4)
subroutine, public gom_setup(self, vars, kobs)
subroutine c_qg_gom_divide(c_key_self, c_key_other)
QG GeoVaLs division Operator.
Constants for the QG model.
subroutine c_qg_gom_setup(c_key_self, c_key_locs, c_vars)
Linked list implementation.
subroutine c_qg_gom_create(c_key_self)
subroutine qg_gom_analytic_init_c(c_key_self, c_key_locs, c_conf)
Initialize a QG GeoVaLs object based on an analytic state.
subroutine c_qg_gom_random(c_key_self)
subroutine, public qg_vars_create(self, kvars)
Linked list implementation.
Fortran module handling observation locations.
type(registry_t), public qg_goms_registry
Linked list interface - defines registry_t type.
subroutine c_qg_gom_rms(c_key_self, rms)
Fortran module to handle variables for the QG model.
subroutine c_qg_gom_add(c_key_self, c_key_other)
Fortran module for generating random vectors.
subroutine test1_advection_hadley(lon, lat, p, z, zcoords, u, v, w, t, phis, ps, rho, q, q1)
subroutine c_qg_gom_zero(c_key_self)
subroutine qg_gom_read_file_c(c_key_self, c_conf)
subroutine c_qg_gom_maxloc(c_key_self, mxval, iloc, ivar)
Fortran module handling interpolated (to obs locations) model variables.
subroutine qg_gom_write_file_c(c_key_self, c_conf)
subroutine c_qg_gom_minmaxavg(c_key_self, kobs, pmin, pmax, prms)
subroutine c_qg_gom_dotprod(c_key_self, c_key_other, prod)
subroutine c_qg_gom_assign(c_key_self, c_key_other)
subroutine c_qg_gom_delete(c_key_self)
real(kind=kind_real), parameter ubar
typical verlocity (m/s)
subroutine c_qg_gom_abs(c_key_self)