32 #define LISTED_TYPE oobump_type 35 #include "oops/util/linkedList_i.f" 45 #include "oops/util/linkedList_c.f" 51 subroutine create_oobump_c(key, idx, c_conf, ens1_ne, ens1_nsub, ens2_ne, ens2_nsub) bind(c, name='create_oobump_f90')
53 integer(c_int),
intent(inout) :: key
54 integer(c_int),
intent(in) :: idx
55 type(c_ptr),
intent(in) :: c_conf
56 integer,
intent(in) :: ens1_ne
57 integer,
intent(in) :: ens1_nsub
58 integer,
intent(in) :: ens2_ne
59 integer,
intent(in) :: ens2_nsub
61 type(oobump_type),
pointer :: self
62 type(unstructured_grid),
pointer :: ug
73 call create_oobump(self, ug, c_conf, ens1_ne, ens1_nsub, ens2_ne, ens2_nsub)
81 integer(c_int),
intent(inout) :: key
83 type(oobump_type),
pointer :: self
100 integer(c_int),
intent(in) :: key
101 integer(c_int),
intent(in) :: idx
102 integer,
intent(in) :: ie
103 integer,
intent(in) :: iens
105 type(oobump_type),
pointer :: self
106 type(unstructured_grid),
pointer :: ug
123 integer(c_int),
intent(in) :: key
125 type(oobump_type),
pointer :: self
139 integer(c_int),
intent(in) :: key
140 integer(c_int),
intent(in) :: idx
142 type(oobump_type),
pointer :: self
143 type(unstructured_grid),
pointer :: ug
160 integer(c_int),
intent(in) :: key
161 integer(c_int),
intent(in) :: idx
163 type(oobump_type),
pointer :: self
164 type(unstructured_grid),
pointer :: ug
181 integer(c_int),
intent(in) :: key
182 integer(c_int),
intent(in) :: idx
184 type(oobump_type),
pointer :: self
185 type(unstructured_grid),
pointer :: ug
202 integer(c_int),
intent(in) :: key
203 integer(c_int),
intent(in) :: idx
205 type(oobump_type),
pointer :: self
206 type(unstructured_grid),
pointer :: ug
223 integer(c_int),
intent(in) :: key
224 integer(c_int),
intent(in) :: idx
226 type(oobump_type),
pointer :: self
227 type(unstructured_grid),
pointer :: ug
244 integer(c_int),
intent(in) :: key
245 integer(c_int),
intent(out) :: n
247 type(oobump_type),
pointer :: self
261 integer(c_int),
intent(in) :: key
262 real(c_double),
intent(in) :: cv(:)
263 integer(c_int),
intent(in) :: idx
265 type(oobump_type),
pointer :: self
266 type(unstructured_grid),
pointer :: ug
283 integer(c_int),
intent(in) :: key
284 integer(c_int),
intent(in) :: idx
285 real(c_double),
intent(inout) :: cv(:)
287 type(oobump_type),
pointer :: self
288 type(unstructured_grid),
pointer :: ug
303 subroutine get_oobump_param_c(key, nstr, cstr, idx) bind(c, name='get_oobump_param_f90')
305 integer(c_int),
intent(in) :: key
306 integer(c_int),
intent(in) :: nstr
307 character(kind=c_char),
intent(in) :: cstr(nstr)
308 integer(c_int),
intent(in) :: idx
310 type(oobump_type),
pointer :: self
311 type(unstructured_grid),
pointer :: ug
313 character(len=nstr) :: param
324 param = trim(param)//cstr(istr)
334 subroutine set_oobump_param_c(key, nstr, cstr, idx) bind(c, name='set_oobump_param_f90')
336 integer(c_int),
intent(in) :: key
337 integer(c_int),
intent(in) :: nstr
338 character(kind=c_char),
intent(in) :: cstr(nstr)
339 integer(c_int),
intent(in) :: idx
341 type(oobump_type),
pointer :: self
342 type(unstructured_grid),
pointer :: ug
344 character(len=nstr) :: param
355 param = trim(param)//cstr(istr)
367 subroutine create_oobump(self, ug, c_conf, ens1_ne, ens1_nsub, ens2_ne, ens2_nsub)
372 type(c_ptr),
intent(in) :: c_conf
373 integer,
intent(in) :: ens1_ne
374 integer,
intent(in) :: ens1_nsub
375 integer,
intent(in) :: ens2_ne
376 integer,
intent(in) :: ens2_nsub
381 self%ngrid = ug%ngrid
382 allocate(self%bump(self%ngrid))
384 do igrid=1,self%ngrid
386 call self%bump(igrid)%nam%init
392 call self%bump(igrid)%setup_online(ug%grid(igrid)%nmga,ug%grid(igrid)%nl0,ug%grid(igrid)%nv,ug%grid(igrid)%nts, &
393 & ug%grid(igrid)%lon,ug%grid(igrid)%lat,ug%grid(igrid)%area,ug%grid(igrid)%vunit,ug%grid(igrid)%lmask,ens1_ne=ens1_ne, &
394 & ens1_nsub=ens1_nsub, ens2_ne=ens2_ne, ens2_nsub=ens2_nsub)
403 type(c_ptr),
intent(in) :: c_conf
405 integer :: iscales,ildwh,ildwv,idir,iv
406 character(len=3) :: iscaleschar,ildwvchar,idirchar,ivchar
407 character(len=6) :: ildwhchar
412 if (config_element_exists(c_conf,
"datadir")) bump%nam%datadir = config_get_string(c_conf,1024,
"datadir")
413 if (config_element_exists(c_conf,
"prefix")) bump%nam%prefix = config_get_string(c_conf,1024,
"prefix")
414 if (config_element_exists(c_conf,
"default_seed")) bump%nam%default_seed =
integer_to_logical(config_get_int(c_conf,
"default_seed"))
417 if (config_element_exists(c_conf,
"method")) bump%nam%method = config_get_string(c_conf,1024,
"method")
418 if (config_element_exists(c_conf,
"strategy")) bump%nam%strategy = config_get_string(c_conf,1024,
"strategy")
419 if (config_element_exists(c_conf,
"new_vbal")) bump%nam%new_vbal =
integer_to_logical(config_get_int(c_conf,
"new_vbal"))
420 if (config_element_exists(c_conf,
"load_vbal")) bump%nam%load_vbal =
integer_to_logical(config_get_int(c_conf,
"load_vbal"))
421 if (config_element_exists(c_conf,
"new_hdiag")) bump%nam%new_hdiag =
integer_to_logical(config_get_int(c_conf,
"new_hdiag"))
422 if (config_element_exists(c_conf,
"new_lct")) bump%nam%new_lct =
integer_to_logical(config_get_int(c_conf,
"new_lct"))
423 if (config_element_exists(c_conf,
"load_cmat")) bump%nam%load_cmat =
integer_to_logical(config_get_int(c_conf,
"load_cmat"))
424 if (config_element_exists(c_conf,
"new_nicas")) bump%nam%new_nicas =
integer_to_logical(config_get_int(c_conf,
"new_nicas"))
425 if (config_element_exists(c_conf,
"load_nicas")) bump%nam%load_nicas =
integer_to_logical(config_get_int(c_conf,
"load_nicas"))
426 if (config_element_exists(c_conf,
"new_obsop")) bump%nam%new_obsop =
integer_to_logical(config_get_int(c_conf,
"new_obsop"))
427 if (config_element_exists(c_conf,
"load_obsop")) bump%nam%load_obsop =
integer_to_logical(config_get_int(c_conf,
"load_obsop"))
428 if (config_element_exists(c_conf,
"check_adjoints")) &
429 & bump%nam%check_adjoints =
integer_to_logical(config_get_int(c_conf,
"check_adjoints"))
430 if (config_element_exists(c_conf,
"check_pos_def")) &
432 if (config_element_exists(c_conf,
"check_sqrt")) bump%nam%check_sqrt =
integer_to_logical(config_get_int(c_conf,
"check_sqrt"))
433 if (config_element_exists(c_conf,
"check_dirac")) bump%nam%check_dirac =
integer_to_logical(config_get_int(c_conf,
"check_dirac"))
434 if (config_element_exists(c_conf,
"check_randomization")) &
435 & bump%nam%check_randomization =
integer_to_logical(config_get_int(c_conf,
"check_randomization"))
436 if (config_element_exists(c_conf,
"check_consistency")) &
437 & bump%nam%check_consistency =
integer_to_logical(config_get_int(c_conf,
"check_consistency"))
438 if (config_element_exists(c_conf,
"check_optimality")) &
439 & bump%nam%check_optimality =
integer_to_logical(config_get_int(c_conf,
"check_optimality"))
440 if (config_element_exists(c_conf,
"check_obsop")) &
444 if (config_element_exists(c_conf,
"sam_read")) bump%nam%sam_read =
integer_to_logical(config_get_int(c_conf,
"sam_read"))
445 if (config_element_exists(c_conf,
"sam_write")) bump%nam%sam_write =
integer_to_logical(config_get_int(c_conf,
"sam_write"))
446 if (config_element_exists(c_conf,
"mask_type")) bump%nam%mask_type = config_get_string(c_conf,1024,
"mask_type")
447 if (config_element_exists(c_conf,
"mask_th")) bump%nam%mask_th = config_get_real(c_conf,
"mask_th")
448 if (config_element_exists(c_conf,
"mask_check")) bump%nam%mask_check =
integer_to_logical(config_get_int(c_conf,
"mask_check"))
449 if (config_element_exists(c_conf,
"draw_type")) bump%nam%draw_type = config_get_string(c_conf,1024,
"draw_type")
450 if (config_element_exists(c_conf,
"nc1")) bump%nam%nc1 = config_get_int(c_conf,
"nc1")
451 if (config_element_exists(c_conf,
"nc2")) bump%nam%nc2 = config_get_int(c_conf,
"nc2")
452 if (config_element_exists(c_conf,
"ntry")) bump%nam%ntry = config_get_int(c_conf,
"ntry")
453 if (config_element_exists(c_conf,
"nrep")) bump%nam%nrep = config_get_int(c_conf,
"nrep")
454 if (config_element_exists(c_conf,
"nc3")) bump%nam%nc3 = config_get_int(c_conf,
"nc3")
455 if (config_element_exists(c_conf,
"dc")) bump%nam%dc = config_get_real(c_conf,
"dc")
456 if (config_element_exists(c_conf,
"nl0r")) bump%nam%nl0r = config_get_int(c_conf,
"nl0r")
459 if (config_element_exists(c_conf,
"ne")) bump%nam%ne = config_get_int(c_conf,
"ne")
460 if (config_element_exists(c_conf,
"gau_approx")) bump%nam%gau_approx =
integer_to_logical(config_get_int(c_conf,
"gau_approx"))
462 write(ivchar,
'(i3)') iv
463 if (config_element_exists(c_conf,
"vbal_block("//trim(adjustl(ivchar))//
")")) &
464 & bump%nam%vbal_block(iv) =
integer_to_logical(config_get_int(c_conf,
"vbal_block("//trim(adjustl(ivchar))//
")"))
466 if (config_element_exists(c_conf,
"vbal_rad")) bump%nam%vbal_rad = config_get_real(c_conf,
"vbal_rad")
467 if (config_element_exists(c_conf,
"var_diag")) bump%nam%var_diag =
integer_to_logical(config_get_int(c_conf,
"var_diag"))
468 if (config_element_exists(c_conf,
"var_filter")) bump%nam%var_filter =
integer_to_logical(config_get_int(c_conf,
"var_filter"))
469 if (config_element_exists(c_conf,
"var_full")) bump%nam%var_full =
integer_to_logical(config_get_int(c_conf,
"var_full"))
470 if (config_element_exists(c_conf,
"var_niter")) bump%nam%var_niter = config_get_int(c_conf,
"var_niter")
471 if (config_element_exists(c_conf,
"var_rhflt")) bump%nam%var_rhflt = config_get_real(c_conf,
"var_rhflt")
472 if (config_element_exists(c_conf,
"local_diag")) bump%nam%local_diag =
integer_to_logical(config_get_int(c_conf,
"local_diag"))
473 if (config_element_exists(c_conf,
"local_rad")) bump%nam%local_rad = config_get_real(c_conf,
"local_rad")
474 if (config_element_exists(c_conf,
"displ_diag")) bump%nam%displ_diag =
integer_to_logical(config_get_int(c_conf,
"displ_diag"))
475 if (config_element_exists(c_conf,
"displ_rad")) bump%nam%displ_rad = config_get_real(c_conf,
"displ_rad")
476 if (config_element_exists(c_conf,
"displ_niter")) bump%nam%displ_niter = config_get_int(c_conf,
"displ_niter")
477 if (config_element_exists(c_conf,
"displ_rhflt")) bump%nam%displ_rhflt = config_get_real(c_conf,
"displ_rhflt")
478 if (config_element_exists(c_conf,
"displ_tol")) bump%nam%displ_tol = config_get_real(c_conf,
"displ_tol")
481 if (config_element_exists(c_conf,
"minim_algo")) bump%nam%minim_algo = config_get_string(c_conf,1024,
"minim_algo")
483 write(ivchar,
'(i3)') iv
484 if (config_element_exists(c_conf,
"double_fit("//trim(adjustl(ivchar))//
")")) &
485 & bump%nam%double_fit(iv) =
integer_to_logical(config_get_int(c_conf,
"double_fit("//trim(adjustl(ivchar))//
")"))
487 if (config_element_exists(c_conf,
"lhomh")) bump%nam%lhomh =
integer_to_logical(config_get_int(c_conf,
"lhomh"))
488 if (config_element_exists(c_conf,
"lhomv")) bump%nam%lhomv =
integer_to_logical(config_get_int(c_conf,
"lhomv"))
489 if (config_element_exists(c_conf,
"rvflt")) bump%nam%rvflt = config_get_real(c_conf,
"rvflt")
490 if (config_element_exists(c_conf,
"lct_nscales")) bump%nam%lct_nscales = config_get_int(c_conf,
"lct_nscales")
492 write(iscaleschar,
'(i3)') iscales
493 if (config_element_exists(c_conf,
"lct_diag("//trim(adjustl(iscaleschar))//
")")) &
494 & bump%nam%lct_diag(iscales) =
integer_to_logical(config_get_int(c_conf,
"lct_diag("//trim(adjustl(iscaleschar))//
")"))
498 if (config_element_exists(c_conf,
"lsqrt")) bump%nam%lsqrt =
integer_to_logical(config_get_int(c_conf,
"lsqrt"))
499 if (config_element_exists(c_conf,
"resol")) bump%nam%resol = config_get_real(c_conf,
"resol")
500 if (config_element_exists(c_conf,
"fast_sampling")) bump%nam%fast_sampling =
integer_to_logical(config_get_int(c_conf, &
502 if (config_element_exists(c_conf,
"nicas_interp")) bump%nam%nicas_interp = config_get_string(c_conf,1024,
"nicas_interp")
503 if (config_element_exists(c_conf,
"network")) bump%nam%network =
integer_to_logical(config_get_int(c_conf,
"network"))
504 if (config_element_exists(c_conf,
"mpicom")) bump%nam%mpicom = config_get_int(c_conf,
"mpicom")
505 if (config_element_exists(c_conf,
"advmode")) bump%nam%advmode = config_get_int(c_conf,
"advmode")
506 if (config_element_exists(c_conf,
"forced_radii")) bump%nam%forced_radii =
integer_to_logical(config_get_int(c_conf,
"forced_radii"))
507 if (config_element_exists(c_conf,
"rh")) bump%nam%rh = config_get_real(c_conf,
"rh")
508 if (config_element_exists(c_conf,
"rv")) bump%nam%rv = config_get_real(c_conf,
"rv")
509 if (config_element_exists(c_conf,
"ndir")) bump%nam%ndir = config_get_int(c_conf,
"ndir")
511 write(idirchar,
'(i3)') idir
512 if (config_element_exists(c_conf,
"londir("//trim(adjustl(idirchar))//
")")) &
513 & bump%nam%londir(idir) = config_get_real(c_conf,
"londir("//trim(adjustl(idirchar))//
")")
514 if (config_element_exists(c_conf,
"latdir("//trim(adjustl(idirchar))//
")")) &
515 & bump%nam%latdir(idir) = config_get_real(c_conf,
"latdir("//trim(adjustl(idirchar))//
")")
516 if (config_element_exists(c_conf,
"levdir("//trim(adjustl(idirchar))//
")")) &
517 & bump%nam%levdir(idir) = config_get_int(c_conf,
"levdir("//trim(adjustl(idirchar))//
")")
518 if (config_element_exists(c_conf,
"ivdir("//trim(adjustl(idirchar))//
")")) &
519 & bump%nam%ivdir(idir) = config_get_int(c_conf,
"ivdir("//trim(adjustl(idirchar))//
")")
520 if (config_element_exists(c_conf,
"itsdir("//trim(adjustl(idirchar))//
")")) &
521 & bump%nam%itsdir(idir) = config_get_int(c_conf,
"itsdir("//trim(adjustl(idirchar))//
")")
525 if (config_element_exists(c_conf,
"nldwh")) bump%nam%nldwh = config_get_int(c_conf,
"nldwh")
527 write(ildwhchar,
'(i6)') ildwh
528 if (config_element_exists(c_conf,
"il_ldwh("//trim(adjustl(ildwhchar))//
")")) &
529 & bump%nam%il_ldwh(ildwh) = config_get_int(c_conf,
"il_ldwh("//trim(adjustl(ildwhchar))//
")")
530 if (config_element_exists(c_conf,
"ic_ldwh("//trim(adjustl(ildwhchar))//
")")) &
531 & bump%nam%ic_ldwh(ildwh) = config_get_int(c_conf,
"ic_ldwh("//trim(adjustl(ildwhchar))//
")")
533 if (config_element_exists(c_conf,
"nldwv")) bump%nam%nldwv = config_get_int(c_conf,
"nldwv")
535 write(ildwvchar,
'(i3)') ildwv
536 if (config_element_exists(c_conf,
"lon_ldwv("//trim(adjustl(ildwvchar))//
")")) &
537 & bump%nam%lon_ldwv(ildwv) = config_get_real(c_conf,
"lon_ldwv("//trim(adjustl(ildwvchar))//
")")
538 if (config_element_exists(c_conf,
"lat_ldwv("//trim(adjustl(ildwvchar))//
")")) &
539 & bump%nam%lat_ldwv(ildwv) = config_get_real(c_conf,
"lat_ldwv("//trim(adjustl(ildwvchar))//
")")
541 if (config_element_exists(c_conf,
"diag_rhflt")) bump%nam%diag_rhflt = config_get_real(c_conf,
"diag_rhflt")
542 if (config_element_exists(c_conf,
"diag_interp")) bump%nam%diag_interp = config_get_string(c_conf,1024,
"diag_interp")
543 if (config_element_exists(c_conf,
"field_io")) bump%nam%field_io =
integer_to_logical(config_get_int(c_conf,
"field_io"))
544 if (config_element_exists(c_conf,
"split_io")) bump%nam%split_io =
integer_to_logical(config_get_int(c_conf,
"split_io"))
545 if (config_element_exists(c_conf,
"grid_output")) bump%nam%grid_output =
integer_to_logical(config_get_int(c_conf,
"grid_output"))
546 if (config_element_exists(c_conf,
"grid_resol")) bump%nam%grid_resol = config_get_real(c_conf,
"grid_resol")
547 if (config_element_exists(c_conf,
"grid_interp")) bump%nam%grid_interp = config_get_string(c_conf,1024,
"grid_interp")
555 integer,
intent(in) :: i
562 call abor1_ftn(
'wrong integer in integer_to_logical')
575 if (
allocated(self%bump))
then 576 do igrid=1,self%ngrid
577 call self%bump(igrid)%dealloc
579 deallocate(self%bump)
590 integer,
intent(in) :: ie
591 integer,
intent(in) :: iens
595 do igrid=1,self%ngrid
596 call self%bump(igrid)%add_member(ug%grid(igrid)%fld,ie,iens)
609 do igrid=1,self%ngrid
610 call self%bump(igrid)%run_drivers
624 do igrid=1,self%ngrid
625 call self%bump(igrid)%apply_vbal(ug%grid(igrid)%fld)
639 do igrid=1,self%ngrid
640 call self%bump(igrid)%apply_vbal_inv(ug%grid(igrid)%fld)
654 do igrid=1,self%ngrid
655 call self%bump(igrid)%apply_vbal_ad(ug%grid(igrid)%fld)
669 do igrid=1,self%ngrid
670 call self%bump(igrid)%apply_vbal_inv_ad(ug%grid(igrid)%fld)
684 do igrid=1,self%ngrid
685 call self%bump(igrid)%apply_nicas(ug%grid(igrid)%fld)
695 integer,
intent(out) :: n
700 do igrid=1,self%ngrid
701 call self%bump(igrid)%get_cv_size(nn)
712 real(kind_real),
intent(in) :: cv(:)
714 integer :: offset,igrid,nn
719 do igrid=1,self%ngrid
721 call self%bump(igrid)%get_cv_size(nn)
724 call self%bump(igrid)%apply_nicas_sqrt(cv(offset+1:offset+nn), ug%grid(igrid)%fld)
738 real(kind_real),
intent(inout) :: cv(:)
739 integer :: offset,igrid,nn
744 do igrid=1,self%ngrid
746 call self%bump(igrid)%get_cv_size(nn)
749 call self%bump(igrid)%apply_nicas_sqrt_ad(ug%grid(igrid)%fld, cv(offset+1:offset+nn))
761 type(oobump_type),
intent(in) :: self
762 character(len=*),
intent(in) :: param
763 type(unstructured_grid),
intent(inout) :: ug
767 do igrid=1,self%ngrid
768 call self%bump(igrid)%get_parameter(param,ug%grid(igrid)%fld)
777 type(oobump_type),
intent(inout) :: self
778 character(len=*),
intent(in) :: param
779 type(unstructured_grid),
intent(in) :: ug
783 do igrid=1,self%ngrid
784 call self%bump(igrid)%set_parameter(param,ug%grid(igrid)%fld)
subroutine multiply_oobump_vbal_ad_c(key, idx)
subroutine, public multiply_oobump_vbal_ad(self, ug)
subroutine add_oobump_member_c(key, idx, ie, iens)
subroutine, public multiply_oobump_nicas_sqrt_ad(self, ug, cv)
subroutine, public multiply_oobump_nicas(self, ug)
subroutine get_oobump_param(self, param, ug)
type(registry_t) oobump_registry
Linked list interface - defines registry_t type.
Fortran module for handling generic BUMP.
subroutine, public add_oobump_member(self, ug, ie, iens)
subroutine, public run_oobump_drivers(self)
subroutine delete_oobump_c(key)
subroutine, public multiply_oobump_nicas_sqrt(self, cv, ug)
subroutine multiply_oobump_nicas_sqrt_ad_c(key, idx, cv)
subroutine multiply_oobump_nicas_sqrt_c(key, cv, idx)
integer, parameter, public nlmax
subroutine, public create_oobump(self, ug, c_conf, ens1_ne, ens1_nsub, ens2_ne, ens2_nsub)
integer, parameter, public nldwvmax
subroutine set_oobump_param(self, param, ug)
subroutine run_oobump_drivers_c(key)
subroutine, public multiply_oobump_vbal_inv_ad(self, ug)
logical function integer_to_logical(i)
subroutine create_oobump_c(key, idx, c_conf, ens1_ne, ens1_nsub, ens2_ne, ens2_nsub)
Linked list implementation.
subroutine get_oobump_cv_size_c(key, n)
subroutine, public get_oobump_cv_size(self, n)
subroutine, public multiply_oobump_vbal(self, ug)
type(registry_t), public unstructured_grid_registry
Linked list interface - defines registry_t type.
integer, parameter, public nc3max
subroutine, public delete_oobump(self)
subroutine set_oobump_param_c(key, nstr, cstr, idx)
integer, parameter, public nvmax
integer, parameter, public ndirmax
integer, parameter, public nscalesmax
subroutine get_oobump_param_c(key, nstr, cstr, idx)
subroutine multiply_oobump_vbal_c(key, idx)
subroutine multiply_oobump_vbal_inv_ad_c(key, idx)
subroutine multiply_oobump_vbal_inv_c(key, idx)
Fortran module for handling generic unstructured grid.
subroutine, public bump_read_conf(c_conf, bump)
subroutine multiply_oobump_nicas_c(key, idx)
subroutine, public multiply_oobump_vbal_inv(self, ug)