Skip to content

Commit

Permalink
start for moving to single precision option
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Jan 4, 2024
1 parent 5a17e80 commit 7c83c33
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 142 deletions.
8 changes: 4 additions & 4 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ ROMSX::WritePlotFile (int which, Vector<std::string> plot_var_names)
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
loc_arr(i,j,k,0) = (i+0.5) * dx;
loc_arr(i,j,k,1) = (j+0.5) * dy;
loc_arr(i,j,k,2) = Real(0.125) * (zp_arr(i,j ,k ) + zp_arr(i+1,j ,k ) +
zp_arr(i,j+1,k ) + zp_arr(i+1,j+1,k ) +
zp_arr(i,j ,k+1) + zp_arr(i+1,j ,k+1) +
zp_arr(i,j+1,k+1) + zp_arr(i+1,j+1,k+1) );
loc_arr(i,j,k,2) = 0.125_rt * (zp_arr(i,j ,k ) + zp_arr(i+1,j ,k ) +
zp_arr(i,j+1,k ) + zp_arr(i+1,j+1,k ) +
zp_arr(i,j ,k+1) + zp_arr(i+1,j ,k+1) +
zp_arr(i,j+1,k+1) + zp_arr(i+1,j+1,k+1) );
});
} // mfi
mf_comp += AMREX_SPACEDIM;
Expand Down
28 changes: 14 additions & 14 deletions Source/ROMSX_make_new_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,20 @@ void ROMSX::init_stuff(int lev, const BoxArray& ba, const DistributionMapping& d
set_weights(lev);

//consider tracking ru and rv indexes more specifically or more similarly to indx
vec_ru[lev]->setVal(0.0);
vec_rv[lev]->setVal(0.0);

vec_DU_avg1[lev]->setVal(0.0);
vec_DU_avg2[lev]->setVal(0.0);
vec_DV_avg1[lev]->setVal(0.0);
vec_DV_avg2[lev]->setVal(0.0);
vec_rubar[lev]->setVal(0.0);
vec_rvbar[lev]->setVal(0.0);
vec_rzeta[lev]->setVal(0.0);

vec_ubar[lev]->setVal(0.0);
vec_vbar[lev]->setVal(0.0);
vec_zeta[lev]->setVal(0.0);
vec_ru[lev]->setVal(0.0_rt);
vec_rv[lev]->setVal(0.0_rt);

vec_DU_avg1[lev]->setVal(0.0_rt);
vec_DU_avg2[lev]->setVal(0.0_rt);
vec_DV_avg1[lev]->setVal(0.0_rt);
vec_DV_avg2[lev]->setVal(0.0_rt);
vec_rubar[lev]->setVal(0.0_rt);
vec_rvbar[lev]->setVal(0.0_rt);
vec_rzeta[lev]->setVal(0.0_rt);

vec_ubar[lev]->setVal(0.0_rt);
vec_vbar[lev]->setVal(0.0_rt);
vec_zeta[lev]->setVal(0.0_rt);

// Set initial linear drag coefficient
vec_rdrag[lev]->setVal(solverChoice.rdrag);
Expand Down
54 changes: 27 additions & 27 deletions Source/TimeIntegration/ROMSX_advance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ ROMSX::advance_2d (int lev,

ParallelFor(makeSlab(xgbx2,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
{
Real on_u = Real(2.0) / (pn(i,j,0)+pn(i-1,j,0));
Real cff1= 0.5 * on_u *(Drhs(i,j,0)+Drhs(i-1,j,0));
Real on_u = 2.0_rt / (pn(i,j,0)+pn(i-1,j,0));
Real cff1= 0.5_rt * on_u *(Drhs(i,j,0)+Drhs(i-1,j,0));
DUon(i,j,0)=ubar(i,j,0,krhs)*cff1;
});

ParallelFor(makeSlab(ygbx2,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
{
Real om_v = Real(2.0) / (pm(i,j,0)+pm(i,j-1,0));
Real cff1= 0.5 * om_v * (Drhs(i,j,0)+Drhs(i,j-1,0));
Real om_v = 2.0_rt / (pm(i,j,0)+pm(i,j-1,0));
Real cff1= 0.5_rt * om_v * (Drhs(i,j,0)+Drhs(i,j-1,0));
DVom(i,j,0)=vbar(i,j,0,krhs)*cff1;
});
}
Expand Down Expand Up @@ -258,12 +258,12 @@ ROMSX::advance_2d (int lev,
//From ana_grid.h and metrics.F
ParallelFor(xbxD, [=] AMREX_GPU_DEVICE (int i, int j, int)
{
rhs_ubar(i,j,0)=0.0;
rhs_ubar(i,j,0)=0.0_rt;
});

ParallelFor(ybxD, [=] AMREX_GPU_DEVICE (int i, int j, int)
{
rhs_vbar(i,j,0)=0.0;
rhs_vbar(i,j,0)=0.0_rt;
});

Real Esize = Geom(lev).ProbHi()[1] - Geom(lev).ProbLo()[1];
Expand All @@ -274,9 +274,9 @@ ROMSX::advance_2d (int lev,
const auto dx = geomdata.CellSize();

//defined UPWELLING
Real y = prob_lo[1] + (j + 0.5) * dx[1];
Real y = prob_lo[1] + (j + 0.5_rt) * dx[1];
Real f=coriolis_f0 + coriolis_beta*(y-.5*Esize);
fomn(i,j,0) = f*(1.0/(pm(i,j,0)*pn(i,j,0)));
fomn(i,j,0) = f*(1.0_rt/(pm(i,j,0)*pn(i,j,0)));
});

ParallelFor(makeSlab(tbxp3,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
Expand All @@ -287,29 +287,29 @@ ROMSX::advance_2d (int lev,
if(predictor_2d_step)
{
if(first_2d_step) {
Real cff2=(Real(-1.0)/Real(12.0))*weight2[my_iif+1];
Real cff2=(-1.0_rt/12.0_rt)*weight2[my_iif+1];
ParallelFor(makeSlab(gbx3,2,0),
[=] AMREX_GPU_DEVICE (int i, int j, int)
{
Zt_avg1(i,j,0)=0.0;
Zt_avg1(i,j,0)=0.0_rt;
});
ParallelFor(makeSlab(xgbx2,2,0),
[=] AMREX_GPU_DEVICE (int i, int j, int)
{
DU_avg1(i,j,0)=0.0;
DU_avg1(i,j,0)=0.0_rt;
DU_avg2(i,j,0)=cff2*DUon(i,j,0);
});
ParallelFor(makeSlab(ygbx2,2,0),
[=] AMREX_GPU_DEVICE (int i, int j, int)
{
DV_avg1(i,j,0)=0.0;
DV_avg1(i,j,0)=0.0_rt;
DV_avg2(i,j,0)=cff2*DVom(i,j,0);
});
}
else {
Real cff1_wt1 = weight1[my_iif-1];
Real cff2_wt1 = (Real(8.0)/Real(12.0))*weight2[my_iif]-
(Real(1.0)/Real(12.0))*weight2[my_iif+1];
Real cff2_wt1 = (8.0_rt/12.0_rt)*weight2[my_iif]-
(1.0_rt/12.0_rt)*weight2[my_iif+1];

ParallelFor(makeSlab(gbx3,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
{
Expand All @@ -335,7 +335,7 @@ ROMSX::advance_2d (int lev,
if (first_2d_step) {
cff2_wt2=weight2[my_iif];
} else {
cff2_wt2=Real(5.0)/Real(12.0)*weight2[my_iif];
cff2_wt2=5.0_rt/12.0_rt*weight2[my_iif];
}

ParallelFor(makeSlab(xgbx2,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int)
Expand Down Expand Up @@ -370,7 +370,7 @@ ROMSX::advance_2d (int lev,
// todo: gzeta

// todo: HACKHACKHACK Should use rho0 from prob.H
Real fac=1000.0/1025.0;
Real fac=1000.0_rt/1025.0_rt;

if (my_iif==0) {
Real cff1=dtfast_lev;
Expand All @@ -391,9 +391,9 @@ ROMSX::advance_2d (int lev,

} else if (predictor_2d_step) {

Real cff1=2.0_rt*dtfast_lev;
Real cff4=4.0/25.0;
Real cff5=1.0-2.0*cff4;
Real cff1=2.0_rt * dtfast_lev;
Real cff4=4.0_rt / 25.0_rt;
Real cff5=1.0_rt - 2.0_rt*cff4;

ParallelFor(tbxp1, [=] AMREX_GPU_DEVICE (int i, int j, int )
{
Expand All @@ -412,9 +412,9 @@ ROMSX::advance_2d (int lev,

} else if (!predictor_2d_step) { //AKA if(corrector_2d_step)

Real cff1=dtfast_lev*5.0_rt/12.0_rt;
Real cff2=dtfast_lev*8.0_rt/12.0_rt;
Real cff3=dtfast_lev*1.0_rt/12.0_rt;
Real cff1=dtfast_lev * 5.0_rt/12.0_rt;
Real cff2=dtfast_lev * 8.0_rt/12.0_rt;
Real cff3=dtfast_lev * 1.0_rt/12.0_rt;
Real cff4=2.0_rt/5.0_rt;
Real cff5=1.0_rt-cff4;

Expand Down Expand Up @@ -469,12 +469,12 @@ ROMSX::advance_2d (int lev,
!
*/

Real cff1 = 0.5 * solverChoice.g; // Should be the variable gravitational field strength
Real cff2 = 1.0 / 3.0;
Real cff1 = 0.5_rt * solverChoice.g; // Should be the variable gravitational field strength
Real cff2 = 1.0_rt / 3.0_rt;
ParallelFor(xbxD,
[=] AMREX_GPU_DEVICE (int i, int j, int )
{
Real on_u = Real(2.0) / (pn(i,j,0)+pn(i-1,j,0));
Real on_u = 2.0_rt / (pn(i,j,0)+pn(i-1,j,0));
rhs_ubar(i,j,0)=cff1 * on_u *
(( h(i-1,j,0) + h(i,j,0))*
(gzeta(i-1,j,0) - gzeta(i,j,0))+
Expand All @@ -488,7 +488,7 @@ ROMSX::advance_2d (int lev,
ParallelFor(ybxD,
[=] AMREX_GPU_DEVICE (int i, int j, int )
{
Real om_v = Real(2.0) / (pm(i,j,0)+pm(i,j-1,0));
Real om_v = 2.0_rt / (pm(i,j,0)+pm(i,j-1,0));
rhs_vbar(i,j,0) = cff1*om_v *
(( h(i,j-1,0) + h(i,j,0))*
(gzeta(i,j-1,0) - gzeta(i,j,0))+
Expand Down Expand Up @@ -528,7 +528,7 @@ ROMSX::advance_2d (int lev,
//-----------------------------------------------------------------------
uv3dmix(xbxD, ybxD, ubar, vbar, ubar, vbar, rhs_ubar, rhs_vbar,
visc2_p, visc2_r, Drhs_const,
pn, pm, krhs, nnew, 0.0);
pn, pm, krhs, nnew, 0.0_rt);

//-----------------------------------------------------------------------
// Coupling from 3d to 2d
Expand Down
8 changes: 4 additions & 4 deletions Source/TimeIntegration/ROMSX_prestep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ROMSX::prestep (int lev,
Array4<Real const> const& bustr = mf_bustr->const_array(mfi);
Array4<Real const> const& bvstr = mf_bvstr->const_array(mfi);

Real lambda = 1.0;
Real lambda = 1.0_rt;

Box bx = mfi.tilebox();
Box gbx = mfi.growntilebox();
Expand Down Expand Up @@ -139,13 +139,13 @@ ROMSX::prestep (int lev,
auto btflux= fab_btflux.array();

//From ini_fields and .in file
//fab_stflux.setVal(0.0);
//fab_stflux.setVal(0.0_rt);
//also set btflux=0 (as in ana_btflux.H)
ParallelFor(tbxp2,
[=] AMREX_GPU_DEVICE (int i, int j, int k)
{
stflux(i,j,k)=0.0;
btflux(i,j,k)=0.0;
stflux(i,j,k)=0.0_rt;
btflux(i,j,k)=0.0_rt;
});

for (int i_comp=0; i_comp < NCONS; i_comp++) {
Expand Down
Loading

0 comments on commit 7c83c33

Please sign in to comment.