Skip to content

Commit

Permalink
Fixes the failures associated with oops ObsVariables introduction (#207)
Browse files Browse the repository at this point in the history
Code now compiling
  • Loading branch information
mikecooke77 authored May 20, 2024
1 parent bcd0f03 commit f8e68f6
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/opsinputs/CxWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ioda/ObsDataVector.h"
#include "ioda/ObsSpace.h"
#include "ioda/ObsVector.h"
#include "oops/base/Variables.h"
#include "oops/util/Logger.h"
#include "opsinputs/CxWriterParameters.h"
#include "opsinputs/LocalEnvironment.h"
Expand Down Expand Up @@ -93,7 +92,7 @@ void CxWriter::postFilter(const ufo::GeoVaLs & gv,
ufo::Variables filtervars;
for (const ufo::Variable &var : parameters_.variables_for_qc.value().get())
filtervars += var;
ioda::ObsDataVector<int> flags(obsdb_, filtervars.toOopsVariables());
ioda::ObsDataVector<int> flags(obsdb_, filtervars.toOopsObsVariables());
for (int ivar = 0; ivar < flags.nvars(); ivar++) {
const std::string varname = flags.varnames()[ivar];
flags[varname] = flags_->operator[](varname);
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/CxWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string>

#include "ioda/ObsDataVector.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "oops/interface/ObsFilterBase.h"
#include "oops/util/ObjectCounter.h"
Expand Down Expand Up @@ -64,7 +65,7 @@ class CxWriter : public oops::interface::ObsFilterBase<ufo::ObsTraits>,
void checkFilterData(const oops::FilterStage filterStage) override {}

oops::Variables requiredVars() const override {return geovars_;}
oops::Variables requiredHdiagnostics() const override {return extradiagvars_;}
oops::ObsVariables requiredHdiagnostics() const override {return extradiagvars_;}

private:
void print(std::ostream &) const override;
Expand All @@ -77,7 +78,7 @@ class CxWriter : public oops::interface::ObsFilterBase<ufo::ObsTraits>,

ioda::ObsSpace & obsdb_;
oops::Variables geovars_;
oops::Variables extradiagvars_;
oops::ObsVariables extradiagvars_;
std::shared_ptr<ioda::ObsDataVector<int>> flags_;
std::shared_ptr<ioda::ObsDataVector<float>> obsErrors_;

Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/CxWriter.interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module opsinputs_cxwriter_mod_c
c_bool, &
c_int, &
c_ptr
use obs_variables_mod, only: obs_variables
use oops_variables_mod, only: oops_variables
use opsinputs_cxwriter_mod, only: &
opsinputs_cxwriter, &
Expand Down Expand Up @@ -112,13 +113,13 @@ subroutine opsinputs_cxwriter_post_c(c_self, c_obspace, c_geovals, c_flags, &

type(opsinputs_cxwriter), pointer :: self
type(ufo_geovals), pointer :: geovals
type(oops_variables) :: f_varnames
type(obs_variables) :: f_varnames

call opsinputs_cxwriter_registry%get(c_self, self)
call ufo_geovals_registry%get(c_geovals, geovals)

! Obtain simulated variable names.
f_varnames = oops_variables(c_varnames)
f_varnames = obs_variables(c_varnames)

call opsinputs_cxwriter_post(self, c_obspace, geovals, c_flags, &
f_varnames, c_hofx)
Expand Down
3 changes: 2 additions & 1 deletion src/opsinputs/CxWriter.interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define OPSINPUTS_CXWRITER_INTERFACE_H_

#include "ioda/ObsSpace.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "ufo/Fortran.h"

Expand Down Expand Up @@ -37,7 +38,7 @@ extern "C" {
const ufo::F90goms &,
const ioda::ObsDataVector<int> &flags,
const int &nvars, const int &nlocs,
const oops::Variables &varnames, const double *hofx);
const oops::ObsVariables &varnames, const double *hofx);
} // extern C

} // namespace opsinputs
Expand Down
3 changes: 1 addition & 2 deletions src/opsinputs/VarObsWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "ioda/ObsDataVector.h"
#include "ioda/ObsSpace.h"
#include "ioda/ObsVector.h"
#include "oops/base/Variables.h"
#include "oops/mpi/mpi.h"
#include "oops/util/IntSetParser.h"
#include "oops/util/Logger.h"
Expand Down Expand Up @@ -121,7 +120,7 @@ void VarObsWriter::postFilter(const ufo::GeoVaLs & gv,
ufo::Variables filtervars;
for (const ufo::Variable &var : parameters_.variables_for_qc.value().get())
filtervars += var;
ioda::ObsDataVector<int> flags(obsdb_, filtervars.toOopsVariables());
ioda::ObsDataVector<int> flags(obsdb_, filtervars.toOopsObsVariables());
for (int ivar = 0; ivar < flags.nvars(); ivar++) {
std::string varname = flags.varnames()[ivar];
flags[varname] = flags_->operator[](varname);
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/VarObsWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>

#include "ioda/ObsDataVector.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "oops/interface/ObsFilterBase.h"
#include "oops/util/ObjectCounter.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ class VarObsWriter : public oops::interface::ObsFilterBase<ufo::ObsTraits>,
void checkFilterData(const oops::FilterStage filterStage) override {}

oops::Variables requiredVars() const override {return geovars_;}
oops::Variables requiredHdiagnostics() const override {return extradiagvars_;}
oops::ObsVariables requiredHdiagnostics() const override {return extradiagvars_;}

private:
void print(std::ostream &) const override;
Expand All @@ -86,7 +87,7 @@ class VarObsWriter : public oops::interface::ObsFilterBase<ufo::ObsTraits>,

ioda::ObsSpace & obsdb_;
oops::Variables geovars_;
oops::Variables extradiagvars_;
oops::ObsVariables extradiagvars_;
std::shared_ptr<ioda::ObsDataVector<int>> flags_;
std::shared_ptr<ioda::ObsDataVector<float>> obsErrors_;
std::vector<int> varchannels_;
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/VarObsWriter.interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function opsinputs_varobswriter_create_c(c_self, c_conf, c_comm_is_valid, c_comm
c_varlist, c_varlist_diags) &
bind(c,name='opsinputs_varobswriter_create_f90')
use oops_variables_mod
use obs_variables_mod
implicit none
integer(c_int), intent(inout) :: c_self
type(c_ptr), value, intent(in) :: c_conf
Expand All @@ -61,14 +62,14 @@ function opsinputs_varobswriter_create_c(c_self, c_conf, c_comm_is_valid, c_comm
type(fckit_configuration) :: f_conf
integer(gc_int_kind) :: f_comm
type(oops_variables) :: f_varlist
type(oops_variables) :: f_varlist_diags
type(obs_variables) :: f_varlist_diags

call opsinputs_varobswriter_registry%setup(c_self, self)

f_conf = fckit_configuration(c_conf)
f_comm = c_comm
f_varlist = oops_variables(c_varlist)
f_varlist_diags = oops_variables(c_varlist_diags)
f_varlist_diags = obs_variables(c_varlist_diags)
if (opsinputs_varobswriter_create(self, f_conf, c_comm_is_valid, f_comm, c_channels, &
f_varlist, f_varlist_diags)) then
opsinputs_varobswriter_create_c = 1
Expand Down
3 changes: 2 additions & 1 deletion src/opsinputs/VarObsWriter.interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <mpi.h>

#include "ioda/ObsSpace.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "ufo/Fortran.h"

Expand All @@ -34,7 +35,7 @@ extern "C" {
const MPI_Fint &comm,
const int &nchannels,
const int *channels,
oops::Variables &, oops::Variables &);
oops::Variables &, oops::ObsVariables &);
void opsinputs_varobswriter_delete_f90(F90check &);
void opsinputs_varobswriter_prior_f90(const F90check &, const ioda::ObsSpace &,
const ufo::F90goms &);
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/opsinputs_cxwriter_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module opsinputs_cxwriter_mod
use obsspace_mod, only: &
obsspace_get_db, &
obsspace_get_nlocs
use obs_variables_mod, only: obs_variables
use oops_variables_mod, only: oops_variables
use opsinputs_cxfields_mod
use opsinputs_fill_mod, only: &
Expand Down Expand Up @@ -173,7 +174,7 @@ module opsinputs_cxwriter_mod

type(ufo_geovals), pointer :: GeoVals
type(opsinputs_jeditoopslayoutmapping) :: JediToOpsLayoutMapping
type(oops_variables) :: varnames
type(obs_variables) :: varnames
real(c_double), pointer :: hofx(:, :)
end type opsinputs_cxwriter

Expand Down Expand Up @@ -501,7 +502,7 @@ subroutine opsinputs_cxwriter_post(self, ObsSpace, GeoVals, Flags, varnames, hof
type(c_ptr), value, intent(in) :: ObsSpace
type(ufo_geovals), intent(in), pointer :: GeoVals
type(c_ptr), value, intent(in) :: Flags
type(oops_variables), intent(in) :: varnames
type(obs_variables), intent(in) :: varnames
real(c_double), intent(in), target :: hofx(:, :)

! Local declarations:
Expand Down
3 changes: 2 additions & 1 deletion src/opsinputs/opsinputs_fill_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module opsinputs_fill_mod
use obsspace_mod, only: &
obsspace_has, &
obsspace_get_db
use obs_variables_mod, only: obs_variables
use oops_variables_mod, only: oops_variables
use ufo_geovals_mod, only: &
ufo_geoval, &
Expand Down Expand Up @@ -1487,7 +1488,7 @@ subroutine opsinputs_fill_fillreal2dfromgeovalorhofx( &
character(len=*), intent(in) :: JediVarName
type(opsinputs_jeditoopslayoutmapping), intent(in) :: JediToOpsLayoutMapping
real(c_double), intent(in) :: hofx(:, :)
type(oops_variables), intent(in) :: varnames
type(obs_variables), intent(in) :: varnames
character(len=*), intent(in), optional :: JediObsName
logical, intent(in), optional :: WriteHofXIntoCX

Expand Down
6 changes: 3 additions & 3 deletions src/opsinputs/opsinputs_obsdatavector_f.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int opsinputs_obsdatavector_nlocs_f(const ioda::ObsDataVector<T> &vec) {
}

template <typename T>
const oops::Variables * opsinputs_obsdatavector_varnames_f(
const oops::ObsVariables * opsinputs_obsdatavector_varnames_f(
const ioda::ObsDataVector<T> &vec) {
return &vec.varnames();
}
Expand All @@ -50,7 +50,7 @@ int opsinputs_obsdatavector_int_nlocs_f(const ioda::ObsDataVector<int> &vec) {
return opsinputs_obsdatavector_nlocs_f(vec);
}

const oops::Variables * opsinputs_obsdatavector_int_varnames_f(
const oops::ObsVariables * opsinputs_obsdatavector_int_varnames_f(
const ioda::ObsDataVector<int> &vec) {
return opsinputs_obsdatavector_varnames_f(vec);
}
Expand All @@ -70,7 +70,7 @@ int opsinputs_obsdatavector_float_nlocs_f(const ioda::ObsDataVector<float> &vec)
return opsinputs_obsdatavector_nlocs_f(vec);
}

const oops::Variables * opsinputs_obsdatavector_float_varnames_f(
const oops::ObsVariables * opsinputs_obsdatavector_float_varnames_f(
const ioda::ObsDataVector<float> &vec) {
return opsinputs_obsdatavector_varnames_f(vec);
}
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/opsinputs_obsdatavector_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ namespace ioda {
} // namespace ioda

namespace oops {
class ObsVariables;
class Variables;
} // namespace oops

namespace opsinputs {

extern "C" {
int opsinputs_obsdatavector_int_nlocs_f(const ioda::ObsDataVector<int> &vec);
const oops::Variables * opsinputs_obsdatavector_int_varnames_f(
const oops::ObsVariables * opsinputs_obsdatavector_int_varnames_f(
const ioda::ObsDataVector<int> &vec);
bool opsinputs_obsdatavector_int_has_f(const ioda::ObsDataVector<int> &vec,
const char *variable);
Expand All @@ -31,7 +32,7 @@ extern "C" {
const size_t &length, int* data);

int opsinputs_obsdatavector_float_nlocs_f(const ioda::ObsDataVector<float> &vec);
const oops::Variables * opsinputs_obsdatavector_float_varnames_f(
const oops::ObsVariables * opsinputs_obsdatavector_float_varnames_f(
const ioda::ObsDataVector<float> &vec);
bool opsinputs_obsdatavector_float_has_f(const ioda::ObsDataVector<float> &vec,
const char *variable);
Expand Down
5 changes: 3 additions & 2 deletions src/opsinputs/opsinputs_varobswriter_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module opsinputs_varobswriter_mod
obsspace_get_gnlocs, &
obsspace_get_nlocs, &
obsspace_has
use obs_variables_mod, only: obs_variables
use oops_variables_mod, only: oops_variables
use opsinputs_fill_mod, only: &
opsinputs_fill_fillcoord2d, &
Expand Down Expand Up @@ -219,7 +220,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe
integer(gc_int_kind), intent(in) :: comm
integer(c_int), intent(in) :: channels(:)
type(oops_variables), intent(inout) :: geovars ! GeoVaLs required by the VarObsWriter.
type(oops_variables), intent(inout) :: diagvars ! HofXDiags required by the VarObsWriter.
type(obs_variables), intent(inout) :: diagvars ! HofXDiags required by the VarObsWriter.
logical :: opsinputs_varobswriter_create

! Local declarations:
Expand Down Expand Up @@ -622,7 +623,7 @@ subroutine opsinputs_varobswriter_addrequireddiagvars(self, diagvars)

! Subroutine arguments:
type(opsinputs_varobswriter), intent(in) :: self
type(oops_variables), intent(inout) :: diagvars
type(obs_variables), intent(inout) :: diagvars

! Local declarations:
integer(integer64) :: VarFields(ActualMaxVarfield)
Expand Down
5 changes: 3 additions & 2 deletions test/opsinputs/CxChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "../opsinputs/CxCheckerParameters.h"
#include "ioda/ObsDataVector.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "oops/interface/ObsFilterBase.h"
#include "oops/util/ObjectCounter.h"
Expand Down Expand Up @@ -70,7 +71,7 @@ class CxChecker : public oops::interface::ObsFilterBase<ufo::ObsTraits>,
void checkFilterData(const oops::FilterStage filterStage) override {}

oops::Variables requiredVars() const override {return geovars_;}
oops::Variables requiredHdiagnostics() const override {return extradiagvars_;}
oops::ObsVariables requiredHdiagnostics() const override {return extradiagvars_;}

private:
struct PrintCxFileOutput;
Expand All @@ -94,7 +95,7 @@ class CxChecker : public oops::interface::ObsFilterBase<ufo::ObsTraits>,

ioda::ObsSpace & obsdb_;
oops::Variables geovars_;
oops::Variables extradiagvars_;
oops::ObsVariables extradiagvars_;
std::shared_ptr<ioda::ObsDataVector<int>> flags_;
std::shared_ptr<ioda::ObsDataVector<float>> obsErrors_;

Expand Down
1 change: 0 additions & 1 deletion test/opsinputs/ResetFlagsToPass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "ioda/ObsDataVector.h"
#include "ioda/ObsSpace.h"
#include "oops/base/Variables.h"
#include "oops/util/IntSetParser.h" // for contains()
#include "oops/util/Logger.h"
#include "ufo/filters/QCflags.h"
Expand Down
5 changes: 3 additions & 2 deletions test/opsinputs/ResetFlagsToPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "../opsinputs/ResetFlagsToPassParameters.h"
#include "ioda/ObsDataVector.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "oops/interface/ObsFilterBase.h"
#include "oops/util/ObjectCounter.h"
Expand Down Expand Up @@ -62,14 +63,14 @@ class ResetFlagsToPass : public oops::interface::ObsFilterBase<ufo::ObsTraits>,
void checkFilterData(const oops::FilterStage filterStage) override {}

oops::Variables requiredVars() const override {return geovars_;}
oops::Variables requiredHdiagnostics() const override {return extradiagvars_;}
oops::ObsVariables requiredHdiagnostics() const override {return extradiagvars_;}

private:
void print(std::ostream &) const override;

ioda::ObsSpace & obsdb_;
oops::Variables geovars_;
oops::Variables extradiagvars_;
oops::ObsVariables extradiagvars_;
std::shared_ptr<ioda::ObsDataVector<int>> flags_;

ResetFlagsToPassParameters parameters_;
Expand Down
1 change: 0 additions & 1 deletion test/opsinputs/VarObsChecker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "ioda/ObsDataVector.h"
#include "ioda/ObsSpace.h"
#include "oops/base/Variables.h"
#include "oops/mpi/mpi.h"
#include "oops/util/Logger.h"

Expand Down
5 changes: 3 additions & 2 deletions test/opsinputs/VarObsChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "../opsinputs/VarObsCheckerParameters.h"
#include "ioda/ObsDataVector.h"
#include "oops/base/ObsVariables.h"
#include "oops/base/Variables.h"
#include "oops/interface/ObsFilterBase.h"
#include "oops/util/ObjectCounter.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ class VarObsChecker : public oops::interface::ObsFilterBase<ufo::ObsTraits>,
void checkFilterData(const oops::FilterStage filterStage) override {}

oops::Variables requiredVars() const override {return geovars_;}
oops::Variables requiredHdiagnostics() const override {return extradiagvars_;}
oops::ObsVariables requiredHdiagnostics() const override {return extradiagvars_;}

private:
struct PrintVarObsOutput;
Expand All @@ -87,7 +88,7 @@ class VarObsChecker : public oops::interface::ObsFilterBase<ufo::ObsTraits>,

ioda::ObsSpace & obsdb_;
oops::Variables geovars_;
oops::Variables extradiagvars_;
oops::ObsVariables extradiagvars_;
std::shared_ptr<ioda::ObsDataVector<int>> flags_;
std::shared_ptr<ioda::ObsDataVector<float>> obsErrors_;

Expand Down

0 comments on commit f8e68f6

Please sign in to comment.