Skip to content

Commit 67cfee9

Browse files
casting Cs_w values explicitly to float
1 parent 0196fc9 commit 67cfee9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

parcels/compilation/codegenerator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,9 @@ def visit_FieldEvalNode(self, node):
830830
args = self._check_FieldSamplingArguments(node.args.ccode)
831831
if "croco" in node.field.obj.gridindexingtype and node.field.obj.name != "H" and node.field.obj.name != "Zeta":
832832
# Get Cs_w values directly from fieldset (since they are 1D in vertical only)
833-
Cs_w = [self.fieldset.Cs_w.data[0][zi][0][0] for zi in range(self.fieldset.Cs_w.data.shape[1])]
833+
Cs_w = [
834+
self.fieldset.Cs_w.data[0][zi][0][0].astype(float) for zi in range(self.fieldset.Cs_w.data.shape[1])
835+
]
834836
statements_croco = [
835837
c.Statement(f"float cs_w[] = {*Cs_w, }".replace("(", "{").replace(")", "}")),
836838
c.Statement(

parcels/include/parcels.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,8 @@ static inline double croco_from_z_to_sigma(CField *U, CField *H, CField *Zeta,
12531253
float *sigma_levels = grid->depth;
12541254
int zdim = grid->zdim;
12551255
float zvec[zdim];
1256-
status = temporal_interpolation(x, y, 0, time, H, xi, yi, zi, ti, &local_h, LINEAR, CROCO);
1257-
status = temporal_interpolation(x, y, 0, time, Zeta, xi, yi, zi, ti, &local_zeta, LINEAR, CROCO);
1256+
status = temporal_interpolation(x, y, 0, time, H, xi, yi, zi, ti, &local_h, LINEAR, CROCO); CHECKSTATUS(status);
1257+
status = temporal_interpolation(x, y, 0, time, Zeta, xi, yi, zi, ti, &local_zeta, LINEAR, CROCO); CHECKSTATUS(status);
12581258
for (zii = 0; zii < zdim; zii++) {
12591259
z0 = hc*sigma_levels[zii] + (local_h - hc) *cs_w[zii];
12601260
zvec[zii] = z0 + local_zeta * (1 + z0 / local_h);

0 commit comments

Comments
 (0)