Skip to content

Commit

Permalink
Add identity 3dvar test (old test). Add some halo exchanges when going
Browse files Browse the repository at this point in the history
from increments to fieldset and vice versa.
  • Loading branch information
frld committed Nov 6, 2024
1 parent 50d4dfc commit 640ed8e
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/orca-jedi/increment/Increment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ void Increment::axpy(const double & zz, const Increment & dx, const bool check)
std::string fieldName_dx = field_dx.name();
oops::Log::debug() << "orcamodel::Increment::axpy:: field name = " << fieldName
<< " field name dx = " << fieldName_dx
<< " zz = " << zz
<< std::endl;
auto field_view = atlas::array::make_view<double, 2>(field);
auto field_view_dx = atlas::array::make_view<double, 2>(field_dx);
Expand Down Expand Up @@ -550,6 +551,8 @@ void Increment::toFieldSet(atlas::FieldSet & fset) const {

fset = atlas::FieldSet();

incrementFields_.haloExchange();

for (size_t i=0; i < vars_.size(); ++i) {
// copy variable from increments to new field set
atlas::Field fieldinc = incrementFields_[i];
Expand Down Expand Up @@ -593,6 +596,9 @@ void Increment::fromFieldSet(const atlas::FieldSet & fset) {
}
}
}

incrementFields_.haloExchange();

oops::Log::debug() << "Increment fromFieldSet done" << std::endl;
}

Expand Down
5 changes: 5 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ ecbuild_add_test( TARGET test_orcamodel_3DVar_sic
ARGS testinput/3dvar_sic.yaml
COMMAND orcamodel_3DVar.x )

ecbuild_add_test( TARGET test_orcamodel_3DVar_sic_identity
OMP 1
ARGS testinput/3dvar_sic_identity.yaml
COMMAND orcamodel_3DVar.x )

ecbuild_add_test( TARGET test_orcamodel_Dirac
OMP 1
ARGS testinput/dirac.yaml
Expand Down
95 changes: 95 additions & 0 deletions src/tests/testinput/3dvar_sic_identity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
cost function:
cost type: 3D-Var
time window:
begin: '2021-06-29T00:00:00Z'
length: P1D
analysis variables: [ice_area_fraction]
background error:
covariance model: SABER
saber central block:
saber block name: ID
geometry: &Geom
nemo variables:
- name: ice_area_fraction
nemo field name: iiceconc
model space: surface
field precision: double
- name: sea_surface_temperature
nemo field name: votemper
model space: surface
field precision: double
- name: sea_water_potential_temperature
nemo field name: votemper
model space: volume
field precision: double
- name: ice_area_fraction_background_error
nemo field name: sic_tot_var
model space: surface
variable type: background variance
field precision: double
grid name: ORCA2_T
number levels: 10
extrafields initialisation: true
background:
date: 2021-06-29T12:00:00Z
state variables: [ ice_area_fraction ]
nemo field file: Data/orca2_t_nemo.nc
set gmask: true
observations:
observers:
- obs space:
name: Sea Ice
obsdatain:
engine:
type: H5File
obsfile: Data/sic_obs_ideal.nc
obsdataout:
engine:
type: H5File
obsfile: testoutput/obsdataout_3dvar_sic_identity.nc
simulated variables: [ice_area_fraction]
get values:
time interpolation: linear
atlas-interpolator:
type: unstructured-bilinear-lonlat
# non_linear: missing-if-all-missing
max_fraction_elems_to_try: 0.0
adjoint: true
obs operator:
name: Composite
components:
- name: Identity
obs filters:
- filter: Background Check
filter variables:
- name: ice_area_fraction
absolute threshold: 2.0
action:
name: reject
obs error:
covariance model: diagonal
variational:
minimizer:
algorithm: DRPCG
iterations:
- ninner: 1
gradient norm reduction: 1e-30
geometry: *Geom
test: on
online diagnostics:
write increment: true
increment:
state component:
output path: testoutput/increments_3dvar_sic_identity.nc
date: 2021-06-30T00:00:00Z
final:
diagnostics:
departures: oman
output:
date: 2021-06-30T00:00:00Z
state variables: [ ice_area_fraction ]
nemo field file: testoutput/3dvar_sic_identity2.nc
output nemo field file: testoutput/analysis_3dvar_sic_identity.nc
test:
reference filename: testoutput/test_3dvar_sic_identity.ref
test output filename: testoutput/test_3dvar_sic_identity.out
1 change: 1 addition & 0 deletions src/tests/testinput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ list( APPEND orcajedi_test_input
test_name_map.yaml
dirac.yaml
3dvar_sic.yaml
3dvar_sic_identity.yaml
bump_nicas_setup.yaml
)

Expand Down
1 change: 1 addition & 0 deletions src/tests/testoutput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ list( APPEND orcajedi_test_output
test_hofx3d_nc_ssh_amm1.ref
test_hofx3d_nc_ssh_amm1r.ref
test_3dvar_sic.ref
test_3dvar_sic_identity.ref
test_dirac.ref
test_bump_nicas.ref
)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/testoutput/test_3dvar_sic.ref
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ CostFunction::addIncrement: Analysis:



CostJb : Nonlinear Jb = 0.00000e+00
CostJb : Nonlinear Jb = -2.76549e-03
CostJo : Nonlinear Jo(Sea Ice) = 7.87621e-01, nobs = 47, Jo/n = 1.67579e-02, err = 2.00000e+00
CostFunction: Nonlinear J = 7.87621e-01
CostFunction: Nonlinear J = 7.84855e-01
16 changes: 16 additions & 0 deletions src/tests/testoutput/test_3dvar_sic_identity.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CostJb : Nonlinear Jb = 0.0000000000000000e+00
CostJo : Nonlinear Jo(Sea Ice) = 1.4687500000000000e+00, nobs = 47, Jo/n = 3.1250000000000000e-02, err = 2.0000000000000000e+00
CostFunction: Nonlinear J = 1.4687500000000000e+00
DRPCGMinimizer: reduction in residual norm = 7.2399282392205355e-01
CostFunction::addIncrement: Analysis:
Model state valid at time: 2021-06-29T12:00:00Z
1 variables: ice_area_fraction
atlas field norms:
ice_area_fraction: 3.20155e-03




CostJb : Nonlinear Jb = 0.00000e+00
CostJo : Nonlinear Jo(Sea Ice) = 1.10491e+00, nobs = 47, Jo/n = 2.35087e-02, err = 2.00000e+00
CostFunction: Nonlinear J = 1.10491e+00

0 comments on commit 640ed8e

Please sign in to comment.