Skip to content

Commit

Permalink
prevent invalid arithmetic when coriolis turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
hklion committed Jan 5, 2024
1 parent 2faa1ac commit d4e89b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/Initialization/ROMSX_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ROMSX::init_beta_plane_coriolis (int lev)
Real coriolis_beta = solverChoice.coriolis_beta;
Real Esize = geomdata.ProbHi()[1] - geomdata.ProbLo()[1];

ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int )
ParallelFor(Box(fcor_arr), [=] AMREX_GPU_DEVICE (int i, int j, int )
{
Real y = geomdata.ProbLo()[1] + (j + 0.5) * geomdata.CellSize()[1];
fcor_arr(i,j,0) = coriolis_f0 + coriolis_beta * (y - 0.5 * Esize);
Expand Down
10 changes: 6 additions & 4 deletions Source/TimeIntegration/ROMSX_advance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,12 @@ ROMSX::advance_2d (int lev,
rhs_vbar(i,j,0)=0.0;
});

ParallelFor(tbxp2D, [=] AMREX_GPU_DEVICE (int i, int j, int )
{
fomn(i,j,0) = fcor(i,j,0)*(1.0/(pm(i,j,0)*pn(i,j,0)));
});
if (solverChoice.use_coriolis) {
ParallelFor(tbxp2D, [=] AMREX_GPU_DEVICE (int i, int j, int )
{
fomn(i,j,0) = fcor(i,j,0)*(1.0/(pm(i,j,0)*pn(i,j,0)));
});
}

ParallelFor(makeSlab(tbxp3,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
{
Expand Down
11 changes: 6 additions & 5 deletions Source/TimeIntegration/ROMSX_setup_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ ROMSX::setup_step (int lev, Real time, Real dt_lev)

auto fomn=fab_fomn.array();

ParallelFor(tbxp2D,
[=] AMREX_GPU_DEVICE (int i, int j, int )
{
fomn(i,j,0) = fcor(i,j,0)*(1.0/(pm(i,j,0)*pn(i,j,0)));
});
if (solverChoice.use_coriolis) {
ParallelFor(tbxp2D, [=] AMREX_GPU_DEVICE (int i, int j, int )
{
fomn(i,j,0) = fcor(i,j,0)*(1.0/(pm(i,j,0)*pn(i,j,0)));
});
}

ParallelFor(gbx2, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
Expand Down

0 comments on commit d4e89b1

Please sign in to comment.