Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 152 additions & 171 deletions src/nemo-feedback/NemoFeedback.cc

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/nemo-feedback/NemoFeedback.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class NemoFeedback : public ufo::ObsFilterBase,
/// the file during construction of the feedback file. This step should
/// ensure that the number of levels and the reference Julian day are
/// shared across MPI processes.
feedback_io::MetaData setupMetaData(const NemoFeedbackDataCreator& creator)
const;
feedback_io::MetaData setupMetaData(const NemoFeedbackDataCreator& creator,
const util::DateTime juldReferenceGlobal,
const size_t nLevelsGlobal) const;
/// \brief Setup the NEMO STATION_TYPES and STATION_IDS netCDF variables
/// In the case of altimetry data, this requires additional processing
/// of the satelliteIdentifier to extract these variables.
Expand Down
4 changes: 4 additions & 0 deletions src/nemo-feedback/feedback_io/DataIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ DataIndexer::DataIndexer(const size_t nObs, const size_t nLevels,
nObs_(nObs), nLevels_(nLevels), sourceDataSize_(sourceDataSize),
indices_(indices), starts_(starts) {
counts_.reserve(nObs);
if (nObs == 0) {
validate();
return;
}
for (size_t iProf = 0; iProf < nObs - 1; ++iProf) {
counts_.push_back(starts[iProf +1] - starts[iProf]);
}
Expand Down
23 changes: 23 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,26 @@ ecbuild_add_test( TARGET test_nemo_feedback_hofx_profiles_two_vars_file
COMMAND ./mains/compare_nc_cdl.sh
TEST_DEPENDS test_nemo_feedback_hofx_profiles_two_vars_writer)

ecbuild_add_test( TARGET test_nemo_feedback_hofx_mpi_2_writer
OMP 1
MPI 2
ARGS testinput/hofx_mpi_2_writer.yaml
COMMAND test_NemoInputsFilters.x )

ecbuild_add_test( TARGET test_nemo_feedback_hofx_mpi_2_file
OMP 1
ARGS testoutput/test_hofx_mpi_2_writer_out_00001.nc testoutput/test_hofx_mpi_2_writer_out_00001_ref.cdl
COMMAND ./mains/compare_nc_cdl.sh
TEST_DEPENDS test_nemo_feedback_hofx_mpi_2_writer)

ecbuild_add_test( TARGET test_nemo_feedback_hofx_mpi_3_writer
OMP 1
MPI 3
ARGS testinput/hofx_mpi_3_writer.yaml
COMMAND test_NemoInputsFilters.x )

ecbuild_add_test( TARGET test_nemo_feedback_hofx_mpi_3_file
OMP 1
ARGS testoutput/test_hofx_mpi_3_writer_out_00001.nc testoutput/test_hofx_mpi_3_writer_out_00001_ref.cdl
COMMAND ./mains/compare_nc_cdl.sh
TEST_DEPENDS test_nemo_feedback_hofx_mpi_3_writer)
2 changes: 2 additions & 0 deletions src/tests/Data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ hofx_sic_obs.nc
hofx_two_vars_obs.nc
hofx_potm_obs.nc
hofx_prof_2var_obs.nc
hofx_mpi_obs.nc
test_hofx3d_nc_prof_2vars_writer_geovals.nc
test_hofx_profiles_writer_geovals.nc
test_hofx_sic_writer_geovals.nc
test_hofx_two_vars_writer_geovals.nc
test_hofx_mpi_writer_geovals.nc
)

foreach(FILENAME ${nemofeedback_test_data})
Expand Down
3 changes: 3 additions & 0 deletions src/tests/Data/hofx_mpi_obs.nc
Git LFS file not shown
3 changes: 3 additions & 0 deletions src/tests/Data/test_hofx_mpi_writer_geovals.nc
Git LFS file not shown
2 changes: 2 additions & 0 deletions src/tests/testinput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ list( APPEND fdbk_writer_test_input
hofx_two_vars_writer.yaml
hofx_profiles_writer.yaml
hofx_profiles_2var_writer.yaml
hofx_mpi_2_writer.yaml
hofx_mpi_3_writer.yaml
test_name_map.yaml
)

Expand Down
38 changes: 38 additions & 0 deletions src/tests/testinput/hofx_mpi_2_writer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
time window:
begin: 2024-06-28T12:00:00Z
end: 2025-07-18T12:00:00Z
observations:
- obs space:
name: Sea Surface Height Anomaly MPI
obsdatain:
engine:
type: H5File
obsfile: Data/hofx_mpi_obs.nc
obsdataout:
engine:
type: H5File
obsfile: testoutput/test_hofx_mpi_2_jopa_out.nc
simulated variables: [seaSurfaceHeightAnomaly]
obs filters:
- filter: NEMO Feedback Writer
reference date: 2021-06-30T12:00:00Z
filename: testoutput/test_hofx_mpi_2_writer_out.nc
observation alias file: testinput/test_name_map.yaml
where:
- variable:
name: DiagnosticFlags/ObsToWrite/seaSurfaceHeightAnomaly
value: is_true
variables:
- name: seaSurfaceHeightAnomaly
nemo name: SLA
long name: Sea Surface Height Anomaly
units: Fraction
additional variables:
- name: seaSurfaceHeightAnomaly
feedback suffix: Hx
ioda group: HofX
benchmarkFlag: 1000 # just to keep the ObsFilters test happy
flaggedBenchmark: 0
HofX: hofx
geovals:
filename: Data/test_hofx_mpi_writer_geovals.nc
34 changes: 34 additions & 0 deletions src/tests/testinput/hofx_mpi_3_writer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
time window:
begin: 2024-06-28T12:00:00Z
end: 2025-07-18T12:00:00Z
observations:
- obs space:
name: Sea Surface Height Anomaly MPI
obsdatain:
engine:
type: H5File
obsfile: Data/hofx_mpi_obs.nc
obsdataout:
engine:
type: H5File
obsfile: testoutput/test_hofx_mpi_3_jopa_out.nc
simulated variables: [seaSurfaceHeightAnomaly]
obs filters:
- filter: NEMO Feedback Writer
reference date: 2021-06-30T12:00:00Z
filename: testoutput/test_hofx_mpi_3_writer_out.nc
observation alias file: testinput/test_name_map.yaml
variables:
- name: seaSurfaceHeightAnomaly
nemo name: SLA
long name: Sea Surface Height Anomaly
units: Fraction
additional variables:
- name: seaSurfaceHeightAnomaly
feedback suffix: Hx
ioda group: HofX
benchmarkFlag: 1000 # just to keep the ObsFilters test happy
flaggedBenchmark: 0
HofX: hofx
geovals:
filename: Data/test_hofx_mpi_writer_geovals.nc
3 changes: 2 additions & 1 deletion src/tests/testinput/test_name_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ variable maps:
alias: sea_water_salinity
- name: depthBelowWaterSurface
alias: depth

- name: seaSurfaceHeightAnomaly
alias: sea_surface_height_anomaly
2 changes: 2 additions & 0 deletions src/tests/testoutput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ list( APPEND fdbk_writer_test_output
test_hofx_two_vars_writer_out_ref.cdl
test_hofx_profiles_writer_out_ref.cdl
test_hofx3d_nc_prof_2vars_writer_out_ref.cdl
test_hofx_mpi_2_writer_out_00001_ref.cdl
test_hofx_mpi_3_writer_out_00001_ref.cdl
)

foreach(FILENAME ${fdbk_writer_test_output})
Expand Down
172 changes: 172 additions & 0 deletions src/tests/testoutput/test_hofx_mpi_2_writer_out_00001_ref.cdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
netcdf test_hofx_mpi_2_writer_out_00001 {
dimensions:
N_QCF = 2 ;
STRINGGRID = 1 ;
STRINGJULD = 14 ;
STRINGNAM = 8 ;
STRINGTYP = 4 ;
STRINGWMO = 8 ;
N_OBS = 1 ;
N_LEVELS = 1 ;
N_VARS = 1 ;
N_ENTRIES = 1 ;
variables:
char JULD_REFERENCE(STRINGJULD) ;
JULD_REFERENCE:long_name = "Date of reference for julian days" ;
JULD_REFERENCE:Conventions = "YYYYMMDDHHMMSS" ;
char VARIABLES(N_VARS, STRINGNAM) ;
VARIABLES:long_name = "List of variables in feedback files" ;
char ENTRIES(N_ENTRIES, STRINGNAM) ;
ENTRIES:long_name = "List of additional entries for each variable in feedback files" ;
double LATITUDE(N_OBS) ;
LATITUDE:units = "degrees_north" ;
LATITUDE:long_name = "latitude" ;
double LONGITUDE(N_OBS) ;
LONGITUDE:units = "degrees_east" ;
LONGITUDE:long_name = "longitude" ;
double DEPTH(N_OBS, N_LEVELS) ;
DEPTH:_FillValue = 99999. ;
DEPTH:units = "metre" ;
DEPTH:long_name = "Depth" ;
double JULD(N_OBS) ;
JULD:units = "days since JULD_REFERENCE" ;
JULD:long_name = "Julian day" ;
char STATION_IDENTIFIER(N_OBS, STRINGWMO) ;
STATION_IDENTIFIER:long_name = "Station identifier" ;
char STATION_TYPE(N_OBS, STRINGTYP) ;
STATION_TYPE:long_name = "Code instrument type" ;
int DEPTH_QC(N_OBS, N_LEVELS) ;
DEPTH_QC:long_name = "Quality on depth" ;
DEPTH_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int DEPTH_QC_FLAGS(N_OBS, N_LEVELS, N_QCF) ;
DEPTH_QC_FLAGS:long_name = "Quality on depth" ;
DEPTH_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int OBSERVATION_QC(N_OBS) ;
OBSERVATION_QC:long_name = "Quality on observation" ;
OBSERVATION_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int OBSERVATION_QC_FLAGS(N_OBS, N_QCF) ;
OBSERVATION_QC_FLAGS:long_name = "Quality on observation" ;
OBSERVATION_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int POSITION_QC(N_OBS) ;
POSITION_QC:long_name = "Quality on position" ;
POSITION_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int POSITION_QC_FLAGS(N_OBS, N_QCF) ;
POSITION_QC_FLAGS:long_name = "Quality on position" ;
POSITION_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int JULD_QC(N_OBS) ;
JULD_QC:long_name = "Quality on date and time" ;
JULD_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int JULD_QC_FLAGS(N_OBS, N_QCF) ;
JULD_QC_FLAGS:long_name = "Quality on date and time" ;
JULD_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int ORIGINAL_FILE_INDEX(N_OBS) ;
ORIGINAL_FILE_INDEX:long_name = "Index in original data file" ;
double SLA_OBS(N_OBS, N_LEVELS) ;
SLA_OBS:long_name = "Sea Surface Height Anomaly" ;
SLA_OBS:units = "Fraction" ;
SLA_OBS:_FillValue = 99999. ;
double SLA_Hx(N_OBS, N_LEVELS) ;
SLA_Hx:long_name = "Sea Surface Height Anomaly Hx" ;
SLA_Hx:units = "Fraction" ;
SLA_Hx:_FillValue = 99999. ;
int SLA_QC_FLAGS(N_OBS, N_QCF) ;
SLA_QC_FLAGS:_FillValue = 0 ;
SLA_QC_FLAGS:long_name = "quality flags on Sea Surface Height Anomaly" ;
SLA_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int SLA_LEVEL_QC_FLAGS(N_OBS, N_LEVELS, N_QCF) ;
SLA_LEVEL_QC_FLAGS:_FillValue = 0 ;
SLA_LEVEL_QC_FLAGS:long_name = "quality flags for each level on Sea Surface Height Anomaly" ;
SLA_LEVEL_QC_FLAGS:Conventions = "JEDI UFO QC flag conventions" ;
int SLA_QC(N_OBS) ;
SLA_QC:long_name = "quality on Sea Surface Height Anomaly" ;
SLA_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int SLA_LEVEL_QC(N_OBS, N_LEVELS) ;
SLA_LEVEL_QC:_FillValue = 0 ;
SLA_LEVEL_QC:long_name = "quality for each level on Sea Surface Height Anomaly" ;
SLA_LEVEL_QC:Conventions = "U.S. Integrated Ocean Observing System, 2017. Manual for the Use of Real-Time Oceanographic Data Quality Control Flags, Version 1.1" ;
int SLA_IOBSI(N_OBS) ;
SLA_IOBSI:long_name = "ORCA grid search I coordinate" ;
int SLA_IOBSJ(N_OBS) ;
SLA_IOBSJ:long_name = "ORCA grid search J coordinate" ;
int SLA_IOBSK(N_OBS, N_LEVELS) ;
SLA_IOBSK:long_name = "ORCA grid search K coordinate" ;
char SLA_GRID(STRINGGRID) ;
SLA_GRID:long_name = "ORCA grid search grid (T,U,V)" ;

// global attributes:
:title = "NEMO observation operator output" ;
:Convention = "NEMO unified observation operator output" ;
data:

JULD_REFERENCE = "20210630120000" ;

VARIABLES =
"SLA " ;

ENTRIES =
"Hx " ;

LATITUDE = 28.26 ;

LONGITUDE = 33.350002 ;

DEPTH =
0 ;

JULD = 1461.1639 ;

STATION_IDENTIFIER =
"1005 " ;

STATION_TYPE =
"1005" ;

DEPTH_QC =
_ ;

DEPTH_QC_FLAGS =
_, _ ;

OBSERVATION_QC = 0 ;

OBSERVATION_QC_FLAGS =
_, _ ;

POSITION_QC = _ ;

POSITION_QC_FLAGS =
_, _ ;

JULD_QC = _ ;

JULD_QC_FLAGS =
_, _ ;

ORIGINAL_FILE_INDEX = _ ;

SLA_OBS =
0.00099999993 ;

SLA_Hx =
-0.072882071 ;

SLA_QC_FLAGS =
_, _ ;

SLA_LEVEL_QC_FLAGS =
_, _ ;

SLA_QC = _ ;

SLA_LEVEL_QC =
_ ;

SLA_IOBSI = _ ;

SLA_IOBSJ = _ ;

SLA_IOBSK =
_ ;

SLA_GRID = "T" ;
}
Loading