19 use fckit_log_module,
only : fckit_log
34 use odbgetput,
only: &
48 #define LISTED_TYPE ioda_obsdb 51 #include "linkedList_i.f" 60 #include "linkedList_c.f" 79 integer(c_int),
intent(inout) :: c_key_self
80 type(c_ptr),
intent(in) :: c_conf
82 type(ioda_obsdb),
pointer :: self
83 character(len=max_string) :: fin
84 character(len=max_string) :: fout
85 character(len=max_string) :: cfg_fout
86 logical :: fout_exists
87 type(fckit_mpi_comm) :: comm
88 character(len=10) :: cproc
90 character(len=max_string) :: MyObsType
91 character(len=255) :: record
93 integer,
allocatable :: dist_indx(:)
94 integer,
allocatable :: miss_indx(:)
99 type(random_distribution) :: ran_dist
101 integer :: input_file_type
104 integer :: rc, handle, num_pools, num_rows, num_cols
106 function setenv (envname, envval, overwrite) bind (c, name = "setenv")
107 use,
intrinsic :: iso_c_binding, only: &
110 character(kind=c_char) :: envname(*)
111 character(kind=c_char) :: envval(*)
112 integer(kind=c_int),
value :: overwrite
113 integer(kind=c_int) :: setenv
119 myobstype = trim(config_get_string(c_conf,
max_string,
"ObsType"))
121 if (config_element_exists(c_conf,
"ObsData.ObsDataIn"))
then 122 fin = config_get_string(c_conf,
max_string,
"ObsData.ObsDataIn.obsfile")
136 if (trim(myobstype) .eq.
"Radiance") nvars = 15
137 if (trim(myobstype) .eq.
"Aod") nvars = 11
139 select case (input_file_type)
142 call nc_diag_read_init(fin, iunit)
145 fvlen = nc_diag_read_get_dim(iunit,
'nlocs')
150 nlocs = ran_dist%nobs_pe()
151 allocate(dist_indx(nlocs))
152 dist_indx = ran_dist%indx
157 if ((trim(myobstype) .eq.
"Radiosonde") .or. &
158 (trim(myobstype) .eq.
"Aircraft"))
then 163 nlocs =
size(miss_indx)
164 deallocate(dist_indx)
165 allocate(dist_indx(nlocs))
166 dist_indx = miss_indx
170 deallocate(miss_indx)
179 call count_query_results (fin,
'select seqno from "' // trim(fin) //
'" where entryno = 1;', nobs)
182 allocate (dist_indx(nobs))
183 dist_indx(:) = [(/(n, n = 1,nobs)/)]
191 rc = setenv(
"ODB_SRCPATH_OOPS" // c_null_char, trim(fin) // c_null_char, 1_c_int)
192 rc = setenv(
"ODB_DATAPATH_OOPS" // c_null_char, trim(fin) // c_null_char, 1_c_int)
193 rc = setenv(
"IOASSIGN" // c_null_char, trim(fin) //
'/IOASSIGN' // c_null_char, 1_c_int)
194 handle = odb_open(
"OOPS",
"OLD", num_pools)
195 rc = odb_addview(handle,
"query", abort = .false.)
196 rc = odb_select(handle,
"query", num_rows, num_cols)
197 allocate (self % odb_data(num_rows,0:num_cols))
198 rc = odb_get(handle,
"query", self % odb_data, num_rows)
199 rc = odb_cancel(handle,
"query")
200 rc = odb_close(handle)
201 nobs =
size(self % odb_data,dim=1)
204 allocate (dist_indx(nobs))
205 dist_indx(:) = [(/(n, n = 1,nobs)/)]
217 allocate(dist_indx(1))
221 write(record,*)
'ioda_obsdb_setup_c: ', trim(myobstype),
' file in = ',trim(fin)
222 call fckit_log%info(record)
225 if (config_element_exists(c_conf,
"ObsData.ObsDataOut"))
then 226 cfg_fout = config_get_string(c_conf,
max_string,
"ObsData.ObsDataOut.obsfile")
233 comm = fckit_mpi_comm()
234 write(cproc,fmt=
'(i4.4)') comm%rank()
238 ppos = scan(trim(cfg_fout),
'.', back=.true.)
241 fout = cfg_fout(1:ppos-1) //
'_' // trim(adjustl(cproc)) // trim(cfg_fout(ppos:))
244 fout = trim(cfg_fout) //
'_' // trim(adjustl(cproc))
249 inquire(file=trim(fout), exist=fout_exists)
250 if (fout_exists)
then 251 write(record,*)
'ioda_obsdb_setup_c: WARNING: Overwriting output file: ', trim(fout)
252 call fckit_log%info(record)
261 call ioda_obsdb_setup(self, fvlen, nobs, dist_indx, nlocs, nvars, fin, fout, myobstype)
269 integer(c_int),
intent(inout) :: c_key_self
270 type(ioda_obsdb),
pointer :: self
280 subroutine ioda_obsdb_nobs_c(c_key_self, kobs) bind(c,name='ioda_obsdb_nobs_f90')
282 integer(c_int),
intent(in) :: c_key_self
283 integer(c_int),
intent(inout) :: kobs
284 type(ioda_obsdb),
pointer :: self
296 integer(c_int),
intent(in) :: c_key_self
297 integer(c_int),
intent(inout) :: klocs
298 type(ioda_obsdb),
pointer :: self
310 integer(c_int),
intent(in) :: c_key_self
311 type(c_ptr),
intent(in) :: c_t1, c_t2
312 integer(c_int),
intent(inout) :: c_key_locs
314 type(ioda_obsdb),
pointer :: self
315 type(datetime) :: t1, t2
316 type(ioda_locs),
pointer :: locs
319 call c_f_datetime(c_t1, t1)
320 call c_f_datetime(c_t2, t2)
332 subroutine ioda_obsdb_generate_c(c_key_self, c_conf, c_t1, c_t2) bind(c,name='ioda_obsdb_generate_f90')
334 integer(c_int),
intent(inout) :: c_key_self
335 type(c_ptr),
intent(in) :: c_conf
336 type(c_ptr),
intent(in) :: c_t1, c_t2
338 type(ioda_obsdb),
pointer :: self
339 type(datetime) :: t1, t2
342 integer,
allocatable :: dist_indx(:)
345 character(len=max_string) :: MyObsType
346 character(len=255) :: record
347 real :: lat, lon1, lon2
348 type(random_distribution) :: ran_dist
351 call c_f_datetime(c_t1, t1)
352 call c_f_datetime(c_t2, t2)
354 fvlen = config_get_int(c_conf,
"nobs")
355 lat = config_get_real(c_conf,
"lat")
356 lon1 = config_get_real(c_conf,
"lon1")
357 lon2 = config_get_real(c_conf,
"lon2")
362 nobs = ran_dist%nobs_pe()
363 allocate(dist_indx(nobs))
364 dist_indx = ran_dist%indx
373 myobstype = trim(config_get_string(c_conf,
max_string,
"ObsType"))
374 write(record,*)
'ioda_obsdb_generate_c: ', trim(myobstype)
375 call fckit_log%info(record)
377 call ioda_obsdb_generate(self, fvlen, nobs, dist_indx, nlocs, nvars, myobstype, lat, lon1, lon2)
379 deallocate(dist_indx)
385 subroutine ioda_obsdb_geti_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec) bind(c,name='ioda_obsdb_geti_f90')
387 integer(c_int),
intent(in) :: c_key_self
388 integer(c_int),
intent(in) :: c_name_size
389 character(kind=c_char,len=1),
intent(in) :: c_name(c_name_size+1)
390 integer(c_int),
intent(in) :: c_vec_size
391 integer(c_int),
intent(out) :: c_vec(c_vec_size)
393 type(ioda_obsdb),
pointer :: self
394 real(kind_real),
allocatable :: vdata(:)
396 character(len=c_name_size) :: vname
402 do jj = 1, c_name_size
403 vname(jj:jj) = c_name(jj)
406 allocate(vdata(c_vec_size))
409 c_vec(:) = nint(vdata(:), c_int)
416 subroutine ioda_obsdb_getd_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec) bind(c,name='ioda_obsdb_getd_f90')
418 integer(c_int),
intent(in) :: c_key_self
419 integer(c_int),
intent(in) :: c_name_size
420 character(kind=c_char,len=1),
intent(in) :: c_name(c_name_size+1)
421 integer(c_int),
intent(in) :: c_vec_size
422 real(c_double),
intent(out) :: c_vec(c_vec_size)
424 type(ioda_obsdb),
pointer :: self
425 real(kind_real),
allocatable :: vdata(:)
427 character(len=c_name_size) :: vname
433 do i = 1, c_name_size
434 vname(i:i) = c_name(i)
439 allocate(vdata(c_vec_size))
442 if (trim(vname) .eq.
"ObsErr")
then 443 c_vec = 1.0_kind_real / vdata
454 subroutine ioda_obsdb_puti_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec) bind(c,name='ioda_obsdb_puti_f90')
456 integer(c_int),
intent(in) :: c_key_self
457 integer(c_int),
intent(in) :: c_name_size
458 character(kind=c_char,len=1),
intent(in) :: c_name(c_name_size+1)
459 integer(c_int),
intent(in) :: c_vec_size
460 integer(c_int),
intent(in) :: c_vec(c_vec_size)
462 type(ioda_obsdb),
pointer :: self
463 real(kind_real),
allocatable :: vdata(:)
465 character(len=c_name_size) :: vname
471 do jj = 1, c_name_size
472 vname(jj:jj) = c_name(jj)
475 allocate(vdata(c_vec_size))
484 subroutine ioda_obsdb_putd_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec) bind(c,name='ioda_obsdb_putd_f90')
486 integer(c_int),
intent(in) :: c_key_self
487 integer(c_int),
intent(in) :: c_name_size
488 character(kind=c_char,len=1),
intent(in) :: c_name(c_name_size+1)
489 integer(c_int),
intent(in) :: c_vec_size
490 real(c_double),
intent(in) :: c_vec(c_vec_size)
492 type(ioda_obsdb),
pointer :: self
494 character(len=c_name_size) :: vname
500 do i = 1, c_name_size
501 vname(i:i) = c_name(i)
subroutine ioda_obsdb_generate_c(c_key_self, c_conf, c_t1, c_t2)
subroutine count_query_results(filename, query, num_results)
subroutine, public ioda_obsdb_setup(self, fvlen, nobs, dist_indx, nlocs, nvars, filename, fileout, obstype)
subroutine ioda_obsdb_nlocs_c(c_key_self, klocs)
subroutine ioda_obsdb_putd_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec)
subroutine ioda_obsdb_geti_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec)
integer, parameter max_string
subroutine ioda_obsdb_nobs_c(c_key_self, kobs)
subroutine ioda_obsdb_delete_c(c_key_self)
subroutine ioda_obsdb_getlocations_c(c_key_self, c_t1, c_t2, c_key_locs)
subroutine ioda_obsdb_getd_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec)
Fortran module handling radiosonde observation space.
Fortran module containing IODA utility programs.
type(registry_t), public ioda_locs_registry
Linked list interface - defines registry_t type.
subroutine, public ioda_obsdb_get_vec(self, vname, vdata)
type(registry_t), public ioda_obsdb_registry
Linked list interface - defines registry_t type.
integer function, public ioda_obsdb_get_ftype(fname)
subroutine, public ioda_obsdb_delete(self)
Fortran module with ODB API utility routines.
subroutine, public ioda_obsdb_getlocs(self, locs, t1, t2)
subroutine, public ioda_obsdb_put_vec(self, vname, vdata)
subroutine nc_diag_read_close(filename, file_ncdr_id, from_pop)
Fortran module handling observation locations.
Fortran module to handle radiosonde observations.
subroutine ioda_obsdb_setup_c(c_key_self, c_conf)
Linked list implementation.
subroutine ioda_obsdb_puti_c(c_key_self, c_name_size, c_name, c_vec_size, c_vec)
subroutine, public ioda_deselect_missing_values(ncid, vname, in_index, out_index)
subroutine, public ioda_obsdb_generate(self, fvlen, nobs, dist_indx, nlocs, nvars, obstype, lat, lon1, lon2)
subroutine nc_diag_read_init(filename, file_ncdr_id, from_push)