Skip to content
Open
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
21 changes: 0 additions & 21 deletions src/multio/action/encode-mtg2/EncodeMtg2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "multio/action/encode-mtg2/fakeDoubleLoop.h"
#include "multio/datamod/MarsMiscGeo.h"
#include "multio/datamod/types/TimeSpan.h"
#include "multio/mars2mars/Rules.h"
#include "multio/message/Parametrization.h"
#include "multio/util/PrecisionTag.h"

Expand Down Expand Up @@ -146,33 +145,13 @@ void EncodeMtg2::executeImpl(Message msg) {

// Apply mappings
fake_double_loop::fakeDoubleLoop(marsRec);
auto mappingResult = mars2mars::applyMappings(mars2mars::allRules(), marsRec, miscRec);

executeNext(dispatchPrecisionTag(msg.precision(), [&](auto pt) {
using Precision = typename decltype(pt)::type;
msg.payload().acquire();
auto values = static_cast<Precision*>(msg.payload().modifyData());
size_t size = msg.payload().size() / sizeof(Precision);

// Check if values need scaling
if (mappingResult && mappingResult->valuesScaleFactor) {
ASSERT(values);

const auto scaleFactor = *(mappingResult->valuesScaleFactor);

if (miscRec.missingValue.isSet()) {
const double missing = miscRec.missingValue.get();
std::transform(values, values + size, values, [&](const Precision& value) -> Precision {
return static_cast<Precision>(value == missing ? missing : value * scaleFactor);
});
}
else {
std::transform(values, values + size, values, [&](const Precision& value) -> Precision {
return static_cast<Precision>(value * scaleFactor);
});
}
}

// Call the GRIB2 encoder in metkit
const auto sample = encode(*encoder_, cache_, values, size, marsRec, miscRec);

Expand Down
23 changes: 4 additions & 19 deletions src/multiom/core/common/enumerators_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1475,14 +1475,6 @@ FUNCTION IPREFIX2ILEVTYPE( IPREFIX, PARAM_ID, LEVEL, REPRES, ILEVTYPE, HOOKS ) R
! Initialization of good path return value
PP_SET_ERR_SUCCESS( RET )

! NGRBRSN - 33 - Snow density
! NGRBTSN - 238 - Temperature of snow layer
! NGRBWSN - 228038 - Snow liquid water (multi-layer)
! NGRBSD - 228141 - Snow depth (multi-layer)
! NGRBSOT - 260360 - Soil temperature (multi-layer)
! NGRBSIT - 262024 - Sea ice temperature (multi-layer)
! NGRBVSW - 260199 - Volumetric soil moisture (multi-layer)

SELECT CASE ( IPREFIX )

CASE ( PREFIX_MODEL_LEVEL_E )
Expand All @@ -1496,18 +1488,11 @@ FUNCTION IPREFIX2ILEVTYPE( IPREFIX, PARAM_ID, LEVEL, REPRES, ILEVTYPE, HOOKS ) R
CASE ( PREFIX_THETA_LEVEL_E )
ILEVTYPE = LEVTYPE_PT_E
CASE ( PREFIX_SURFACE_E )
! SELECT CASE (PARAM_ID)
! TODO: This logic is very weak and should be improved
! CASE ( NGRBSD, NGRBTSN, NGRBRSN, NGRBWSN, NGRBSOT, NGRBVSW, NGRBSIT )
! IF ( LEVEL .NE. 0 ) THEN
! Multilevel surfaces at level 0 are considered as surface
! ILEVTYPE = LEVTYPE_SOL_E
! ELSE
IF ( LEVEL .NE. 0 ) THEN
ILEVTYPE = LEVTYPE_SOL_E
ELSE
ILEVTYPE = LEVTYPE_SFC_E
! END IF
! CASE DEFAULT
! ILEVTYPE = LEVTYPE_SFC_E
! END SELECT
END IF
CASE (PREFIX_AL_E)
ILEVTYPE = LEVTYPE_AL_E
CASE ( PREFIX_WAVE_INT_E )
Expand Down
18 changes: 4 additions & 14 deletions src/multiom/ifs2mars/ifs-interface/ifs_utils_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ FUNCTION IPREFIX2ILEVTYPE( IPREFIX, PARAM_ID, LEVEL, REPRES, ILEVTYPE, HOOKS ) R
! Initialization of good path return value
PP_SET_ERR_SUCCESS( RET )

! NGRBRSN - 33 - Snow density
! NGRBTSN - 238 - Temperature of snow layer
! NGRBWSN - 228038 - Snow liquid water (multi-layer)
! NGRBSD - 228141 - Snow depth (multi-layer)

SELECT CASE ( IPREFIX )

CASE ( PREFIX_MODEL_LEVEL_E )
Expand All @@ -360,16 +355,11 @@ FUNCTION IPREFIX2ILEVTYPE( IPREFIX, PARAM_ID, LEVEL, REPRES, ILEVTYPE, HOOKS ) R
CASE ( PREFIX_THETA_LEVEL_E )
ILEVTYPE = LEVTYPE_PT_E
CASE ( PREFIX_SURFACE_E )
SELECT CASE (PARAM_ID)
CASE ( NGRBRSN, NGRBTSN, NGRBWSN, NGRBSD, 231027 )
IF ( LEVEL .NE. 0 ) THEN
ILEVTYPE = LEVTYPE_SOL_E
ELSE
ILEVTYPE = LEVTYPE_SFC_E
END IF
CASE DEFAULT
IF ( LEVEL .NE. 0 ) THEN
ILEVTYPE = LEVTYPE_SOL_E
ELSE
ILEVTYPE = LEVTYPE_SFC_E
END SELECT
END IF
CASE ( PREFIX_WAVE_INT_E )
ILEVTYPE = LEVTYPE_SFC_E
CASE ( PREFIX_WAVE_SPEC_E )
Expand Down
Loading