From 1e7de3b536c974327513d17f9aee156d93030825 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 19 Oct 2020 10:17:46 +0200 Subject: [PATCH 01/30] Replace wherever possible '.reset(new' with '= make_unique' (#1429) * replace wherever possible .reset(new with = make_unique * fixed bug * fixed bug * revert WarpXOpenPMD.cpp to the original version * removed another .reset(new --- Source/BoundaryConditions/PML.cpp | 93 ++++++++++--------- Source/Diagnostics/BTDiagnostics.cpp | 8 +- .../Diagnostics/BackTransformedDiagnostic.cpp | 24 ++--- .../BackTransformFunctor.cpp | 15 +-- Source/Diagnostics/FieldIO.cpp | 14 +-- Source/Diagnostics/MultiDiagnostics.H | 2 + Source/Diagnostics/MultiDiagnostics.cpp | 4 +- .../Diagnostics/ParticleDiag/ParticleDiag.H | 2 + .../Diagnostics/ParticleDiag/ParticleDiag.cpp | 4 +- .../ReducedDiags/LoadBalanceCosts.cpp | 3 +- .../ReducedDiags/MultiReducedDiags.cpp | 28 +++--- .../ReducedDiags/ParticleHistogram.cpp | 7 +- Source/Diagnostics/SliceDiagnostic.cpp | 17 ++-- Source/Diagnostics/WarpXIO.cpp | 3 +- Source/FieldSolver/ElectrostaticSolver.cpp | 6 +- .../MacroscopicProperties.cpp | 15 +-- .../SpectralHankelTransformer.cpp | 8 +- .../SpectralSolver/SpectralSolver.cpp | 18 ++-- .../SpectralSolver/SpectralSolverRZ.cpp | 8 +- Source/Initialization/PlasmaInjector.H | 1 + Source/Initialization/PlasmaInjector.cpp | 17 ++-- Source/Initialization/WarpXInitData.cpp | 44 +++++---- Source/Parallelization/WarpXComm.cpp | 13 ++- Source/Parallelization/WarpXRegrid.cpp | 84 +++++++++-------- Source/Particles/MultiParticleContainer.cpp | 38 ++++---- .../Particles/PhysicalParticleContainer.cpp | 8 +- Source/Particles/WarpXParticleContainer.cpp | 2 +- Source/Utils/Interpolate.H | 2 + Source/Utils/Interpolate.cpp | 8 +- Source/WarpX.cpp | 32 +++---- 30 files changed, 282 insertions(+), 246 deletions(-) diff --git a/Source/BoundaryConditions/PML.cpp b/Source/BoundaryConditions/PML.cpp index 202867bdbb8..3824ddcef5e 100644 --- a/Source/BoundaryConditions/PML.cpp +++ b/Source/BoundaryConditions/PML.cpp @@ -20,6 +20,7 @@ #endif #include +#include using namespace amrex; @@ -493,18 +494,18 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, ngf = ngFFT; #endif - pml_E_fp[0].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getEfield_fp(0,0).ixType().toIntVect() ), dm, 3, nge ) ); - pml_E_fp[1].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getEfield_fp(0,1).ixType().toIntVect() ), dm, 3, nge ) ); - pml_E_fp[2].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getEfield_fp(0,2).ixType().toIntVect() ), dm, 3, nge ) ); - pml_B_fp[0].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getBfield_fp(0,0).ixType().toIntVect() ), dm, 2, ngb ) ); - pml_B_fp[1].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getBfield_fp(0,1).ixType().toIntVect() ), dm, 2, ngb ) ); - pml_B_fp[2].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getBfield_fp(0,2).ixType().toIntVect() ), dm, 2, ngb ) ); + pml_E_fp[0] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getEfield_fp(0,0).ixType().toIntVect() ), dm, 3, nge ); + pml_E_fp[1] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getEfield_fp(0,1).ixType().toIntVect() ), dm, 3, nge ); + pml_E_fp[2] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getEfield_fp(0,2).ixType().toIntVect() ), dm, 3, nge ); + pml_B_fp[0] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getBfield_fp(0,0).ixType().toIntVect() ), dm, 2, ngb ); + pml_B_fp[1] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getBfield_fp(0,1).ixType().toIntVect() ), dm, 2, ngb ); + pml_B_fp[2] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getBfield_fp(0,2).ixType().toIntVect() ), dm, 2, ngb ); pml_E_fp[0]->setVal(0.0); @@ -514,27 +515,27 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, pml_B_fp[1]->setVal(0.0); pml_B_fp[2]->setVal(0.0); - pml_j_fp[0].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getcurrent_fp(0,0).ixType().toIntVect() ), dm, 1, ngb ) ); - pml_j_fp[1].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getcurrent_fp(0,1).ixType().toIntVect() ), dm, 1, ngb ) ); - pml_j_fp[2].reset( new MultiFab( amrex::convert( ba, - WarpX::GetInstance().getcurrent_fp(0,2).ixType().toIntVect() ), dm, 1, ngb ) ); + pml_j_fp[0] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getcurrent_fp(0,0).ixType().toIntVect() ), dm, 1, ngb ); + pml_j_fp[1] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getcurrent_fp(0,1).ixType().toIntVect() ), dm, 1, ngb ); + pml_j_fp[2] = std::make_unique(amrex::convert( ba, + WarpX::GetInstance().getcurrent_fp(0,2).ixType().toIntVect() ), dm, 1, ngb ); pml_j_fp[0]->setVal(0.0); pml_j_fp[1]->setVal(0.0); pml_j_fp[2]->setVal(0.0); if (do_dive_cleaning) { - pml_F_fp.reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()), dm, 3, ngf)); + pml_F_fp = std::make_unique(amrex::convert(ba,IntVect::TheUnitVector()), dm, 3, ngf); pml_F_fp->setVal(0.0); } if (do_pml_in_domain){ - sigba_fp.reset(new MultiSigmaBox(ba, dm, grid_ba_reduced, geom->CellSize(), ncell, delta)); + sigba_fp = std::make_unique(ba, dm, grid_ba_reduced, geom->CellSize(), ncell, delta); } else { - sigba_fp.reset(new MultiSigmaBox(ba, dm, grid_ba, geom->CellSize(), ncell, delta)); + sigba_fp = std::make_unique(ba, dm, grid_ba, geom->CellSize(), ncell, delta); } @@ -547,8 +548,8 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, BoxArray realspace_ba = ba; // Copy box Array v_galilean_zero = {0,0,0}; realspace_ba.enclosedCells().grow(nge); // cell-centered + guard cells - spectral_solver_fp.reset( new SpectralSolver( realspace_ba, dm, - nox_fft, noy_fft, noz_fft, do_nodal, v_galilean_zero, dx, dt, in_pml ) ); + spectral_solver_fp = std::make_unique(realspace_ba, dm, + nox_fft, noy_fft, noz_fft, do_nodal, v_galilean_zero, dx, dt, in_pml ); #endif if (cgeom) @@ -568,18 +569,18 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, DistributionMapping cdm{cba}; - pml_E_cp[0].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getEfield_cp(1,0).ixType().toIntVect() ), cdm, 3, nge ) ); - pml_E_cp[1].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getEfield_cp(1,1).ixType().toIntVect() ), cdm, 3, nge ) ); - pml_E_cp[2].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getEfield_cp(1,2).ixType().toIntVect() ), cdm, 3, nge ) ); - pml_B_cp[0].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getBfield_cp(1,0).ixType().toIntVect() ), cdm, 2, ngb ) ); - pml_B_cp[1].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getBfield_cp(1,1).ixType().toIntVect() ), cdm, 2, ngb ) ); - pml_B_cp[2].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getBfield_cp(1,2).ixType().toIntVect() ), cdm, 2, ngb ) ); + pml_E_cp[0] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getEfield_cp(1,0).ixType().toIntVect() ), cdm, 3, nge ); + pml_E_cp[1] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getEfield_cp(1,1).ixType().toIntVect() ), cdm, 3, nge ); + pml_E_cp[2] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getEfield_cp(1,2).ixType().toIntVect() ), cdm, 3, nge ); + pml_B_cp[0] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getBfield_cp(1,0).ixType().toIntVect() ), cdm, 2, ngb ); + pml_B_cp[1] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getBfield_cp(1,1).ixType().toIntVect() ), cdm, 2, ngb ); + pml_B_cp[2] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getBfield_cp(1,2).ixType().toIntVect() ), cdm, 2, ngb ); pml_E_cp[0]->setVal(0.0); pml_E_cp[1]->setVal(0.0); @@ -590,24 +591,24 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, if (do_dive_cleaning) { - pml_F_cp.reset(new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()), cdm, 3, ngf)); + pml_F_cp = std::make_unique(amrex::convert(cba,IntVect::TheUnitVector()), cdm, 3, ngf); pml_F_cp->setVal(0.0); } - pml_j_cp[0].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getcurrent_cp(1,0).ixType().toIntVect() ), cdm, 1, ngb ) ); - pml_j_cp[1].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getcurrent_cp(1,1).ixType().toIntVect() ), cdm, 1, ngb ) ); - pml_j_cp[2].reset( new MultiFab( amrex::convert( cba, - WarpX::GetInstance().getcurrent_cp(1,2).ixType().toIntVect() ), cdm, 1, ngb ) ); + pml_j_cp[0] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getcurrent_cp(1,0).ixType().toIntVect() ), cdm, 1, ngb ); + pml_j_cp[1] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getcurrent_cp(1,1).ixType().toIntVect() ), cdm, 1, ngb ); + pml_j_cp[2] = std::make_unique(amrex::convert( cba, + WarpX::GetInstance().getcurrent_cp(1,2).ixType().toIntVect() ), cdm, 1, ngb ); pml_j_cp[0]->setVal(0.0); pml_j_cp[1]->setVal(0.0); pml_j_cp[2]->setVal(0.0); if (do_pml_in_domain){ - sigba_cp.reset(new MultiSigmaBox(cba, cdm, grid_cba_reduced, cgeom->CellSize(), ncell, delta)); + sigba_cp = std::make_unique(cba, cdm, grid_cba_reduced, cgeom->CellSize(), ncell, delta); } else { - sigba_cp.reset(new MultiSigmaBox(cba, cdm, grid_cba, cgeom->CellSize(), ncell, delta)); + sigba_cp = std::make_unique(cba, cdm, grid_cba, cgeom->CellSize(), ncell, delta); } #ifdef WARPX_USE_PSATD @@ -617,8 +618,8 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& /*grid_dm*/, // const bool in_pml = true; // Tells spectral solver to use split-PML equations realspace_cba.enclosedCells().grow(nge); // cell-centered + guard cells - spectral_solver_cp.reset( new SpectralSolver( realspace_cba, cdm, - nox_fft, noy_fft, noz_fft, do_nodal, v_galilean_zero, cdx, dt, in_pml ) ); + spectral_solver_cp = std::make_unique(realspace_cba, cdm, + nox_fft, noy_fft, noz_fft, do_nodal, v_galilean_zero, cdx, dt, in_pml ); #endif } } diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index d57af3ec0a2..b651874e4de 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -6,9 +6,13 @@ #include "ComputeDiagFunctors/BackTransformFunctor.H" #include "ComputeDiagFunctors/RhoFunctor.H" #include "Utils/CoarsenIO.H" + #include #include #include + +#include + using namespace amrex::literals; BTDiagnostics::BTDiagnostics (int i, std::string name) @@ -303,8 +307,8 @@ BTDiagnostics::DefineCellCenteredMultiFab(int lev) ba.coarsen(m_crse_ratio); amrex::DistributionMapping dmap = warpx.DistributionMap(lev); int ngrow = 1; - m_cell_centered_data[lev].reset( new amrex::MultiFab(ba, dmap, - m_cellcenter_varnames.size(), ngrow) ); + m_cell_centered_data[lev] = std::make_unique(ba, dmap, + m_cellcenter_varnames.size(), ngrow); } diff --git a/Source/Diagnostics/BackTransformedDiagnostic.cpp b/Source/Diagnostics/BackTransformedDiagnostic.cpp index 5a251ad1333..ee7f70f973b 100644 --- a/Source/Diagnostics/BackTransformedDiagnostic.cpp +++ b/Source/Diagnostics/BackTransformedDiagnostic.cpp @@ -12,6 +12,8 @@ #include "SliceDiagnostic.H" #include "WarpX.H" +#include + using namespace amrex; #ifdef WARPX_USE_HDF5 @@ -595,11 +597,11 @@ BackTransformedDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, prob_domain_lab.setLo(AMREX_SPACEDIM-1, zmin_lab + v_window_lab * t_lab); prob_domain_lab.setHi(AMREX_SPACEDIM-1, zmax_lab + v_window_lab * t_lab); Box diag_box = geom.Domain(); - m_LabFrameDiags_[i].reset(new LabFrameSnapShot(t_lab, t_boost, + m_LabFrameDiags_[i] = std::make_unique(t_lab, t_boost, m_inv_gamma_boost_, m_inv_beta_boost_, m_dz_lab_, prob_domain_lab, prob_ncells_lab, m_ncomp_to_dump, m_mesh_field_names, prob_domain_lab, - diag_box, i)); + diag_box, i); } @@ -675,11 +677,11 @@ BackTransformedDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, v_window_lab * t_slice_lab ); // construct labframeslice - m_LabFrameDiags_[i+N_snapshots].reset(new LabFrameSlice(t_slice_lab, t_boost, + m_LabFrameDiags_[i+N_snapshots] = std::make_unique(t_slice_lab, t_boost, m_inv_gamma_boost_, m_inv_beta_boost_, m_dz_lab_, prob_domain_lab, slice_ncells_lab, m_ncomp_to_dump, m_mesh_field_names, slice_dom_lab, - slicediag_box, i, m_particle_slice_width_lab_)); + slicediag_box, i, m_particle_slice_width_lab_); } // sort diags based on their respective t_lab std::stable_sort(m_LabFrameDiags_.begin(), m_LabFrameDiags_.end(), compare_tlab_uptr); @@ -826,8 +828,8 @@ writeLabFrameData(const MultiFab* cell_centered_data, BoxArray buff_ba(lf_diags->m_buff_box_); buff_ba.maxSize(m_max_box_size_); DistributionMapping buff_dm(buff_ba); - lf_diags->m_data_buffer_.reset( new MultiFab(buff_ba, - buff_dm, m_ncomp_to_dump, 0) ); + lf_diags->m_data_buffer_ = std::make_unique(buff_ba, + buff_dm, m_ncomp_to_dump, 0); } // ... reset particle buffer particles_buffer_[i] if (WarpX::do_back_transformed_particles) @@ -843,8 +845,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, if (lf_diags->m_t_lab != prev_t_lab ) { if (slice) { - slice.reset(new MultiFab); - slice.reset(nullptr); + slice = nullptr; } slice = amrex::get_slice_data(m_boost_direction_, lf_diags->m_current_z_boost, @@ -867,9 +868,9 @@ writeLabFrameData(const MultiFab* cell_centered_data, // Make it a BoxArray slice_ba BoxArray slice_ba(slice_box); slice_ba.maxSize(m_max_box_size_); - tmp_slice_ptr = std::unique_ptr(new MultiFab(slice_ba, + tmp_slice_ptr = std::make_unique(slice_ba, lf_diags->m_data_buffer_->DistributionMap(), - ncomp, 0)); + ncomp, 0); // slice is re-used if the t_lab of a diag is equal to // that of the previous diag. @@ -880,8 +881,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, tmp_slice_ptr->copy(*slice, 0, 0, ncomp); lf_diags->AddDataToBuffer(*tmp_slice_ptr, i_lab, map_actual_fields_to_dump); - tmp_slice_ptr.reset(new MultiFab); - tmp_slice_ptr.reset(nullptr); + tmp_slice_ptr = nullptr; } if (WarpX::do_back_transformed_particles) { diff --git a/Source/Diagnostics/ComputeDiagFunctors/BackTransformFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/BackTransformFunctor.cpp index 298a74c2bf9..f383738629d 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/BackTransformFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/BackTransformFunctor.cpp @@ -1,7 +1,11 @@ #include "BackTransformFunctor.H" #include "WarpX.H" + #include #include + +#include + using namespace amrex; BackTransformFunctor::BackTransformFunctor (amrex::MultiFab const * mf_src, int lev, @@ -50,8 +54,8 @@ BackTransformFunctor::operator ()(amrex::MultiFab& mf_dst, int /*dcomp*/, const // Define MultiFab with the distribution map of the destination multifab and // containing all ten components that were in the slice generated from m_mf_src. std::unique_ptr< amrex::MultiFab > tmp_slice_ptr = nullptr; - tmp_slice_ptr.reset( new MultiFab ( slice_ba, mf_dst.DistributionMap(), - slice->nComp(), 0) ); + tmp_slice_ptr = std::make_unique ( slice_ba, mf_dst.DistributionMap(), + slice->nComp(), 0 ); // Parallel copy the lab-frame data from "slice" MultiFab with // ncomp=10 and boosted-frame dmap to "tmp_slice_ptr" MultiFab with // ncomp=10 and dmap of the destination Multifab, which will store the final data @@ -96,11 +100,8 @@ BackTransformFunctor::operator ()(amrex::MultiFab& mf_dst, int /*dcomp*/, const } // Reset the temporary MultiFabs generated - slice.reset(new MultiFab); - slice.reset(nullptr); - tmp_slice_ptr.reset(new MultiFab); - tmp_slice_ptr.reset(nullptr); - + slice = nullptr; + tmp_slice_ptr = nullptr; } } diff --git a/Source/Diagnostics/FieldIO.cpp b/Source/Diagnostics/FieldIO.cpp index 10195eb998b..b1c5c27cfff 100644 --- a/Source/Diagnostics/FieldIO.cpp +++ b/Source/Diagnostics/FieldIO.cpp @@ -20,6 +20,8 @@ #include +#include + using namespace amrex; /** \brief @@ -121,15 +123,15 @@ AverageAndPackVectorField( MultiFab& mf_avg, if (vector_field[0]->nComp() > 1) { // With the RZ solver, if there are more than one component, the total // fields needs to be constructed in temporary MultiFabs. - vector_total[0].reset(new MultiFab(vector_field[0]->boxArray(), dm, 1, vector_field[0]->nGrowVect())); - vector_total[1].reset(new MultiFab(vector_field[1]->boxArray(), dm, 1, vector_field[1]->nGrowVect())); - vector_total[2].reset(new MultiFab(vector_field[2]->boxArray(), dm, 1, vector_field[2]->nGrowVect())); + vector_total[0] = std::make_unique(vector_field[0]->boxArray(), dm, 1, vector_field[0]->nGrowVect()); + vector_total[1] = std::make_unique(vector_field[1]->boxArray(), dm, 1, vector_field[1]->nGrowVect()); + vector_total[2] = std::make_unique(vector_field[2]->boxArray(), dm, 1, vector_field[2]->nGrowVect()); ConstructTotalRZVectorField(vector_total, vector_field); } else { // Create aliases of the MultiFabs - vector_total[0].reset(new MultiFab(*vector_field[0], amrex::make_alias, 0, 1)); - vector_total[1].reset(new MultiFab(*vector_field[1], amrex::make_alias, 0, 1)); - vector_total[2].reset(new MultiFab(*vector_field[2], amrex::make_alias, 0, 1)); + vector_total[0] = std::make_unique(*vector_field[0], amrex::make_alias, 0, 1); + vector_total[1] = std::make_unique(*vector_field[1], amrex::make_alias, 0, 1); + vector_total[2] = std::make_unique(*vector_field[2], amrex::make_alias, 0, 1); } #else const std::array,3> &vector_total = vector_field; diff --git a/Source/Diagnostics/MultiDiagnostics.H b/Source/Diagnostics/MultiDiagnostics.H index d0c64e623ce..f59dea7dde4 100644 --- a/Source/Diagnostics/MultiDiagnostics.H +++ b/Source/Diagnostics/MultiDiagnostics.H @@ -4,6 +4,8 @@ #include "FullDiagnostics.H" #include "BTDiagnostics.H" +#include + /** All types of diagnostics. */ enum struct DiagTypes {Full, BackTransformed}; diff --git a/Source/Diagnostics/MultiDiagnostics.cpp b/Source/Diagnostics/MultiDiagnostics.cpp index d9300187ee8..554e823e83c 100644 --- a/Source/Diagnostics/MultiDiagnostics.cpp +++ b/Source/Diagnostics/MultiDiagnostics.cpp @@ -12,9 +12,9 @@ MultiDiagnostics::MultiDiagnostics () alldiags.resize( ndiags ); for (int i=0; i(i, diags_names[i]); } else if ( diags_types[i] == DiagTypes::BackTransformed ){ - alldiags[i].reset( new BTDiagnostics(i, diags_names[i]) ); + alldiags[i] = std::make_unique(i, diags_names[i]); } else { amrex::Abort("Unknown diagnostic type"); } diff --git a/Source/Diagnostics/ParticleDiag/ParticleDiag.H b/Source/Diagnostics/ParticleDiag/ParticleDiag.H index 71a71fcc298..119a341b6a5 100644 --- a/Source/Diagnostics/ParticleDiag/ParticleDiag.H +++ b/Source/Diagnostics/ParticleDiag/ParticleDiag.H @@ -5,6 +5,8 @@ #include "Utils/WarpXUtil.H" #include "Particles/WarpXParticleContainer.H" +#include + class ParticleDiag { public: diff --git a/Source/Diagnostics/ParticleDiag/ParticleDiag.cpp b/Source/Diagnostics/ParticleDiag/ParticleDiag.cpp index 9a9fe205587..b6219ba5565 100644 --- a/Source/Diagnostics/ParticleDiag/ParticleDiag.cpp +++ b/Source/Diagnostics/ParticleDiag/ParticleDiag.cpp @@ -74,7 +74,7 @@ ParticleDiag::ParticleDiag(std::string diag_name, std::string name, WarpXParticl std::string function_string = ""; Store_parserString(pp,"plot_filter_function(t,x,y,z,ux,uy,uz)", function_string); - m_particle_filter_parser.reset(new ParserWrapper<7>( - makeParser(function_string,{"t","x","y","z","ux","uy","uz"}))); + m_particle_filter_parser = std::make_unique>( + makeParser(function_string,{"t","x","y","z","ux","uy","uz"})); } } diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp index 671355188c4..048aa7dab2e 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp @@ -9,6 +9,7 @@ #include "LoadBalanceCosts.H" #include "Utils/WarpXUtil.H" +#include using namespace amrex; @@ -58,7 +59,7 @@ void LoadBalanceCosts::ComputeDiags (int step) costs.resize(nLevels); for (int lev = 0; lev < nLevels; ++lev) { - costs[lev].reset(new amrex::LayoutData(*warpx.getCosts(lev))); + costs[lev] = std::make_unique>(*warpx.getCosts(lev)); } if (warpx.load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Heuristic) diff --git a/Source/Diagnostics/ReducedDiags/MultiReducedDiags.cpp b/Source/Diagnostics/ReducedDiags/MultiReducedDiags.cpp index a6bb16e57b1..226068f579b 100644 --- a/Source/Diagnostics/ReducedDiags/MultiReducedDiags.cpp +++ b/Source/Diagnostics/ReducedDiags/MultiReducedDiags.cpp @@ -48,38 +48,38 @@ MultiReducedDiags::MultiReducedDiags () // match diags if (rd_type.compare("ParticleEnergy") == 0) { - m_multi_rd[i_rd].reset - ( new ParticleEnergy(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("FieldEnergy") == 0) { - m_multi_rd[i_rd].reset - ( new FieldEnergy(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("FieldMaximum") == 0) { - m_multi_rd[i_rd].reset - ( new FieldMaximum(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("BeamRelevant") == 0) { - m_multi_rd[i_rd].reset - ( new BeamRelevant(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("LoadBalanceCosts") == 0) { - m_multi_rd[i_rd].reset - ( new LoadBalanceCosts(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("ParticleHistogram") == 0) { - m_multi_rd[i_rd].reset - ( new ParticleHistogram(m_rd_names[i_rd])); + m_multi_rd[i_rd] = + std::make_unique(m_rd_names[i_rd]); } else if (rd_type.compare("ParticleNumber") == 0) { - m_multi_rd[i_rd].reset - ( new ParticleNumber(m_rd_names[i_rd])); + m_multi_rd[i_rd]= + std::make_unique(m_rd_names[i_rd]); } else { Abort("No matching reduced diagnostics type found."); } diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp index 85624c6a19b..b2fd64a983c 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp @@ -8,9 +8,12 @@ #include "ParticleHistogram.H" #include "WarpX.H" #include "Utils/WarpXUtil.H" + #include #include + #include +#include using namespace amrex; @@ -44,8 +47,8 @@ ParticleHistogram::ParticleHistogram (std::string rd_name) std::string function_string = ""; Store_parserString(pp,"histogram_function(t,x,y,z,ux,uy,uz)", function_string); - m_parser.reset(new ParserWrapper( - makeParser(function_string,{"t","x","y","z","ux","uy","uz"}))); + m_parser = std::make_unique>( + makeParser(function_string,{"t","x","y","z","ux","uy","uz"})); // read normalization type std::string norm_string = "default"; diff --git a/Source/Diagnostics/SliceDiagnostic.cpp b/Source/Diagnostics/SliceDiagnostic.cpp index 1d0d2e39ce8..8b95217e7e4 100644 --- a/Source/Diagnostics/SliceDiagnostic.cpp +++ b/Source/Diagnostics/SliceDiagnostic.cpp @@ -11,6 +11,8 @@ #include +#include + using namespace amrex; @@ -113,8 +115,8 @@ CreateSlice( const MultiFab& mf, const Vector &dom_geom, Vector sdmap(1); sdmap[0] = DistributionMapping{sba[0]}; - smf.reset(new MultiFab(amrex::convert(sba[0],SliceType), sdmap[0], - ncomp, nghost)); + smf = std::make_unique(amrex::convert(sba[0],SliceType), sdmap[0], + ncomp, nghost); // Copy data from domain to slice that has same cell size as that of // // the domain mf. src and dst have the same number of ghost cells // @@ -137,8 +139,8 @@ CreateSlice( const MultiFab& mf, const Vector &dom_geom, AMREX_ALWAYS_ASSERT(crse_ba[0].size() == sba[0].size()); - cs_mf.reset( new MultiFab(amrex::convert(crse_ba[0],SliceType), - sdmap[0], ncomp,nghost)); + cs_mf = std::make_unique(amrex::convert(crse_ba[0],SliceType), + sdmap[0], ncomp,nghost); MultiFab& mfSrc = *smf; MultiFab& mfDst = *cs_mf; @@ -480,10 +482,3 @@ InterpolateLo(const Box& bx, FArrayBox &fabox, IntVect slice_lo, } } - - - - - - - diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp index 42261caf68f..6a2c124791a 100644 --- a/Source/Diagnostics/WarpXIO.cpp +++ b/Source/Diagnostics/WarpXIO.cpp @@ -24,6 +24,7 @@ # include #endif +#include using namespace amrex; @@ -251,7 +252,7 @@ WarpX::GetCellCenteredData() { for (int lev = 0; lev <= finest_level; ++lev) { - cc[lev].reset( new MultiFab(grids[lev], dmap[lev], nc, ng) ); + cc[lev] = std::make_unique(grids[lev], dmap[lev], nc, ng ); int dcomp = 0; // first the electric field diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 25f672f908c..73d7048b73b 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -11,6 +11,8 @@ #include +#include + using namespace amrex; void @@ -52,8 +54,8 @@ WarpX::AddSpaceChargeField (WarpXParticleContainer& pc) for (int lev = 0; lev <= max_level; lev++) { BoxArray nba = boxArray(lev); nba.surroundingNodes(); - rho[lev].reset(new MultiFab(nba, dmap[lev], 1, ng)); - phi[lev].reset(new MultiFab(nba, dmap[lev], 1, 1)); + rho[lev] = std::make_unique(nba, dmap[lev], 1, ng); + phi[lev] = std::make_unique(nba, dmap[lev], 1, 1); phi[lev]->setVal(0.); } diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index a368dc02682..2232c4e5b3d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -2,6 +2,8 @@ #include #include "WarpX.H" +#include + using namespace amrex; MacroscopicProperties::MacroscopicProperties () @@ -34,8 +36,8 @@ MacroscopicProperties::ReadParameters () // initialization of sigma (conductivity) with parser if (m_sigma_s == "parse_sigma_function") { Store_parserString(pp, "sigma_function(x,y,z)", m_str_sigma_function); - m_sigma_parser.reset(new ParserWrapper<3>( - makeParser(m_str_sigma_function,{"x","y","z"}) ) ); + m_sigma_parser = std::make_unique>( + makeParser(m_str_sigma_function,{"x","y","z"})); } bool epsilon_specified = false; @@ -54,8 +56,8 @@ MacroscopicProperties::ReadParameters () // initialization of epsilon (permittivity) with parser if (m_epsilon_s == "parse_epsilon_function") { Store_parserString(pp, "epsilon_function(x,y,z)", m_str_epsilon_function); - m_epsilon_parser.reset(new ParserWrapper<3>( - makeParser(m_str_epsilon_function,{"x","y","z"}) ) ); + m_epsilon_parser = std::make_unique>( + makeParser(m_str_epsilon_function,{"x","y","z"})); } // Query input for material permittivity, epsilon. @@ -75,8 +77,8 @@ MacroscopicProperties::ReadParameters () // initialization of mu (permeability) with parser if (m_mu_s == "parse_mu_function") { Store_parserString(pp, "mu_function(x,y,z)", m_str_mu_function); - m_mu_parser.reset(new ParserWrapper<3>( - makeParser(m_str_mu_function,{"x","y","z"}) ) ); + m_mu_parser = std::make_unique>( + makeParser(m_str_mu_function,{"x","y","z"})); } } @@ -194,4 +196,3 @@ MacroscopicProperties::InitializeMacroMultiFabUsingParser ( } - diff --git a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/SpectralHankelTransformer.cpp b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/SpectralHankelTransformer.cpp index 7886bd549aa..884ee5f4573 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/SpectralHankelTransformer.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/SpectralHankelTransformer.cpp @@ -7,6 +7,8 @@ #include "Utils/WarpXConst.H" #include "SpectralHankelTransformer.H" +#include + SpectralHankelTransformer::SpectralHankelTransformer (int const nr, int const n_rz_azimuthal_modes, amrex::Real const rmax) @@ -18,9 +20,9 @@ SpectralHankelTransformer::SpectralHankelTransformer (int const nr, dhtm.resize(m_n_rz_azimuthal_modes); for (int mode=0 ; mode < m_n_rz_azimuthal_modes ; mode++) { - dht0[mode].reset( new HankelTransform(mode , mode, m_nr, rmax) ); - dhtp[mode].reset( new HankelTransform(mode+1, mode, m_nr, rmax) ); - dhtm[mode].reset( new HankelTransform(mode-1, mode, m_nr, rmax) ); + dht0[mode] = std::make_unique(mode , mode, m_nr, rmax); + dhtp[mode] = std::make_unique(mode+1, mode, m_nr, rmax); + dhtm[mode] = std::make_unique(mode-1, mode, m_nr, rmax); } ExtractKrArray(); diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp index 5d2c954ce30..0cfd899dfd7 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolver.cpp @@ -14,6 +14,8 @@ #include "Utils/WarpXProfilerWrapper.H" #include "Utils/WarpXUtil.H" +#include + #if WARPX_USE_PSATD /* \brief Initialize the spectral Maxwell solver @@ -53,23 +55,23 @@ SpectralSolver::SpectralSolver( // Initialize the corresponding coefficients over k space if (pml) { - algorithm = std::unique_ptr( new PMLPsatdAlgorithm( - k_space, dm, norder_x, norder_y, norder_z, nodal, dt ) ); + algorithm = std::make_unique( + k_space, dm, norder_x, norder_y, norder_z, nodal, dt); } else { if (fft_do_time_averaging){ - algorithm = std::unique_ptr( new AvgGalileanAlgorithm( - k_space, dm, norder_x, norder_y, norder_z, nodal, v_galilean, dt ) ); + algorithm = std::make_unique( + k_space, dm, norder_x, norder_y, norder_z, nodal, v_galilean, dt); } else { if ((v_galilean[0]==0) && (v_galilean[1]==0) && (v_galilean[2]==0)){ // v_galilean is 0: use standard PSATD algorithm - algorithm = std::unique_ptr( new PsatdAlgorithm( - k_space, dm, norder_x, norder_y, norder_z, nodal, dt, update_with_rho ) ); + algorithm = std::make_unique( + k_space, dm, norder_x, norder_y, norder_z, nodal, dt, update_with_rho); } else { - algorithm = std::unique_ptr( new GalileanAlgorithm( - k_space, dm, norder_x, norder_y, norder_z, nodal, v_galilean, dt, update_with_rho ) ); + algorithm = std::make_unique( + k_space, dm, norder_x, norder_y, norder_z, nodal, v_galilean, dt, update_with_rho); } } } diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp index 38851ef50b0..581538d6ad6 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp @@ -45,12 +45,12 @@ SpectralSolverRZ::SpectralSolverRZ (amrex::BoxArray const & realspace_ba, // PML is not supported. if (v_galilean[2] == 0) { // v_galilean is 0: use standard PSATD algorithm - algorithm = std::unique_ptr( - new PsatdAlgorithmRZ(k_space, dm, n_rz_azimuthal_modes, norder_z, nodal, dt)); + algorithm = std::make_unique( + k_space, dm, n_rz_azimuthal_modes, norder_z, nodal, dt); } else { // Otherwise: use the Galilean algorithm - algorithm = std::unique_ptr( - new GalileanPsatdAlgorithmRZ(k_space, dm, n_rz_azimuthal_modes, norder_z, nodal, v_galilean, dt)); + algorithm = std::make_unique( + k_space, dm, n_rz_azimuthal_modes, norder_z, nodal, v_galilean, dt); } // - Initialize arrays for fields in spectral space + FFT plans diff --git a/Source/Initialization/PlasmaInjector.H b/Source/Initialization/PlasmaInjector.H index f8ef29faf42..62d6fed00cd 100644 --- a/Source/Initialization/PlasmaInjector.H +++ b/Source/Initialization/PlasmaInjector.H @@ -26,6 +26,7 @@ #endif #include +#include /// /// The PlasmaInjector class parses and stores information about the plasma diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 3930fd4de7b..69aefc47efc 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace amrex; @@ -230,8 +231,9 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) "(Please visit PR#765 for more information.)"); #endif // Construct InjectorPosition with InjectorPositionRandom. - h_inj_pos.reset(new InjectorPosition((InjectorPositionRandom*)nullptr, - xmin, xmax, ymin, ymax, zmin, zmax)); + h_inj_pos = std::make_unique( + (InjectorPositionRandom*)nullptr, + xmin, xmax, ymin, ymax, zmin, zmax); parseDensity(pp); parseMomentum(pp); } else if (part_pos_s == "nuniformpercell") { @@ -250,11 +252,12 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) "n_rz_azimuthal_modes (Please visit PR#765 for more information.)"); #endif // Construct InjectorPosition from InjectorPositionRegular. - h_inj_pos.reset(new InjectorPosition((InjectorPositionRegular*)nullptr, - xmin, xmax, ymin, ymax, zmin, zmax, - Dim3{num_particles_per_cell_each_dim[0], - num_particles_per_cell_each_dim[1], - num_particles_per_cell_each_dim[2]})); + h_inj_pos = std::make_unique( + (InjectorPositionRegular*)nullptr, + xmin, xmax, ymin, ymax, zmin, zmax, + Dim3{num_particles_per_cell_each_dim[0], + num_particles_per_cell_each_dim[1], + num_particles_per_cell_each_dim[2]}); num_particles_per_cell = num_particles_per_cell_each_dim[0] * num_particles_per_cell_each_dim[1] * num_particles_per_cell_each_dim[2]; diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index b1e64335486..14acc5647f0 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -22,6 +22,7 @@ # include #endif +#include using namespace amrex; @@ -127,7 +128,8 @@ WarpX::InitDiagnostics () { // Find the positions of the lab-frame box that corresponds to the boosted-frame box at t=0 Real zmin_lab = current_lo[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); Real zmax_lab = current_hi[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); - myBFD.reset(new BackTransformedDiagnostic(zmin_lab, + myBFD = std::make_unique( + zmin_lab, zmax_lab, moving_window_v, dt_snapshots_lab, num_snapshots_lab, @@ -136,7 +138,7 @@ WarpX::InitDiagnostics () { gamma_boost, t_new[0], dt_boost, moving_window_dir, geom[0], slice_realbox, - particle_slice_width_lab)); + particle_slice_width_lab); } } @@ -167,14 +169,14 @@ WarpX::InitPML () #ifdef WARPX_DIM_RZ do_pml_Lo_corrected[0] = 0; // no PML at r=0, in cylindrical geometry #endif - pml[0].reset(new PML(boxArray(0), DistributionMap(0), &Geom(0), nullptr, + pml[0] = std::make_unique(boxArray(0), DistributionMap(0), &Geom(0), nullptr, pml_ncell, pml_delta, 0, #ifdef WARPX_USE_PSATD dt[0], nox_fft, noy_fft, noz_fft, do_nodal, #endif do_dive_cleaning, do_moving_window, pml_has_particles, do_pml_in_domain, - do_pml_Lo_corrected, do_pml_Hi)); + do_pml_Lo_corrected, do_pml_Hi); for (int lev = 1; lev <= finest_level; ++lev) { amrex::IntVect do_pml_Lo_MR = amrex::IntVect::TheUnitVector(); @@ -184,7 +186,7 @@ WarpX::InitPML () do_pml_Lo_MR[0] = 0; } #endif - pml[lev].reset(new PML(boxArray(lev), DistributionMap(lev), + pml[lev] = std::make_unique(boxArray(lev), DistributionMap(lev), &Geom(lev), &Geom(lev-1), pml_ncell, pml_delta, refRatio(lev-1)[0], #ifdef WARPX_USE_PSATD @@ -192,7 +194,7 @@ WarpX::InitPML () #endif do_dive_cleaning, do_moving_window, pml_has_particles, do_pml_in_domain, - do_pml_Lo_MR, amrex::IntVect::TheUnitVector())); + do_pml_Lo_MR, amrex::IntVect::TheUnitVector()); } } } @@ -229,9 +231,11 @@ WarpX::InitNCICorrector () // Initialize Godfrey filters // Same filter for fields Ex, Ey and Bz const bool nodal_gather = !galerkin_interpolation; - nci_godfrey_filter_exeybz[lev].reset( new NCIGodfreyFilter(godfrey_coeff_set::Ex_Ey_Bz, cdtodz, nodal_gather) ); + nci_godfrey_filter_exeybz[lev] = std::make_unique( + godfrey_coeff_set::Ex_Ey_Bz, cdtodz, nodal_gather); // Same filter for fields Bx, By and Ez - nci_godfrey_filter_bxbyez[lev].reset( new NCIGodfreyFilter(godfrey_coeff_set::Bx_By_Ez, cdtodz, nodal_gather) ); + nci_godfrey_filter_bxbyez[lev] = std::make_unique( + godfrey_coeff_set::Bx_By_Ez, cdtodz, nodal_gather); // Compute Godfrey filters stencils nci_godfrey_filter_exeybz[lev]->ComputeStencils(); nci_godfrey_filter_bxbyez[lev]->ComputeStencils(); @@ -345,12 +349,12 @@ WarpX::InitLevelData (int lev, Real /*time*/) str_By_ext_grid_function); Store_parserString(pp, "Bz_external_grid_function(x,y,z)", str_Bz_ext_grid_function); - Bxfield_parser.reset(new ParserWrapper<3>( - makeParser(str_Bx_ext_grid_function,{"x","y","z"}))); - Byfield_parser.reset(new ParserWrapper<3>( - makeParser(str_By_ext_grid_function,{"x","y","z"}))); - Bzfield_parser.reset(new ParserWrapper<3>( - makeParser(str_Bz_ext_grid_function,{"x","y","z"}))); + Bxfield_parser = std::make_unique>( + makeParser(str_Bx_ext_grid_function,{"x","y","z"})); + Byfield_parser = std::make_unique>( + makeParser(str_By_ext_grid_function,{"x","y","z"})); + Bzfield_parser = std::make_unique>( + makeParser(str_Bz_ext_grid_function,{"x","y","z"})); // Initialize Bfield_fp with external function InitializeExternalFieldsOnGridUsingParser(Bfield_fp[lev][0].get(), @@ -394,12 +398,12 @@ WarpX::InitLevelData (int lev, Real /*time*/) Store_parserString(pp, "Ez_external_grid_function(x,y,z)", str_Ez_ext_grid_function); - Exfield_parser.reset(new ParserWrapper<3>( - makeParser(str_Ex_ext_grid_function,{"x","y","z"}))); - Eyfield_parser.reset(new ParserWrapper<3>( - makeParser(str_Ey_ext_grid_function,{"x","y","z"}))); - Ezfield_parser.reset(new ParserWrapper<3>( - makeParser(str_Ez_ext_grid_function,{"x","y","z"}))); + Exfield_parser = std::make_unique>( + makeParser(str_Ex_ext_grid_function,{"x","y","z"})); + Eyfield_parser = std::make_unique>( + makeParser(str_Ey_ext_grid_function,{"x","y","z"})); + Ezfield_parser = std::make_unique>( + makeParser(str_Ez_ext_grid_function,{"x","y","z"})); // Initialize Efield_fp with external function InitializeExternalFieldsOnGridUsingParser(Efield_fp[lev][0].get(), diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp index ac619a9377a..667be0696f6 100644 --- a/Source/Parallelization/WarpXComm.cpp +++ b/Source/Parallelization/WarpXComm.cpp @@ -14,6 +14,8 @@ #include #include +#include + using namespace amrex; void @@ -114,12 +116,13 @@ WarpX::UpdateAuxilaryDataStagToNodal () Array,3> Btmp; if (Bfield_cax[lev][0]) { for (int i = 0; i < 3; ++i) { - Btmp[i].reset(new MultiFab(*Bfield_cax[lev][i], amrex::make_alias, 0, 1)); + Btmp[i] = std::make_unique( + *Bfield_cax[lev][i], amrex::make_alias, 0, 1); } } else { IntVect ngtmp = Bfield_aux[lev-1][0]->nGrowVect(); for (int i = 0; i < 3; ++i) { - Btmp[i].reset(new MultiFab(cnba, dm, 1, ngtmp)); + Btmp[i] = std::make_unique(cnba, dm, 1, ngtmp); } } // ParallelCopy from coarse level @@ -162,12 +165,14 @@ WarpX::UpdateAuxilaryDataStagToNodal () Array,3> Etmp; if (Efield_cax[lev][0]) { for (int i = 0; i < 3; ++i) { - Etmp[i].reset(new MultiFab(*Efield_cax[lev][i], amrex::make_alias, 0, 1)); + Etmp[i] = std::make_unique( + *Efield_cax[lev][i], amrex::make_alias, 0, 1); } } else { IntVect ngtmp = Efield_aux[lev-1][0]->nGrowVect(); for (int i = 0; i < 3; ++i) { - Etmp[i].reset(new MultiFab(cnba, dm, 1, ngtmp)); + Etmp[i] = std::make_unique( + cnba, dm, 1, ngtmp); } } // ParallelCopy from coarse level diff --git a/Source/Parallelization/WarpXRegrid.cpp b/Source/Parallelization/WarpXRegrid.cpp index 374948aa8ef..1fdfd6564e6 100644 --- a/Source/Parallelization/WarpXRegrid.cpp +++ b/Source/Parallelization/WarpXRegrid.cpp @@ -11,6 +11,8 @@ #include +#include + using namespace amrex; void @@ -107,29 +109,29 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi { { const IntVect& ng = Bfield_fp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Bfield_fp[lev][idim]->boxArray(), - dm, Bfield_fp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Bfield_fp[lev][idim]->boxArray(), + dm, Bfield_fp[lev][idim]->nComp(), ng); pmf->Redistribute(*Bfield_fp[lev][idim], 0, 0, Bfield_fp[lev][idim]->nComp(), ng); Bfield_fp[lev][idim] = std::move(pmf); } { const IntVect& ng = Efield_fp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Efield_fp[lev][idim]->boxArray(), - dm, Efield_fp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Efield_fp[lev][idim]->boxArray(), + dm, Efield_fp[lev][idim]->nComp(), ng); pmf->Redistribute(*Efield_fp[lev][idim], 0, 0, Efield_fp[lev][idim]->nComp(), ng); Efield_fp[lev][idim] = std::move(pmf); } { const IntVect& ng = current_fp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(current_fp[lev][idim]->boxArray(), - dm, current_fp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(current_fp[lev][idim]->boxArray(), + dm, current_fp[lev][idim]->nComp(), ng); current_fp[lev][idim] = std::move(pmf); } if (current_store[lev][idim]) { const IntVect& ng = current_store[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(current_store[lev][idim]->boxArray(), - dm, current_store[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(current_store[lev][idim]->boxArray(), + dm, current_store[lev][idim]->nComp(), ng); // no need to redistribute current_store[lev][idim] = std::move(pmf); } @@ -137,8 +139,8 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (F_fp[lev] != nullptr) { const IntVect& ng = F_fp[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(F_fp[lev]->boxArray(), - dm, F_fp[lev]->nComp(), ng)); + auto pmf = std::make_unique(F_fp[lev]->boxArray(), + dm, F_fp[lev]->nComp(), ng); pmf->Redistribute(*F_fp[lev], 0, 0, F_fp[lev]->nComp(), ng); F_fp[lev] = std::move(pmf); } @@ -146,8 +148,8 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (rho_fp[lev] != nullptr) { const int nc = rho_fp[lev]->nComp(); const IntVect& ng = rho_fp[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(rho_fp[lev]->boxArray(), - dm, nc, ng)); + auto pmf = std::make_unique(rho_fp[lev]->boxArray(), + dm, nc, ng); rho_fp[lev] = std::move(pmf); } @@ -155,23 +157,23 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (lev == 0 && Bfield_aux[0][0]->ixType() == Bfield_fp[0][0]->ixType()) { for (int idim = 0; idim < 3; ++idim) { - Bfield_aux[lev][idim].reset(new MultiFab(*Bfield_fp[lev][idim], amrex::make_alias, 0, Bfield_aux[lev][idim]->nComp())); - Efield_aux[lev][idim].reset(new MultiFab(*Efield_fp[lev][idim], amrex::make_alias, 0, Efield_aux[lev][idim]->nComp())); + Bfield_aux[lev][idim] = std::make_unique(*Bfield_fp[lev][idim], amrex::make_alias, 0, Bfield_aux[lev][idim]->nComp()); + Efield_aux[lev][idim] = std::make_unique(*Efield_fp[lev][idim], amrex::make_alias, 0, Efield_aux[lev][idim]->nComp()); } } else { for (int idim=0; idim < 3; ++idim) { { const IntVect& ng = Bfield_aux[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Bfield_aux[lev][idim]->boxArray(), - dm, Bfield_aux[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Bfield_aux[lev][idim]->boxArray(), + dm, Bfield_aux[lev][idim]->nComp(), ng); // pmf->Redistribute(*Bfield_aux[lev][idim], 0, 0, Bfield_aux[lev][idim]->nComp(), ng); Bfield_aux[lev][idim] = std::move(pmf); } { const IntVect& ng = Efield_aux[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Efield_aux[lev][idim]->boxArray(), - dm, Efield_aux[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Efield_aux[lev][idim]->boxArray(), + dm, Efield_aux[lev][idim]->nComp(), ng); // pmf->Redistribute(*Efield_aux[lev][idim], 0, 0, Efield_aux[lev][idim]->nComp(), ng); Efield_aux[lev][idim] = std::move(pmf); } @@ -184,30 +186,30 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi { { const IntVect& ng = Bfield_cp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Bfield_cp[lev][idim]->boxArray(), - dm, Bfield_cp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Bfield_cp[lev][idim]->boxArray(), + dm, Bfield_cp[lev][idim]->nComp(), ng); pmf->Redistribute(*Bfield_cp[lev][idim], 0, 0, Bfield_cp[lev][idim]->nComp(), ng); Bfield_cp[lev][idim] = std::move(pmf); } { const IntVect& ng = Efield_cp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Efield_cp[lev][idim]->boxArray(), - dm, Efield_cp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Efield_cp[lev][idim]->boxArray(), + dm, Efield_cp[lev][idim]->nComp(), ng); pmf->Redistribute(*Efield_cp[lev][idim], 0, 0, Efield_cp[lev][idim]->nComp(), ng); Efield_cp[lev][idim] = std::move(pmf); } { const IntVect& ng = current_cp[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr( new MultiFab(current_cp[lev][idim]->boxArray(), - dm, current_cp[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(current_cp[lev][idim]->boxArray(), + dm, current_cp[lev][idim]->nComp(), ng); current_cp[lev][idim] = std::move(pmf); } } if (F_cp[lev] != nullptr) { const IntVect& ng = F_cp[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(F_cp[lev]->boxArray(), - dm, F_cp[lev]->nComp(), ng)); + auto pmf = std::make_unique(F_cp[lev]->boxArray(), + dm, F_cp[lev]->nComp(), ng); pmf->Redistribute(*F_cp[lev], 0, 0, F_cp[lev]->nComp(), ng); F_cp[lev] = std::move(pmf); } @@ -215,8 +217,8 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (rho_cp[lev] != nullptr) { const int nc = rho_cp[lev]->nComp(); const IntVect& ng = rho_cp[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(rho_cp[lev]->boxArray(), - dm, nc, ng)); + auto pmf = std::make_unique(rho_cp[lev]->boxArray(), + dm, nc, ng); rho_cp[lev] = std::move(pmf); } } @@ -227,24 +229,24 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (Bfield_cax[lev][idim]) { const IntVect& ng = Bfield_cax[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Bfield_cax[lev][idim]->boxArray(), - dm, Bfield_cax[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Bfield_cax[lev][idim]->boxArray(), + dm, Bfield_cax[lev][idim]->nComp(), ng); // pmf->ParallelCopy(*Bfield_cax[lev][idim], 0, 0, Bfield_cax[lev][idim]->nComp(), ng, ng); Bfield_cax[lev][idim] = std::move(pmf); } if (Efield_cax[lev][idim]) { const IntVect& ng = Efield_cax[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(Efield_cax[lev][idim]->boxArray(), - dm, Efield_cax[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(Efield_cax[lev][idim]->boxArray(), + dm, Efield_cax[lev][idim]->nComp(), ng); // pmf->ParallelCopy(*Efield_cax[lev][idim], 0, 0, Efield_cax[lev][idim]->nComp(), ng, ng); Efield_cax[lev][idim] = std::move(pmf); } if (current_buf[lev][idim]) { const IntVect& ng = current_buf[lev][idim]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(current_buf[lev][idim]->boxArray(), - dm, current_buf[lev][idim]->nComp(), ng)); + auto pmf = std::make_unique(current_buf[lev][idim]->boxArray(), + dm, current_buf[lev][idim]->nComp(), ng); // pmf->ParallelCopy(*current_buf[lev][idim], 0, 0, current_buf[lev][idim]->nComp(), ng, ng); current_buf[lev][idim] = std::move(pmf); } @@ -252,24 +254,24 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (charge_buf[lev]) { const IntVect& ng = charge_buf[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new MultiFab(charge_buf[lev]->boxArray(), - dm, charge_buf[lev]->nComp(), ng)); + auto pmf = std::make_unique(charge_buf[lev]->boxArray(), + dm, charge_buf[lev]->nComp(), ng); // pmf->ParallelCopy(*charge_buf[lev][idim], 0, 0, charge_buf[lev]->nComp(), ng, ng); charge_buf[lev] = std::move(pmf); } if (current_buffer_masks[lev]) { const IntVect& ng = current_buffer_masks[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new iMultiFab(current_buffer_masks[lev]->boxArray(), - dm, current_buffer_masks[lev]->nComp(), ng)); + auto pmf = std::make_unique(current_buffer_masks[lev]->boxArray(), + dm, current_buffer_masks[lev]->nComp(), ng); // pmf->ParallelCopy(*current_buffer_masks[lev], 0, 0, current_buffer_masks[lev]->nComp(), ng, ng); current_buffer_masks[lev] = std::move(pmf); } if (gather_buffer_masks[lev]) { const IntVect& ng = gather_buffer_masks[lev]->nGrowVect(); - auto pmf = std::unique_ptr(new iMultiFab(gather_buffer_masks[lev]->boxArray(), - dm, gather_buffer_masks[lev]->nComp(), ng)); + auto pmf = std::make_unique(gather_buffer_masks[lev]->boxArray(), + dm, gather_buffer_masks[lev]->nComp(), ng); // pmf->ParallelCopy(*gather_buffer_masks[lev], 0, 0, gather_buffer_masks[lev]->nComp(), ng, ng); gather_buffer_masks[lev] = std::move(pmf); } @@ -277,7 +279,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi if (costs[lev] != nullptr) { - costs[lev].reset(new amrex::LayoutData(ba, dm)); + costs[lev] = std::make_unique>(ba, dm); for (int i : costs[lev]->IndexArray()) { (*costs[lev])[i] = 0.0; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index d3e794b5d96..ef23f9de543 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -39,23 +39,23 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers.resize(nspecies + nlasers); for (int i = 0; i < nspecies; ++i) { if (species_types[i] == PCTypes::Physical) { - allcontainers[i].reset(new PhysicalParticleContainer(amr_core, i, species_names[i])); + allcontainers[i] = std::make_unique(amr_core, i, species_names[i]); } else if (species_types[i] == PCTypes::RigidInjected) { - allcontainers[i].reset(new RigidInjectedParticleContainer(amr_core, i, species_names[i])); + allcontainers[i] = std::make_unique(amr_core, i, species_names[i]); } else if (species_types[i] == PCTypes::Photon) { - allcontainers[i].reset(new PhotonParticleContainer(amr_core, i, species_names[i])); + allcontainers[i] = std::make_unique(amr_core, i, species_names[i]); } allcontainers[i]->m_deposit_on_main_grid = m_deposit_on_main_grid[i]; allcontainers[i]->m_gather_from_main_grid = m_gather_from_main_grid[i]; } for (int i = nspecies; i < nspecies+nlasers; ++i) { - allcontainers[i].reset(new LaserParticleContainer(amr_core, i, lasers_names[i-nspecies])); + allcontainers[i] = std::make_unique(amr_core, i, lasers_names[i-nspecies]); } - pc_tmp.reset(new PhysicalParticleContainer(amr_core)); + pc_tmp = std::make_unique(amr_core); // Compute the number of species for which lab-frame data is dumped // nspecies_lab_frame_diags, and map their ID to MultiParticleContainer @@ -75,8 +75,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) auto const ncollisions = collision_names.size(); allcollisions.resize(ncollisions); for (int i = 0; i < static_cast(ncollisions); ++i) { - allcollisions[i].reset - (new CollisionType(species_names, collision_names[i])); + allcollisions[i] = + std::make_unique(species_names, collision_names[i]); } } @@ -139,12 +139,12 @@ MultiParticleContainer::ReadParameters () str_Bz_ext_particle_function); // Parser for B_external on the particle - m_Bx_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_Bx_ext_particle_function,{"x","y","z","t"}))); - m_By_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_By_ext_particle_function,{"x","y","z","t"}))); - m_Bz_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_Bz_ext_particle_function,{"x","y","z","t"}))); + m_Bx_particle_parser = std::make_unique>( + makeParser(str_Bx_ext_particle_function,{"x","y","z","t"})); + m_By_particle_parser = std::make_unique>( + makeParser(str_By_ext_particle_function,{"x","y","z","t"})); + m_Bz_particle_parser = std::make_unique>( + makeParser(str_Bz_ext_particle_function,{"x","y","z","t"})); } @@ -164,12 +164,12 @@ MultiParticleContainer::ReadParameters () Store_parserString(pp, "Ez_external_particle_function(x,y,z,t)", str_Ez_ext_particle_function); // Parser for E_external on the particle - m_Ex_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_Ex_ext_particle_function,{"x","y","z","t"}))); - m_Ey_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_Ey_ext_particle_function,{"x","y","z","t"}))); - m_Ez_particle_parser.reset(new ParserWrapper<4>( - makeParser(str_Ez_ext_particle_function,{"x","y","z","t"}))); + m_Ex_particle_parser = std::make_unique>( + makeParser(str_Ex_ext_particle_function,{"x","y","z","t"})); + m_Ey_particle_parser = std::make_unique>( + makeParser(str_Ey_ext_particle_function,{"x","y","z","t"})); + m_Ez_particle_parser = std::make_unique>( + makeParser(str_Ez_ext_particle_function,{"x","y","z","t"})); } diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 107ac10bd0a..7af6c4dd3aa 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -96,7 +96,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp { BackwardCompatibility(); - plasma_injector.reset(new PlasmaInjector(species_id, species_name)); + plasma_injector = std::make_unique(species_id, species_name); physical_species = plasma_injector->getPhysicalSpecies(); charge = plasma_injector->getCharge(); mass = plasma_injector->getMass(); @@ -179,8 +179,8 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp std::string function_string = ""; Store_parserString(pp,"plot_filter_function(t,x,y,z,ux,uy,uz)", function_string); - m_particle_filter_parser.reset(new ParserWrapper<7>( - makeParser(function_string,{"t","x","y","z","ux","uy","uz"}))); + m_particle_filter_parser = std::make_unique>( + makeParser(function_string,{"t","x","y","z","ux","uy","uz"})); } } @@ -188,7 +188,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core) : WarpXParticleContainer(amr_core, 0) { - plasma_injector.reset(new PlasmaInjector()); + plasma_injector = std::make_unique(); } void diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index ba1e2b43858..2374703fc59 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -632,7 +632,7 @@ WarpXParticleContainer::GetChargeDensity (int lev, bool local) WarpX& warpx = WarpX::GetInstance(); const int ng_rho = warpx.get_ng_depos_rho().max(); - auto rho = std::unique_ptr(new MultiFab(nba,dm,WarpX::ncomps,ng_rho)); + auto rho = std::make_unique(nba,dm,WarpX::ncomps,ng_rho); rho->setVal(0.0); #ifdef _OPENMP diff --git a/Source/Utils/Interpolate.H b/Source/Utils/Interpolate.H index 96112cb2446..cf4efaedd05 100644 --- a/Source/Utils/Interpolate.H +++ b/Source/Utils/Interpolate.H @@ -3,6 +3,8 @@ #include "WarpX.H" +#include + namespace Interpolate { using namespace amrex; diff --git a/Source/Utils/Interpolate.cpp b/Source/Utils/Interpolate.cpp index 11d6989a05b..73bd530b8f9 100644 --- a/Source/Utils/Interpolate.cpp +++ b/Source/Utils/Interpolate.cpp @@ -13,7 +13,7 @@ namespace Interpolate { // Prepare the structure that will contain the returned fields std::unique_ptr interpolated_F; - interpolated_F.reset( new MultiFab(F_fp.boxArray(), dm, 1, ngrow) ); + interpolated_F = std::make_unique(F_fp.boxArray(), dm, 1, ngrow); interpolated_F->setVal(0.); // Loop through the boxes and interpolate the values from the _cp data @@ -61,9 +61,9 @@ namespace Interpolate // Prepare the structure that will contain the returned fields std::array, 3> interpolated_F; - interpolated_F[0].reset( new MultiFab(Fx_fp->boxArray(), dm, 1, ngrow) ); - interpolated_F[1].reset( new MultiFab(Fy_fp->boxArray(), dm, 1, ngrow) ); - interpolated_F[2].reset( new MultiFab(Fz_fp->boxArray(), dm, 1, ngrow) ); + interpolated_F[0] = std::make_unique(Fx_fp->boxArray(), dm, 1, ngrow); + interpolated_F[1] = std::make_unique(Fy_fp->boxArray(), dm, 1, ngrow); + interpolated_F[2] = std::make_unique(Fz_fp->boxArray(), dm, 1, ngrow); IntVect fx_type = interpolated_F[0]->ixType().toIntVect(); IntVect fy_type = interpolated_F[1]->ixType().toIntVect(); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 027d9b9260a..740eaacba96 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -173,7 +173,7 @@ WarpX::WarpX () dt.resize(nlevs_max, std::numeric_limits::max()); // Particle Container - mypc = std::unique_ptr (new MultiParticleContainer(this)); + mypc = std::make_unique(this); warpx_do_continuous_injection = mypc->doContinuousInjection(); if (warpx_do_continuous_injection){ if (moving_window_v >= 0){ @@ -187,7 +187,7 @@ WarpX::WarpX () do_back_transformed_particles = mypc->doBackTransformedDiagnostics(); // Diagnostics - multi_diags = std::unique_ptr (new MultiDiagnostics()); + multi_diags = std::make_unique(); /** create object for reduced diagnostics */ reduced_diags = new MultiReducedDiags(); @@ -229,7 +229,7 @@ WarpX::WarpX () if (em_solver_medium == MediumForEM::Macroscopic) { // create object for macroscopic solver - m_macroscopic_properties = std::unique_ptr (new MacroscopicProperties()); + m_macroscopic_properties = std::make_unique(); } @@ -975,7 +975,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (do_dive_cleaning || (plot_rho && do_back_transformed_diagnostics)) { - rho_fp[lev].reset(new MultiFab(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho)); + rho_fp[lev] = std::make_unique(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho); } if (do_subcycling == 1 && lev == 0) @@ -987,12 +987,12 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (do_dive_cleaning) { - F_fp[lev].reset (new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,ncomps, ngF.max())); + F_fp[lev] = std::make_unique(amrex::convert(ba,IntVect::TheUnitVector()),dm,ncomps, ngF.max()); } #ifdef WARPX_USE_PSATD else { - rho_fp[lev].reset(new MultiFab(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho)); + rho_fp[lev] = std::make_unique(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho); } // Allocate and initialize the spectral solver # if (AMREX_SPACEDIM == 3) @@ -1057,11 +1057,11 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm else if (lev == 0) { for (int idir = 0; idir < 3; ++idir) { - Efield_aux[lev][idir].reset(new MultiFab(*Efield_fp[lev][idir], amrex::make_alias, 0, ncomps)); - Bfield_aux[lev][idir].reset(new MultiFab(*Bfield_fp[lev][idir], amrex::make_alias, 0, ncomps)); + Efield_aux[lev][idir] = std::make_unique(*Efield_fp[lev][idir], amrex::make_alias, 0, ncomps); + Bfield_aux[lev][idir] = std::make_unique(*Bfield_fp[lev][idir], amrex::make_alias, 0, ncomps); - Efield_avg_aux[lev][idir].reset(new MultiFab(*Efield_avg_fp[lev][idir], amrex::make_alias, 0, ncomps)); - Bfield_avg_aux[lev][idir].reset(new MultiFab(*Bfield_avg_fp[lev][idir], amrex::make_alias, 0, ncomps)); + Efield_avg_aux[lev][idir] = std::make_unique(*Efield_avg_fp[lev][idir], amrex::make_alias, 0, ncomps); + Bfield_avg_aux[lev][idir] = std::make_unique(*Bfield_avg_fp[lev][idir], amrex::make_alias, 0, ncomps); } } else @@ -1120,16 +1120,16 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm current_cp[lev][2] = std::make_unique(amrex::convert(cba,jz_nodal_flag),dm,ncomps,ngJ); if (do_dive_cleaning || (plot_rho && do_back_transformed_diagnostics)) { - rho_cp[lev].reset(new MultiFab(amrex::convert(cba,rho_nodal_flag),dm,2*ncomps,ngRho)); + rho_cp[lev] = std::make_unique(amrex::convert(cba,rho_nodal_flag),dm,2*ncomps,ngRho); } if (do_dive_cleaning) { - F_cp[lev].reset (new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()),dm,ncomps, ngF.max())); + F_cp[lev] = std::make_unique(amrex::convert(cba,IntVect::TheUnitVector()),dm,ncomps, ngF.max()); } #ifdef WARPX_USE_PSATD else { - rho_cp[lev].reset(new MultiFab(amrex::convert(cba,rho_nodal_flag),dm,2*ncomps,ngRho)); + rho_cp[lev] = std::make_unique(amrex::convert(cba,rho_nodal_flag),dm,2*ncomps,ngRho); } // Allocate and initialize the spectral solver # if (AMREX_SPACEDIM == 3) @@ -1155,8 +1155,8 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm pml_flag_false, fft_periodic_single_box, update_with_rho, fft_do_time_averaging ); # endif #endif - m_fdtd_solver_cp[lev].reset( - new FiniteDifferenceSolver( maxwell_solver_id, cdx, do_nodal ) ); + m_fdtd_solver_cp[lev] = std::make_unique( + maxwell_solver_id, cdx, do_nodal); } // @@ -1209,7 +1209,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (load_balance_intervals.isActivated()) { - costs[lev].reset(new amrex::LayoutData(ba, dm)); + costs[lev] = std::make_unique>(ba, dm); } } From 4f32c2eb2961436118412f3d3ec53cc12d1b65f1 Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 19 Oct 2020 17:47:30 -0700 Subject: [PATCH 02/30] RZ PSATD, in forward transforms, initialize the copies to zero if needed (#1445) --- .../SpectralSolver/SpectralFieldDataRZ.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp index c98c7983590..c2d8dfe94f9 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp @@ -423,6 +423,11 @@ SpectralFieldDataRZ::ForwardTransform (amrex::MultiFab const & field_mf, int con // field_mf does not. amrex::Box const& realspace_bx = tempHTransformed[mfi].box(); + if ( !(field_mf[mfi].box().contains(field_mf_copy[mfi].box())) ) { + // If field_mf[mfi] is smaller than field_mf_copy[mfi], then fill field_mf_copy[mfi] with + // zeros so that all of it is initialized. + field_mf_copy[mfi].setVal(0._rt, realspace_bx, 0, ncomp); + } field_mf_copy[mfi].copy(field_mf[mfi], i_comp*ncomp, 0, ncomp); multi_spectral_hankel_transformer[mfi].PhysicalToSpectral_Scalar(field_mf_copy[mfi], tempHTransformedSplit[mfi]); @@ -456,6 +461,12 @@ SpectralFieldDataRZ::ForwardTransform (amrex::MultiFab const & field_mf_r, int c amrex::Box const& realspace_bx = tempHTransformed[mfi].box(); + if ( !(field_mf_r[mfi].box().contains(field_mf_r_copy[mfi].box())) ) { + // If field_mf_r[mfi] is smaller than field_mf_r_copy[mfi], then fill field_mf_r_copy[mfi] with + // zeros so that all of it is initialized. + field_mf_r_copy[mfi].setVal(0._rt, realspace_bx, 0, 2*n_rz_azimuthal_modes); + field_mf_t_copy[mfi].setVal(0._rt, realspace_bx, 0, 2*n_rz_azimuthal_modes); + } field_mf_r_copy[mfi].copy(field_mf_r[mfi], 0, 0, 1); // Real part of mode 0 field_mf_t_copy[mfi].copy(field_mf_t[mfi], 0, 0, 1); // Real part of mode 0 field_mf_r_copy[mfi].setVal(0._rt, realspace_bx, 1, 1); // Imaginary part of mode 0 From 66db5f4787c0067c0ab9853b820e605415151bc4 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 20 Oct 2020 17:30:15 -0700 Subject: [PATCH 03/30] CI & CMake: HIP Support (#1436) Add AMD HIP support to CMake and test it in CI (single-precision build). --- .github/workflows/dependencies/hip.sh | 49 +++++++++++++++++++++++++++ .github/workflows/ubuntu.yml | 20 +++++++++++ CMakeLists.txt | 2 +- Docs/source/building/cmake.rst | 2 +- cmake/dependencies/AMReX.cmake | 14 +++++--- 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100755 .github/workflows/dependencies/hip.sh diff --git a/.github/workflows/dependencies/hip.sh b/.github/workflows/dependencies/hip.sh new file mode 100755 index 00000000000..ee8e2a6fe10 --- /dev/null +++ b/.github/workflows/dependencies/hip.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# Copyright 2020 The WarpX Community +# +# License: BSD-3-Clause-LBNL +# Authors: Axel Huebl + +# search recursive inside a folder if a file contains tabs +# +# @result 0 if no files are found, else 1 +# + +set -eu -o pipefail + +# Ref.: https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#ubuntu +wget -q -O - http://repo.radeon.com/rocm/rocm.gpg.key \ + | sudo apt-key add - +echo 'deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main' \ + | sudo tee /etc/apt/sources.list.d/rocm.list + +echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin' \ + | sudo tee -a /etc/profile.d/rocm.sh +# we should not need to export HIP_PATH=/opt/rocm/hip with those installs + +sudo apt-get update + +# Ref.: https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#installing-development-packages-for-cross-compilation +# meta-package: rocm-dkms +# OpenCL: rocm-opencl +# other: rocm-dev rocm-utils +sudo apt-get install -y --no-install-recommends \ + build-essential \ + gfortran \ + libnuma-dev \ + libopenmpi-dev \ + openmpi-bin \ + rocm-dev \ + rocrand + +# activate +# +source /etc/profile.d/rocm.sh +hipcc --version + +# cmake-easyinstall +# +sudo curl -L -o /usr/local/bin/cmake-easyinstall https://git.io/JvLxY +sudo chmod a+x /usr/local/bin/cmake-easyinstall +export CEI_SUDO="sudo" diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index dd266435181..40ac9c7f841 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -121,3 +121,23 @@ jobs: mkdir build_sp && cd build_sp cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=DPCPP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single make -j 2 + + build_hip: + name: HIP SP [Linux] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: install dependencies + shell: bash + run: .github/workflows/dependencies/hip.sh + - name: build WarpX + shell: bash + run: | + source /etc/profile.d/rocm.sh + hipcc --version + export CXX=$(which hipcc) + export CC=$(which hipcc) + + mkdir build_sp && cd build_sp + cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=ON -DWarpX_COMPUTE=HIP -DAMD_ARCH=gfx900 -DWarpX_OPENPMD=ON -DWarpX_PRECISION=single + make -j 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 78acf7395d2..cdb675cfda0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ if(NOT WarpX_PRECISION IN_LIST WarpX_PRECISION_VALUES) message(FATAL_ERROR "WarpX_PRECISION (${WarpX_PRECISION}) must be one of ${WarpX_PRECISION_VALUES}") endif() -set(WarpX_COMPUTE_VALUES NOACC OMP CUDA DPCPP) # HIP +set(WarpX_COMPUTE_VALUES NOACC OMP CUDA DPCPP HIP) set(WarpX_COMPUTE OMP CACHE STRING "On-node, accelerated computing backend (NOACC/OMP/CUDA/DPCPP)") set_property(CACHE WarpX_COMPUTE PROPERTY STRINGS ${WarpX_COMPUTE_VALUES}) if(NOT WarpX_COMPUTE IN_LIST WarpX_COMPUTE_VALUES) diff --git a/Docs/source/building/cmake.rst b/Docs/source/building/cmake.rst index 42cabf4c221..609351e00f3 100644 --- a/Docs/source/building/cmake.rst +++ b/Docs/source/building/cmake.rst @@ -123,7 +123,7 @@ CMake Option Default & Values Descr ============================= ============================================ ======================================================= ``CMAKE_BUILD_TYPE`` **RelWithDebInfo**/Release/Debug Type of build, symbols & optimizations ``WarpX_ASCENT`` ON/**OFF** Ascent in situ visualization -``WarpX_COMPUTE`` NOACC/**OMP**/CUDA/DPCPP On-node, accelerated computing backend +``WarpX_COMPUTE`` NOACC/**OMP**/CUDA/DPCPP/HIP On-node, accelerated computing backend ``WarpX_DIMS`` **3**/2/RZ Simulation dimensionality ``WarpX_MPI`` **ON**/OFF Multi-node support (message-passing) ``WarpX_MPI_THREAD_MULTIPLE`` **ON**/OFF MPI thread-multiple support, i.e. for ``async_io`` diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index 8b2f8bac243..50f4ea3dd7e 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -23,25 +23,31 @@ macro(find_amrex) set(ENABLE_ACC OFF CACHE INTERNAL "") set(ENABLE_CUDA ON CACHE INTERNAL "") set(ENABLE_DPCPP OFF CACHE BOOL "") - #set(ENABLE_HIP OFF CACHE BOOL "") + set(ENABLE_HIP OFF CACHE BOOL "") set(ENABLE_OMP OFF CACHE INTERNAL "") elseif(WarpX_COMPUTE STREQUAL OMP) set(ENABLE_ACC OFF CACHE INTERNAL "") set(ENABLE_CUDA OFF CACHE INTERNAL "") set(ENABLE_DPCPP OFF CACHE BOOL "") - #set(ENABLE_HIP OFF CACHE BOOL "") + set(ENABLE_HIP OFF CACHE BOOL "") set(ENABLE_OMP ON CACHE INTERNAL "") elseif(WarpX_COMPUTE STREQUAL DPCPP) set(ENABLE_ACC OFF CACHE INTERNAL "") set(ENABLE_CUDA OFF CACHE INTERNAL "") set(ENABLE_DPCPP ON CACHE BOOL "") - #set(ENABLE_HIP OFF CACHE BOOL "") + set(ENABLE_HIP OFF CACHE BOOL "") + set(ENABLE_OMP OFF CACHE INTERNAL "") + elseif(WarpX_COMPUTE STREQUAL HIP) + set(ENABLE_ACC OFF CACHE INTERNAL "") + set(ENABLE_CUDA OFF CACHE INTERNAL "") + set(ENABLE_DPCPP OFF CACHE BOOL "") + set(ENABLE_HIP ON CACHE BOOL "") set(ENABLE_OMP OFF CACHE INTERNAL "") else() set(ENABLE_ACC OFF CACHE INTERNAL "") set(ENABLE_CUDA OFF CACHE INTERNAL "") set(ENABLE_DPCPP OFF CACHE BOOL "") - #set(ENABLE_HIP OFF CACHE BOOL "") + set(ENABLE_HIP OFF CACHE BOOL "") set(ENABLE_OMP OFF CACHE INTERNAL "") endif() From 4dd88c20d5e029df5d3da7521f27116b59d00d2c Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 20 Oct 2020 22:18:29 -0700 Subject: [PATCH 04/30] Gpu::Atomic::Add -> Gpu::Atomic::AddNoRet (#1447) For HIP, AddNoRet for float is much faster because it has hardware support. --- .../Particles/Deposition/ChargeDeposition.H | 8 +- .../Particles/Deposition/CurrentDeposition.H | 120 +++++++++--------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Source/Particles/Deposition/ChargeDeposition.H b/Source/Particles/Deposition/ChargeDeposition.H index 18013318834..c20b461c620 100644 --- a/Source/Particles/Deposition/ChargeDeposition.H +++ b/Source/Particles/Deposition/ChargeDeposition.H @@ -135,15 +135,15 @@ void doChargeDepositionShapeN(const GetParticlePosition& GetPosition, #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) for (int iz=0; iz<=depos_order; iz++){ for (int ix=0; ix<=depos_order; ix++){ - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 0), sx[ix]*sz[iz]*wq); #if (defined WARPX_DIM_RZ) Complex xy = xy0; // Throughout the following loop, xy takes the value e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 on the weighting comes from the normalization of the modes - amrex::Gpu::Atomic::Add( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode-1), 2._rt*sx[ix]*sz[iz]*wq*xy.real()); - amrex::Gpu::Atomic::Add( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode ), 2._rt*sx[ix]*sz[iz]*wq*xy.imag()); + amrex::Gpu::Atomic::AddNoRet( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode-1), 2._rt*sx[ix]*sz[iz]*wq*xy.real()); + amrex::Gpu::Atomic::AddNoRet( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode ), 2._rt*sx[ix]*sz[iz]*wq*xy.imag()); xy = xy*xy0; } #endif @@ -153,7 +153,7 @@ void doChargeDepositionShapeN(const GetParticlePosition& GetPosition, for (int iz=0; iz<=depos_order; iz++){ for (int iy=0; iy<=depos_order; iy++){ for (int ix=0; ix<=depos_order; ix++){ - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &rho_arr(lo.x+i+ix, lo.y+j+iy, lo.z+k+iz), sx[ix]*sy[iy]*sz[iz]*wq); } diff --git a/Source/Particles/Deposition/CurrentDeposition.H b/Source/Particles/Deposition/CurrentDeposition.H index b116bbb64b9..a353a150126 100644 --- a/Source/Particles/Deposition/CurrentDeposition.H +++ b/Source/Particles/Deposition/CurrentDeposition.H @@ -236,25 +236,25 @@ void doDepositionShapeN(const GetParticlePosition& GetPosition, #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) for (int iz=0; iz<=depos_order; iz++){ for (int ix=0; ix<=depos_order; ix++){ - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 0), sx_jx[ix]*sz_jx[iz]*wqx); - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 0), sx_jy[ix]*sz_jy[iz]*wqy); - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 0), sx_jz[ix]*sz_jz[iz]*wqz); #if (defined WARPX_DIM_RZ) Complex xy = xy0; // Note that xy is equal to e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 on the weighting comes from the normalization of the modes - amrex::Gpu::Atomic::Add( &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 2*imode-1), 2._rt*sx_jx[ix]*sz_jx[iz]*wqx*xy.real()); - amrex::Gpu::Atomic::Add( &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 2*imode ), 2._rt*sx_jx[ix]*sz_jx[iz]*wqx*xy.imag()); - amrex::Gpu::Atomic::Add( &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 2*imode-1), 2._rt*sx_jy[ix]*sz_jy[iz]*wqy*xy.real()); - amrex::Gpu::Atomic::Add( &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 2*imode ), 2._rt*sx_jy[ix]*sz_jy[iz]*wqy*xy.imag()); - amrex::Gpu::Atomic::Add( &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 2*imode-1), 2._rt*sx_jz[ix]*sz_jz[iz]*wqz*xy.real()); - amrex::Gpu::Atomic::Add( &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 2*imode ), 2._rt*sx_jz[ix]*sz_jz[iz]*wqz*xy.imag()); + amrex::Gpu::Atomic::AddNoRet( &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 2*imode-1), 2._rt*sx_jx[ix]*sz_jx[iz]*wqx*xy.real()); + amrex::Gpu::Atomic::AddNoRet( &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 2*imode ), 2._rt*sx_jx[ix]*sz_jx[iz]*wqx*xy.imag()); + amrex::Gpu::Atomic::AddNoRet( &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 2*imode-1), 2._rt*sx_jy[ix]*sz_jy[iz]*wqy*xy.real()); + amrex::Gpu::Atomic::AddNoRet( &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 2*imode ), 2._rt*sx_jy[ix]*sz_jy[iz]*wqy*xy.imag()); + amrex::Gpu::Atomic::AddNoRet( &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 2*imode-1), 2._rt*sx_jz[ix]*sz_jz[iz]*wqz*xy.real()); + amrex::Gpu::Atomic::AddNoRet( &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 2*imode ), 2._rt*sx_jz[ix]*sz_jz[iz]*wqz*xy.imag()); xy = xy*xy0; } #endif @@ -264,13 +264,13 @@ void doDepositionShapeN(const GetParticlePosition& GetPosition, for (int iz=0; iz<=depos_order; iz++){ for (int iy=0; iy<=depos_order; iy++){ for (int ix=0; ix<=depos_order; ix++){ - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jx_arr(lo.x+j_jx+ix, lo.y+k_jx+iy, lo.z+l_jx+iz), sx_jx[ix]*sy_jx[iy]*sz_jx[iz]*wqx); - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jy_arr(lo.x+j_jy+ix, lo.y+k_jy+iy, lo.z+l_jy+iz), sx_jy[ix]*sy_jy[iy]*sz_jy[iz]*wqy); - amrex::Gpu::Atomic::Add( + amrex::Gpu::Atomic::AddNoRet( &jz_arr(lo.x+j_jz+ix, lo.y+k_jz+iy, lo.z+l_jz+iz), sx_jz[ix]*sy_jz[iy]*sz_jz[iz]*wqz); } @@ -495,7 +495,7 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, for (int i=dil; i<=depos_order+1-diu; i++) { sdxi += wqx*(sx_old[i] - sx_new[i])*((sy_new[j] + 0.5_rt*(sy_old[j] - sy_new[j]))*sz_new[k] + (0.5_rt*sy_new[j] + 1._rt/3._rt*(sy_old[j] - sy_new[j]))*(sz_old[k] - sz_new[k])); - amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdxi); + amrex::Gpu::Atomic::AddNoRet( &Jx_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdxi); } } } @@ -505,7 +505,7 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, for (int j=djl; j<=depos_order+1-dju; j++) { sdyj += wqy*(sy_old[j] - sy_new[j])*((sz_new[k] + 0.5_rt*(sz_old[k] - sz_new[k]))*sx_new[i] + (0.5_rt*sz_new[k] + 1._rt/3._rt*(sz_old[k] - sz_new[k]))*(sx_old[i] - sx_new[i])); - amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdyj); + amrex::Gpu::Atomic::AddNoRet( &Jy_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdyj); } } } @@ -515,7 +515,7 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, for (int k=dkl; k<=depos_order+1-dku; k++) { sdzk += wqz*(sz_old[k] - sz_new[k])*((sx_new[i] + 0.5_rt*(sx_old[i] - sx_new[i]))*sy_new[j] + (0.5_rt*sx_new[i] + 1._rt/3._rt*(sx_old[i] - sx_new[i]))*(sy_old[j] - sy_new[j])); - amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdzk); + amrex::Gpu::Atomic::AddNoRet( &Jz_arr(lo.x+i_new-1+i, lo.y+j_new-1+j, lo.z+k_new-1+k), sdzk); } } } @@ -526,14 +526,14 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, amrex::Real sdxi = 0._rt; for (int i=dil; i<=depos_order+1-diu; i++) { sdxi += wqx*(sx_old[i] - sx_new[i])*(sz_new[k] + 0.5_rt*(sz_old[k] - sz_new[k])); - amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdxi); + amrex::Gpu::Atomic::AddNoRet( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdxi); #if (defined WARPX_DIM_RZ) Complex xy_mid = xy_mid0; // Throughout the following loop, xy_mid takes the value e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 comes from the normalization of the modes const Complex djr_cmplx = 2._rt *sdxi*xy_mid; - amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djr_cmplx.real()); - amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djr_cmplx.imag()); + amrex::Gpu::Atomic::AddNoRet( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djr_cmplx.real()); + amrex::Gpu::Atomic::AddNoRet( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djr_cmplx.imag()); xy_mid = xy_mid*xy_mid0; } #endif @@ -543,7 +543,7 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, for (int i=dil; i<=depos_order+2-diu; i++) { Real const sdyj = wq*vy*invvol*((sz_new[k] + 0.5_rt * (sz_old[k] - sz_new[k]))*sx_new[i] + (0.5_rt * sz_new[k] + 1._rt / 3._rt *(sz_old[k] - sz_new[k]))*(sx_old[i] - sx_new[i])); - amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdyj); + amrex::Gpu::Atomic::AddNoRet( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdyj); #if (defined WARPX_DIM_RZ) Complex xy_new = xy_new0; Complex xy_mid = xy_mid0; @@ -555,8 +555,8 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, const Complex djt_cmplx = -2._rt * I*(i_new-1 + i + xmin*dxi)*wq*invdtdx/(amrex::Real)imode *(Complex(sx_new[i]*sz_new[k], 0.)*(xy_new - xy_mid) + Complex(sx_old[i]*sz_old[k], 0.)*(xy_mid - xy_old)); - amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djt_cmplx.real()); - amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djt_cmplx.imag()); + amrex::Gpu::Atomic::AddNoRet( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djt_cmplx.real()); + amrex::Gpu::Atomic::AddNoRet( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djt_cmplx.imag()); xy_new = xy_new*xy_new0; xy_mid = xy_mid*xy_mid0; xy_old = xy_old*xy_old0; @@ -568,14 +568,14 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, Real sdzk = 0._rt; for (int k=dkl; k<=depos_order+1-dku; k++) { sdzk += wqz*(sz_old[k] - sz_new[k])*(sx_new[i] + 0.5_rt * (sx_old[i] - sx_new[i])); - amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdzk); + amrex::Gpu::Atomic::AddNoRet( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdzk); #if (defined WARPX_DIM_RZ) Complex xy_mid = xy_mid0; // Throughout the following loop, xy_mid takes the value e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 comes from the normalization of the modes const Complex djz_cmplx = 2._rt * sdzk * xy_mid; - amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djz_cmplx.real()); - amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djz_cmplx.imag()); + amrex::Gpu::Atomic::AddNoRet( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djz_cmplx.real()); + amrex::Gpu::Atomic::AddNoRet( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djz_cmplx.imag()); xy_mid = xy_mid*xy_mid0; } #endif @@ -775,42 +775,42 @@ void doVayDepositionShapeN (const GetParticlePosition& GetPosition, amrex::Real const sxo_szo = sx_old[i] * sz_old[k]; // Jx - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), wq * invvol * invdt * 0.5_rt * sxn_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + k_new + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + k_new + k, 0, 0), - wq * invvol * invdt * 0.5_rt * sxo_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + k_old + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + k_old + k, 0, 0), wq * invvol * invdt * 0.5_rt * sxn_szo); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), - wq * invvol * invdt * 0.5_rt * sxo_szo); // Jy - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), wqy * 0.25_rt * sxn_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + k_old + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + k_old + k, 0, 0), wqy * 0.25_rt * sxn_szo); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + k_new + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + k_new + k, 0, 0), wqy * 0.25_rt * sxo_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), wqy * 0.25_rt * sxo_szo); // Jz - amrex::Gpu::Atomic::Add(&jz_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jz_arr(lo.x + i_new + i, lo.y + k_new + k, 0, 0), wq * invvol * invdt * 0.5_rt * sxn_szn); - amrex::Gpu::Atomic::Add(&jz_arr(lo.x+i_new+i,lo.y+k_old+k,0,0), + amrex::Gpu::Atomic::AddNoRet(&jz_arr(lo.x+i_new+i,lo.y+k_old+k,0,0), - wq * invvol * invdt * 0.5_rt * sxn_szo); - amrex::Gpu::Atomic::Add(&jz_arr(lo.x+i_old+i,lo.y+k_new+k,0,0), + amrex::Gpu::Atomic::AddNoRet(&jz_arr(lo.x+i_old+i,lo.y+k_new+k,0,0), wq * invvol * invdt * 0.5_rt * sxo_szn); - amrex::Gpu::Atomic::Add(&jz_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), + amrex::Gpu::Atomic::AddNoRet(&jz_arr(lo.x + i_old + i, lo.y + k_old + k, 0, 0), - wq * invvol * invdt * 0.5_rt * sxo_szo); } } @@ -837,78 +837,78 @@ void doVayDepositionShapeN (const GetParticlePosition& GetPosition, amrex::Real const sxo_syo_szo = sx_old[i] * syo_szo; // Jx - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), wq * invvol * invdt * onethird * sxn_syn_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), - wq * invvol * invdt * onethird * sxo_syn_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), wq * invvol * invdt * onesixth * sxn_syo_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + j_old + j,lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + j_old + j,lo.z + k_new + k), - wq * invvol * invdt * onesixth * sxo_syo_szn); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), wq * invvol * invdt * onesixth * sxn_syn_szo); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), - wq * invvol * invdt * onesixth * sxo_syn_szo); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), wq * invvol * invdt * onethird * sxn_syo_szo); - amrex::Gpu::Atomic::Add(&jx_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jx_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), - wq * invvol * invdt * onethird * sxo_syo_szo); // Jy - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), wq * invvol * invdt * onethird * sxn_syn_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), - wq * invvol * invdt * onethird * sxn_syo_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), wq * invvol * invdt * onesixth * sxo_syn_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_new + k), - wq * invvol * invdt * onesixth * sxo_syo_szn); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), wq * invvol * invdt * onesixth * sxn_syn_szo); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), - wq * invvol * invdt * onesixth * sxn_syo_szo); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), wq * invvol * invdt * onethird * sxo_syn_szo); - amrex::Gpu::Atomic::Add(&jy_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jy_arr(lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), - wq * invvol * invdt * onethird * sxo_syo_szo); // Jz - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_new + i, lo.y + j_new + j, lo.z + k_new + k), wq * invvol * invdt * onethird * sxn_syn_szn); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_new + i, lo.y + j_new + j, lo.z + k_old + k), - wq * invvol * invdt * onethird * sxn_syn_szo); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_old + i, lo.y + j_new + j, lo.z + k_new + k), wq * invvol * invdt * onesixth * sxo_syn_szn); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_old + i, lo.y + j_new + j, lo.z + k_old + k), - wq * invvol * invdt * onesixth * sxo_syn_szo); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_new + i, lo.y + j_old + j, lo.z + k_new + k), wq * invvol * invdt * onesixth * sxn_syo_szn); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_new + i, lo.y + j_old + j, lo.z + k_old + k), - wq * invvol * invdt * onesixth * sxn_syo_szo); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_old + i, lo.y + j_old + j, lo.z + k_new + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_old + i, lo.y + j_old + j, lo.z + k_new + k), wq * invvol * invdt * onethird * sxo_syo_szn); - amrex::Gpu::Atomic::Add(&jz_arr( lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), + amrex::Gpu::Atomic::AddNoRet(&jz_arr( lo.x + i_old + i, lo.y + j_old + j, lo.z + k_old + k), - wq * invvol * invdt * onethird * sxo_syo_szo); } } From 25f65408206b8af83c6e6c331f498f4c1ecef59a Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 21 Oct 2020 00:22:34 -0700 Subject: [PATCH 05/30] CI: DPC++ remove outdated activation (#1437) Removes an outdated environment activation line in DPC++. --- .github/workflows/ubuntu.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 40ac9c7f841..90dda08f9f9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -100,7 +100,6 @@ jobs: sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler intel-oneapi-mkl-devel set +e source /opt/intel/oneapi/setvars.sh - source /opt/intel/oneapi/compiler/2021.1-beta08/env/vars.sh set -e git clone https://github.com/openPMD/openPMD-api.git mkdir openPMD-api/build @@ -113,7 +112,6 @@ jobs: run: | set +e source /opt/intel/oneapi/setvars.sh - source /opt/intel/oneapi/compiler/2021.1-beta08/env/vars.sh set -e export CXX=$(which dpcpp) export CC=$(which clang) From 006680623f874c2413b3b8ba00286c175ef452a6 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 22 Oct 2020 17:33:46 +0200 Subject: [PATCH 06/30] [mini-PR, even if it does not look "mini"]Fix unused function warning in parser (#1448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling WarpX I got this warning message: `wp_parser.lex.c:1356:17: warning: ‘void yyunput(int, char*)’ defined but not used [-Wunused-function]` This can be fixed by adding `%option nounput` option to `wp_parser.l` and re-generating the parser with `make`. --- Source/Parser/wp_parser.l | 2 + Source/Parser/wp_parser.lex.cpp | 183 +++++++------ Source/Parser/wp_parser.lex.h | 6 +- Source/Parser/wp_parser.tab.cpp | 446 +++++++++++++++++++------------- Source/Parser/wp_parser.tab.h | 11 +- 5 files changed, 377 insertions(+), 271 deletions(-) diff --git a/Source/Parser/wp_parser.l b/Source/Parser/wp_parser.l index f1d0fb59ed4..f9c17bdc78f 100644 --- a/Source/Parser/wp_parser.l +++ b/Source/Parser/wp_parser.l @@ -4,6 +4,8 @@ #include "wp_parser.tab.h" %} +%option nounput + /* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ /* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ diff --git a/Source/Parser/wp_parser.lex.cpp b/Source/Parser/wp_parser.lex.cpp index 68a6dd75fc4..2dbac3dedf0 100644 --- a/Source/Parser/wp_parser.lex.cpp +++ b/Source/Parser/wp_parser.lex.cpp @@ -1,6 +1,6 @@ -#line 2 "wp_parser.lex.c" +#line 2 "wp_parser.lex.cpp" -#line 4 "wp_parser.lex.c" +#line 4 "wp_parser.lex.cpp" #define YY_INT_ALIGNED short int @@ -34,7 +34,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -51,7 +51,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -162,10 +162,10 @@ extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -521,13 +521,16 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; +#line 1 "wp_parser.l" +#line 3 "wp_parser.l" #include "wp_parser_y.h" #include "wp_parser.tab.h" -#line 529 "wp_parser.lex.c" +#line 529 "wp_parser.lex.cpp" +#line 10 "wp_parser.l" /* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ /* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ /* Used leater to define NUMBER */ -#line 534 "wp_parser.lex.c" +#line 534 "wp_parser.lex.cpp" #define INITIAL 0 @@ -587,9 +590,7 @@ extern int yywrap ( void ); #endif #ifndef YY_NO_UNPUT - - static void yyunput ( int c, char *buf_ptr ); - + #endif #ifndef yytext_ptr @@ -716,7 +717,7 @@ YY_DECL yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; - + if ( !(yy_init) ) { (yy_init) = 1; @@ -744,9 +745,10 @@ YY_DECL } { +#line 16 "wp_parser.l" -#line 754 "wp_parser.lex.c" +#line 752 "wp_parser.lex.cpp" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -804,169 +806,216 @@ YY_DECL goto yy_find_action; case 1: +#line 19 "wp_parser.l" case 2: +#line 20 "wp_parser.l" case 3: +#line 21 "wp_parser.l" case 4: +#line 22 "wp_parser.l" case 5: +#line 23 "wp_parser.l" case 6: +#line 24 "wp_parser.l" case 7: +#line 25 "wp_parser.l" case 8: +#line 26 "wp_parser.l" case 9: +#line 27 "wp_parser.l" case 10: +#line 28 "wp_parser.l" case 11: YY_RULE_SETUP +#line 28 "wp_parser.l" { return yytext[0]; } /* simply pass through */ YY_BREAK /* yylval is union type defined in wp_parser.tab.h that is generated * by bison with wp_parser.y */ case 12: YY_RULE_SETUP +#line 33 "wp_parser.l" { yylval.f1 = WP_SQRT; return F1; } YY_BREAK case 13: YY_RULE_SETUP +#line 34 "wp_parser.l" { yylval.f1 = WP_EXP; return F1; } YY_BREAK case 14: YY_RULE_SETUP +#line 35 "wp_parser.l" { yylval.f1 = WP_LOG; return F1; } YY_BREAK case 15: YY_RULE_SETUP +#line 36 "wp_parser.l" { yylval.f1 = WP_LOG10; return F1; } YY_BREAK case 16: YY_RULE_SETUP +#line 37 "wp_parser.l" { yylval.f1 = WP_SIN; return F1; } YY_BREAK case 17: YY_RULE_SETUP +#line 38 "wp_parser.l" { yylval.f1 = WP_COS; return F1; } YY_BREAK case 18: YY_RULE_SETUP +#line 39 "wp_parser.l" { yylval.f1 = WP_TAN; return F1; } YY_BREAK case 19: YY_RULE_SETUP +#line 40 "wp_parser.l" { yylval.f1 = WP_ASIN; return F1; } YY_BREAK case 20: YY_RULE_SETUP +#line 41 "wp_parser.l" { yylval.f1 = WP_ACOS; return F1; } YY_BREAK case 21: YY_RULE_SETUP +#line 42 "wp_parser.l" { yylval.f1 = WP_ATAN; return F1; } YY_BREAK case 22: YY_RULE_SETUP +#line 43 "wp_parser.l" { yylval.f1 = WP_SINH; return F1; } YY_BREAK case 23: YY_RULE_SETUP +#line 44 "wp_parser.l" { yylval.f1 = WP_COSH; return F1; } YY_BREAK case 24: YY_RULE_SETUP +#line 45 "wp_parser.l" { yylval.f1 = WP_TANH; return F1; } YY_BREAK case 25: YY_RULE_SETUP +#line 46 "wp_parser.l" { yylval.f1 = WP_ABS; return F1; } YY_BREAK case 26: YY_RULE_SETUP +#line 47 "wp_parser.l" { yylval.f1 = WP_ABS; return F1; } YY_BREAK case 27: YY_RULE_SETUP +#line 48 "wp_parser.l" { yylval.f2 = WP_POW; return POW;} YY_BREAK case 28: YY_RULE_SETUP +#line 49 "wp_parser.l" { yylval.f2 = WP_POW; return POW;} YY_BREAK case 29: YY_RULE_SETUP +#line 50 "wp_parser.l" { yylval.f2 = WP_GEQ; return GEQ;} YY_BREAK case 30: YY_RULE_SETUP +#line 51 "wp_parser.l" { yylval.f2 = WP_LEQ; return LEQ;} YY_BREAK case 31: YY_RULE_SETUP +#line 52 "wp_parser.l" { yylval.f2 = WP_EQ; return EQ;} YY_BREAK case 32: YY_RULE_SETUP +#line 53 "wp_parser.l" { yylval.f2 = WP_NEQ; return NEQ;} YY_BREAK case 33: YY_RULE_SETUP +#line 54 "wp_parser.l" { yylval.f2 = WP_AND; return AND;} YY_BREAK case 34: YY_RULE_SETUP +#line 55 "wp_parser.l" { yylval.f2 = WP_OR; return OR;} YY_BREAK case 35: YY_RULE_SETUP +#line 56 "wp_parser.l" { yylval.f2 = WP_POW; return F2; } YY_BREAK case 36: YY_RULE_SETUP +#line 57 "wp_parser.l" { yylval.f2 = WP_HEAVISIDE; return F2; } YY_BREAK case 37: YY_RULE_SETUP +#line 58 "wp_parser.l" { yylval.f2 = WP_MIN; return F2; } YY_BREAK case 38: YY_RULE_SETUP +#line 59 "wp_parser.l" { yylval.f2 = WP_MAX; return F2; } YY_BREAK /* We use SYMBOL to hold variables and constants */ case 39: YY_RULE_SETUP +#line 62 "wp_parser.l" { yylval.s = wp_makesymbol(yytext); return SYMBOL; } YY_BREAK /* Number */ case 40: +#line 66 "wp_parser.l" case 41: YY_RULE_SETUP +#line 66 "wp_parser.l" { yylval.d = atof(yytext); return NUMBER; } YY_BREAK /* Special characters */ case 42: YY_RULE_SETUP +#line 69 "wp_parser.l" YY_BREAK case 43: YY_RULE_SETUP +#line 70 "wp_parser.l" /* ignore white space */ YY_BREAK case 44: /* rule 44 can match eol */ YY_RULE_SETUP +#line 71 "wp_parser.l" /* ignore line continuation */ YY_BREAK case 45: /* rule 45 can match eol */ YY_RULE_SETUP +#line 72 "wp_parser.l" { return EOL; } YY_BREAK /* everything else */ case 46: YY_RULE_SETUP +#line 75 "wp_parser.l" { yyerror("Unknown character %c\n", *yytext); } YY_BREAK case 47: YY_RULE_SETUP +#line 77 "wp_parser.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1021 "wp_parser.lex.c" +#line 1019 "wp_parser.lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1249,7 +1298,7 @@ static int yy_get_next_buffer (void) { yy_state_type yy_current_state; char *yy_cp; - + yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) @@ -1302,43 +1351,6 @@ static int yy_get_next_buffer (void) #ifndef YY_NO_UNPUT - static void yyunput (int c, char * yy_bp ) -{ - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - #endif #ifndef YY_NO_INPUT @@ -1350,7 +1362,7 @@ static int yy_get_next_buffer (void) { int c; - + *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) @@ -1417,12 +1429,12 @@ static int yy_get_next_buffer (void) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * + * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { - + if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = @@ -1435,11 +1447,11 @@ static int yy_get_next_buffer (void) /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * + * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { - + /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); @@ -1479,13 +1491,13 @@ static void yy_load_buffer_state (void) /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * + * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1508,11 +1520,11 @@ static void yy_load_buffer_state (void) /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() - * + * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { - + if ( ! b ) return; @@ -1533,7 +1545,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - + yy_flush_buffer( b ); b->yy_input_file = file; @@ -1549,13 +1561,13 @@ static void yy_load_buffer_state (void) } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * + * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { @@ -1584,7 +1596,7 @@ static void yy_load_buffer_state (void) * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * + * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { @@ -1614,7 +1626,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * + * */ void yypop_buffer_state (void) { @@ -1638,7 +1650,7 @@ void yypop_buffer_state (void) static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; - + if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this @@ -1681,13 +1693,13 @@ static void yyensure_buffer_stack (void) /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * + * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1716,14 +1728,14 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * + * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } @@ -1731,7 +1743,7 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr ) * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * + * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) @@ -1740,7 +1752,7 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); buf = (char *) yyalloc( n ); @@ -1794,16 +1806,16 @@ static void yynoreturn yy_fatal_error (const char* msg ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. - * + * */ int yyget_lineno (void) { - + return yylineno; } /** Get the input stream. - * + * */ FILE *yyget_in (void) { @@ -1811,7 +1823,7 @@ FILE *yyget_in (void) } /** Get the output stream. - * + * */ FILE *yyget_out (void) { @@ -1819,7 +1831,7 @@ FILE *yyget_out (void) } /** Get the length of the current token. - * + * */ int yyget_leng (void) { @@ -1827,7 +1839,7 @@ int yyget_leng (void) } /** Get the current token. - * + * */ char *yyget_text (void) @@ -1837,18 +1849,18 @@ char *yyget_text (void) /** Set the current line number. * @param _line_number line number - * + * */ void yyset_lineno (int _line_number ) { - + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param _in_str A readable stream. - * + * * @see yy_switch_to_buffer */ void yyset_in (FILE * _in_str ) @@ -1902,7 +1914,7 @@ static int yy_init_globals (void) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { - + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer( YY_CURRENT_BUFFER ); @@ -1928,7 +1940,7 @@ int yylex_destroy (void) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, const char * s2, int n ) { - + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; @@ -1953,7 +1965,7 @@ void *yyalloc (yy_size_t size ) void *yyrealloc (void * ptr, yy_size_t size ) { - + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -1971,5 +1983,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" +#line 77 "wp_parser.l" diff --git a/Source/Parser/wp_parser.lex.h b/Source/Parser/wp_parser.lex.h index 557add97016..272cf15211f 100644 --- a/Source/Parser/wp_parser.lex.h +++ b/Source/Parser/wp_parser.lex.h @@ -38,7 +38,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -55,7 +55,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -469,7 +469,7 @@ extern int yylex (void); #undef yyTABLES_NAME #endif -#line 75 "wp_parser.l" +#line 77 "wp_parser.l" #line 476 "wp_parser.lex.h" diff --git a/Source/Parser/wp_parser.tab.cpp b/Source/Parser/wp_parser.tab.cpp index 0f7c2403deb..56bff07bb82 100644 --- a/Source/Parser/wp_parser.tab.cpp +++ b/Source/Parser/wp_parser.tab.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.3.2. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -48,7 +48,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.3.2" +#define YYBISON_VERSION "3.5.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -66,7 +66,7 @@ /* First part of user prologue. */ -#line 2 "wp_parser.y" /* yacc.c:337 */ +#line 2 "wp_parser.y" #include #include @@ -74,7 +74,17 @@ #include "wp_parser_y.h" int yylex (void); -#line 78 "wp_parser.tab.c" /* yacc.c:337 */ +#line 78 "wp_parser.tab.c" + +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR # if defined __cplusplus # if 201103L <= __cplusplus @@ -95,8 +105,8 @@ # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "wp_parser.tab.h". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_YY_WP_PARSER_TAB_H_INCLUDED # define YY_YY_WP_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -132,10 +142,9 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 19 "wp_parser.y" /* yacc.c:352 */ +#line 19 "wp_parser.y" struct wp_node* n; amrex_real d; @@ -143,9 +152,9 @@ union YYSTYPE enum wp_f1_t f1; enum wp_f2_t f2; -#line 147 "wp_parser.tab.c" /* yacc.c:352 */ -}; +#line 156 "wp_parser.tab.c" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -164,28 +173,75 @@ int yyparse (void); # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned short yytype_uint16; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef short yytype_int16; +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -193,7 +249,7 @@ typedef short yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -201,7 +257,19 @@ typedef short yytype_int16; # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + +/* Stored state numbers (used for stacks). */ +typedef yytype_int8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -215,22 +283,20 @@ typedef short yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif #endif /* Suppress unused-variable warnings by "using" E. */ @@ -242,11 +308,11 @@ typedef short yytype_int16; #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -259,6 +325,20 @@ typedef short yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) #if ! defined yyoverflow || YYERROR_VERBOSE @@ -335,17 +415,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -358,11 +438,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -374,12 +454,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -405,14 +485,15 @@ union yyalloc #define YYUNDEFTOK 2 #define YYMAXUTOK 272 + /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ -static const yytype_uint8 yytranslate[] = +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -446,7 +527,7 @@ static const yytype_uint8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = +static const yytype_int8 yyrline[] = { 0, 67, 67, 68, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, @@ -469,7 +550,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 94, 265, 266, 267, 268, 269, 270, 61, 60, 62, @@ -477,14 +558,14 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -24 +#define YYPACT_NINF (-24) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-24))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF (-1) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -501,7 +582,7 @@ static const yytype_int16 yypact[] = /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_uint8 yydefact[] = +static const yytype_int8 yydefact[] = { 2, 0, 1, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 20, 19, 0, 3, 0, 0, 0, @@ -525,7 +606,7 @@ static const yytype_int8 yydefgoto[] = /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint8 yytable[] = +static const yytype_int8 yytable[] = { 13, 14, 15, 11, 30, 31, 12, 17, 0, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, @@ -573,7 +654,7 @@ static const yytype_int8 yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 30, 0, 4, 5, 6, 7, 20, 21, 26, 31, 26, 26, 31, 31, 31, 8, 9, 11, 12, @@ -583,7 +664,7 @@ static const yytype_uint8 yystos[] = }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { 0, 29, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, @@ -591,7 +672,7 @@ static const yytype_uint8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 0, 3, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, @@ -681,7 +762,9 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) if (yytype < YYNTOKENS) YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -705,7 +788,7 @@ yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -728,19 +811,19 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], + yystos[+yyssp[yyi + 1 - yynrhs]], &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); @@ -785,13 +868,13 @@ int yydebug; # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen +# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) # else /* Return the length of YYSTR. */ -static YYSIZE_T +static YYPTRDIFF_T yystrlen (const char *yystr) { - YYSIZE_T yylen; + YYPTRDIFF_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; @@ -827,12 +910,12 @@ yystpcpy (char *yydest, const char *yysrc) backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYSIZE_T +static YYPTRDIFF_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - YYSIZE_T yyn = 0; + YYPTRDIFF_T yyn = 0; char const *yyp = yystr; for (;;) @@ -863,10 +946,10 @@ yytnamerr (char *yyres, const char *yystr) do_not_strip_quotes: ; } - if (! yyres) + if (yyres) + return yystpcpy (yyres, yystr) - yyres; + else return yystrlen (yystr); - - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -879,19 +962,19 @@ yytnamerr (char *yyres, const char *yystr) *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, + yy_state_t *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ + /* Arguments of yyformat: reported tokens (one for the "unexpected", + one per "expected"). */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ + /* Actual size of YYARG. */ int yycount = 0; + /* Cumulated lengths of YYARG. */ + YYPTRDIFF_T yysize = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then @@ -918,7 +1001,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, */ if (yytoken != YYEMPTY) { - int yyn = yypact[*yyssp]; + int yyn = yypact[+*yyssp]; + YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + yysize = yysize0; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { @@ -943,7 +1028,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + YYPTRDIFF_T yysize1 + = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else @@ -970,7 +1056,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + /* Don't count the "%s"s in the final size, but reserve room for + the terminator. */ + YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else @@ -1000,8 +1088,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } else { - yyp++; - yyformat++; + ++yyp; + ++yyformat; } } return 0; @@ -1044,7 +1132,7 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1056,16 +1144,16 @@ yyparse (void) to reallocate them elsewhere. */ /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss; + yy_state_t *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; - YYSIZE_T yystacksize; + YYPTRDIFF_T yystacksize; int yyn; int yyresult; @@ -1079,7 +1167,7 @@ yyparse (void) /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1111,10 +1199,14 @@ yyparse (void) /*--------------------------------------------------------------------. -| yynewstate -- set current state (the top of the stack) to yystate. | +| yysetstate -- set current state (the top of the stack) to yystate. | `--------------------------------------------------------------------*/ yysetstate: - *yyssp = (yytype_int16) yystate; + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE @@ -1122,23 +1214,23 @@ yyparse (void) #else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYPTRDIFF_T yysize = yyssp - yyss + 1; # if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; @@ -1152,9 +1244,10 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1168,16 +1261,16 @@ yyparse (void) yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) YYACCEPT; @@ -1237,15 +1330,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1280,136 +1371,137 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: -#line 68 "wp_parser.y" /* yacc.c:1652 */ - { + case 3: +#line 68 "wp_parser.y" + { wp_defexpr((yyvsp[-1].n)); } -#line 1289 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 1380 "wp_parser.tab.c" break; case 4: -#line 77 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnumber((yyvsp[0].d)); } -#line 1295 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 77 "wp_parser.y" + { (yyval.n) = wp_newnumber((yyvsp[0].d)); } +#line 1386 "wp_parser.tab.c" break; case 5: -#line 78 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } -#line 1301 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 78 "wp_parser.y" + { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } +#line 1392 "wp_parser.tab.c" break; case 6: -#line 79 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1307 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 79 "wp_parser.y" + { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1398 "wp_parser.tab.c" break; case 7: -#line 80 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1313 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 80 "wp_parser.y" + { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1404 "wp_parser.tab.c" break; case 8: -#line 81 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1319 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 81 "wp_parser.y" + { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1410 "wp_parser.tab.c" break; case 9: -#line 82 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1325 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 82 "wp_parser.y" + { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1416 "wp_parser.tab.c" break; case 10: -#line 83 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = (yyvsp[-1].n); } -#line 1331 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 83 "wp_parser.y" + { (yyval.n) = (yyvsp[-1].n); } +#line 1422 "wp_parser.tab.c" break; case 11: -#line 84 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1337 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 84 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1428 "wp_parser.tab.c" break; case 12: -#line 85 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1343 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 85 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1434 "wp_parser.tab.c" break; case 13: -#line 86 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1349 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 86 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1440 "wp_parser.tab.c" break; case 14: -#line 87 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1355 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 87 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1446 "wp_parser.tab.c" break; case 15: -#line 88 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1361 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 88 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1452 "wp_parser.tab.c" break; case 16: -#line 89 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1367 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 89 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1458 "wp_parser.tab.c" break; case 17: -#line 90 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1373 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 90 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1464 "wp_parser.tab.c" break; case 18: -#line 91 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1379 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 91 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1470 "wp_parser.tab.c" break; case 19: -#line 92 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } -#line 1385 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 92 "wp_parser.y" + { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } +#line 1476 "wp_parser.tab.c" break; case 20: -#line 93 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = (yyvsp[0].n); } -#line 1391 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 93 "wp_parser.y" + { (yyval.n) = (yyvsp[0].n); } +#line 1482 "wp_parser.tab.c" break; case 21: -#line 94 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1397 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 94 "wp_parser.y" + { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } +#line 1488 "wp_parser.tab.c" break; case 22: -#line 95 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } -#line 1403 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 95 "wp_parser.y" + { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } +#line 1494 "wp_parser.tab.c" break; case 23: -#line 96 "wp_parser.y" /* yacc.c:1652 */ - { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } -#line 1409 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 96 "wp_parser.y" + { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } +#line 1500 "wp_parser.tab.c" break; -#line 1413 "wp_parser.tab.c" /* yacc.c:1652 */ +#line 1504 "wp_parser.tab.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1472,7 +1564,7 @@ yyparse (void) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); if (!yymsg) { yymsg = yymsgbuf; @@ -1627,7 +1719,7 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[+*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1640,5 +1732,5 @@ yyparse (void) #endif return yyresult; } -#line 99 "wp_parser.y" /* yacc.c:1918 */ +#line 99 "wp_parser.y" diff --git a/Source/Parser/wp_parser.tab.h b/Source/Parser/wp_parser.tab.h index 0c859fc03fa..aba980f57a7 100644 --- a/Source/Parser/wp_parser.tab.h +++ b/Source/Parser/wp_parser.tab.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.3.2. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -69,10 +69,9 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 19 "wp_parser.y" /* yacc.c:1921 */ +#line 19 "wp_parser.y" struct wp_node* n; amrex_real d; @@ -80,9 +79,9 @@ union YYSTYPE enum wp_f1_t f1; enum wp_f2_t f2; -#line 84 "wp_parser.tab.h" /* yacc.c:1921 */ -}; +#line 83 "wp_parser.tab.h" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 From 0fc03a711ce307a3c95ec9659e333b1a629e3564 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 22 Oct 2020 18:24:57 +0200 Subject: [PATCH 07/30] add error message on Juwels compilation in doc (#1450) --- Docs/source/building/juwels.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Docs/source/building/juwels.rst b/Docs/source/building/juwels.rst index 586d3c63a6d..7506563fe3f 100644 --- a/Docs/source/building/juwels.rst +++ b/Docs/source/building/juwels.rst @@ -3,6 +3,10 @@ Juwels (JSC) ============ +.. note:: + + There's currently a bug when building WarpX on Juwels! In order to compile on Juwels, please contact the WarpX developer team. + The `Juwels supercomputer `_ is located at JSC. See `this page `_ for a quick introduction. From 8a5a876dbdb06ac273039ed817a9aef1b1a693c9 Mon Sep 17 00:00:00 2001 From: lge0303 Date: Thu, 22 Oct 2020 11:23:30 -0700 Subject: [PATCH 08/30] Docs: Ascent Replay Workflow (#1331) * Document for ascent replay * ascent replated repository * Apply suggestions from code review * Review of replay - rendering plot without run simulation * modify Review of replay - accept Axel suggestion * modify replay - remove png file * Remove PNG Too large for git * Replay: Restructure Workflow * Remove duplicated files Well documented in the LWFA example and text now. Co-authored-by: Axel Huebl --- .../workflows/source/wrongFileNameInExamples | 2 + Docs/source/visualization/ascent.rst | 125 +++++++++++++++++- Docs/source/visualization/examples | 1 + .../laser_acceleration/ascent_actions.yaml | 93 +++++++++++++ 4 files changed, 217 insertions(+), 4 deletions(-) create mode 120000 Docs/source/visualization/examples create mode 100644 Examples/Physics_applications/laser_acceleration/ascent_actions.yaml diff --git a/.github/workflows/source/wrongFileNameInExamples b/.github/workflows/source/wrongFileNameInExamples index 5c46f92488e..e116b9df084 100755 --- a/.github/workflows/source/wrongFileNameInExamples +++ b/.github/workflows/source/wrongFileNameInExamples @@ -17,6 +17,7 @@ do if [[ ${file:0:6 } != inputs ]] && [[ ${file:0:12} != PICMI_inputs ]] && [[ ${file:0:8 } != analysis ]] && + [[ ${file: -4} != yaml ]] && [[ ${file:0:6 } != README ]] then files+=($file) @@ -32,6 +33,7 @@ then echo " - inputs : for WarpX input files" echo " - PICMI_inputs : for PICMI-compliant input scripts" echo " - analysis : for scripts testing the accuracy of a test" + echo " - *.yaml : for third-party input, e.g. Ascent in situ visualization" echo " - README : for readme files" echo "" echo "Please rename the file(s) to comply, or move to another folder" diff --git a/Docs/source/visualization/ascent.rst b/Docs/source/visualization/ascent.rst index 5f38c57bf07..a48b936aa5a 100644 --- a/Docs/source/visualization/ascent.rst +++ b/Docs/source/visualization/ascent.rst @@ -42,7 +42,7 @@ Ascent looks for the :code:`ascent_actions.yaml` file in the current working dir For example, the following :code:`ascent_actions.yaml` file extracts an isosurface of the field ``Ex`` for ``15`` levels and saves the resulting images to :code:`levels_.png`. `Ascent Actions `_ provides an overview over all available analysis and visualization actions. -.. code-block:: json +.. code-block:: yaml - action: "add_pipelines" @@ -66,7 +66,7 @@ For example, the following :code:`ascent_actions.yaml` file extracts an isosurfa Here is another :code:`ascent_actions.yaml` example that renders isosurfaces and particles: -.. code-block:: json +.. code-block:: yaml - action: "add_pipelines" @@ -101,7 +101,7 @@ Here is another :code:`ascent_actions.yaml` example that renders isosurfaces and Finally, here is a more complex :code:`ascent_actions.yaml` example that creates the same images as the prior example, but adds a trigger that creates a Cinema Database at cycle ``300``: -.. code-block:: json +.. code-block:: yaml - action: "add_triggers" @@ -143,7 +143,7 @@ Finally, here is a more complex :code:`ascent_actions.yaml` example that creates When the trigger condition is meet, ``cycle() == 300``, the actions in :code:`trigger.yaml` are also executed: -.. code-block:: json +.. code-block:: yaml - action: "add_pipelines" @@ -176,3 +176,120 @@ When the trigger condition is meet, ``cycle() == 300``, the actions in :code:`tr db_name: "cinema_out" You can view the Cinema Database result by opening :code:`cinema_databases/cinema_out/index.html`. + + +Replay +------ + +With Ascent/Conduit, one can store the intermediate data files before the rendering step is applied to custom files. +These so-called *Conduit Blueprint HDF5* files can be "replayed", i.e. rendered without running the simulation again. +VisIt 3.0+ also supports those files. + +`Replay `_ is a utility that allows the user to replay a simulation from aforementioned files and rendering them with Ascent. +Replay enables the user or developer to pick specific time steps and load them for Ascent visualization, without running the simulation again. + +We will guide you through the replay procedure. + + +Get Blueprint Files +^^^^^^^^^^^^^^^^^^^ +To use replay, you first need *Conduit Blueprint HDF5* files. +The following block can be used in an ascent action to extract *Conduit Blueprint HDF5* files from a simulation run. + +.. code-block:: yaml + + - + action: action: "add_extracts" + extracts: + e1: + type: "relay" + params: + path: "conduit_blueprint" + protocol: "blueprint/mesh/hdf5" + +The output in the WarpX run directory will look as in the following listing. +The ``.root`` file is a metadata file and the corresponding directory contains the conduit blueprint data in an internal format that is based on HDF5. + +.. code-block:: bash + + conduit_blueprint.cycle_000000/ + conduit_blueprint.cycle_000000.root + conduit_blueprint.cycle_000050/ + conduit_blueprint.cycle_000050.root + conduit_blueprint.cycle_000100/ + conduit_blueprint.cycle_000100.root + +In order to select a few time steps after the fact, a so-called *cycles file* can be created. +A cycles file is a simple text file that lists one root file per line, e.g.: + +.. code-block:: bash + + conduit_blueprint.cycle_000100.root + conduit_blueprint.cycle_000050.root + + +Run Replay +^^^^^^^^^^ + +For Ascent Replay, two command line tools are provided in the utilities/replay directory of the Ascent installation. +There are two version of replay: the MPI-parallel version ``replay_mpi`` and a serial version, ``replay_ser``. +Use an MPI-parallel replay with data sets created with MPI-parallel builds of WarpX. +Here we use ``replay_mpi`` as an example. + +The options for replay are: + +* ``--root``: specifies Blueprint root file to load +* ``--cycles``: specifies a text file containing a list of Blueprint root files to load +* ``--actions``: specifies the name of the actions file to use (default: ``ascent_actions.yaml``) + +Instead of starting a simulation that generates data for Ascent, we now execute ``replay_ser``/``replay_mpi``. +Replay will loop over the files listed in ``cycles`` in the order in which they appear in the cycles file. + +For example, for a small data example that fits on a single computer: + +.. code-block:: bash + + ./replay_ser --root=conduit_blueprint.cycle_000400.root --actions=ascent_actions.yaml + +Will replay the data of WarpX step 400 ("cycle" 400). +A whole set of steps can be replayed with the above mentioned *cycles file*: + +.. code-block:: bash + + ./replay_ser --cycles=warpx_list.txt --actions=ascent_actions.yaml + +For larger examples, e.g. on a cluster with *Slurm* batch system, a parallel launch could look like this: + +.. code-block:: bash + + # one step + srun -n 8 ./replay_mpi --root=conduit_blueprint.cycle_000400.root --actions=ascent_actions.yaml + # multiple steps + srun -n 8 ./replay_mpi --cycles=warpx_list.txt --actions=ascent_actions.yaml + + +Example Actions +^^^^^^^^^^^^^^^ + +A visualization of the electric field component :math:`E_x` (variable: ``Ex``) with a contour plot and with added particles can be obtained with the following Ascent Action. +This action can be used both in replay as well as in situ runs. + +.. literalinclude:: examples/Physics_applications/laser_acceleration/ascent_actions.yaml + :language: yaml + +There are more `Ascent Actions examples available `_ for you to play. + + +Workflow +^^^^^^^^ + +.. note:: + + This section is in-progress. + It will describe how to quickly create and iterate on ``ascent_actions.yaml`` files before running at scale. + + TODOs: finalize acceptance testing; update 3D LWFA example; share Jupyter notebook file + +.. code-block:: bash + + docker run -v$PWD:/home/user/ascent/install-debug/examples/ascentutorial/ascent_intro/notebooks/replay -p 8000:8000 -p 8888:8888 -p 9000:9000 -p 10000:10000 -t -i alpinedav/ascent-jupyter:latest diff --git a/Docs/source/visualization/examples b/Docs/source/visualization/examples new file mode 120000 index 00000000000..76b45c18c59 --- /dev/null +++ b/Docs/source/visualization/examples @@ -0,0 +1 @@ +../../../Examples \ No newline at end of file diff --git a/Examples/Physics_applications/laser_acceleration/ascent_actions.yaml b/Examples/Physics_applications/laser_acceleration/ascent_actions.yaml new file mode 100644 index 00000000000..f0c352949f5 --- /dev/null +++ b/Examples/Physics_applications/laser_acceleration/ascent_actions.yaml @@ -0,0 +1,93 @@ +- + action: "add_pipelines" + pipelines: + clipped_volume: + f0: + type: "contour" + params: + field: "Ex" + levels: 16 + f1: + type: "clip" + params: + topology: topo # name of the amr mesh + multi_plane: + point1: + x: 0.0 + y: 0.0 + z: 0.0 + normal1: + x: 0.0 + y: -1.0 + z: 0.0 + point2: + x: 0.0 + y: 0.0 + z: 0.0 + normal2: + x: -0.7 + y: -0.7 + z: 0.0 + sampled_particles: + f1: + type: histsampling + params: + field: particle_electrons_uz + bins: 64 + sample_rate: 0.90 + f2: + type: "clip" + params: + topology: particle_electrons # particle data + multi_plane: + point1: + x: 0.0 + y: 0.0 + z: 0.0 + normal1: + x: 0.0 + y: -1.0 + z: 0.0 + point2: + x: 0.0 + y: 0.0 + z: 0.0 + normal2: + x: -0.7 + y: -0.7 + z: 0.0 + +# Uncomment this block if you want to create "Conduit Blueprint files" that can +# be used with Ascent "replay" after the simulation run. +# Replay is a workflow to visualize individual steps without running the simulation again. +#- +# action: "add_extracts" +# extracts: +# e1: +# type: "relay" +# params: +# path: "./conduit_blueprint" +# protocol: "blueprint/mesh/hdf5" + +- + action: "add_scenes" + scenes: + scene1: + plots: + p0: + type: "pseudocolor" + field: "particle_electrons_uz" + pipeline: "sampled_particles" + p1: + type: "pseudocolor" + field: "Ex" + pipeline: "clipped_volume" + renders: + image1: + bg_color: [1.0, 1.0, 1.0] + fg_color: [0.0, 0.0, 0.0] + image_prefix: "lwfa_Ex_e-uz_%06d" + camera: + azimuth: 20 + elevation: 30 + zoom: 2.5 From dde26c13e9a54dbae396b02a3daad7f09652747d Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Thu, 22 Oct 2020 11:26:04 -0700 Subject: [PATCH 09/30] Fix warning with openPMD (#1452) --- Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp index 20e3bb311cd..dea1c37ac61 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp @@ -27,7 +27,7 @@ FlushFormatOpenPMD::WriteToFile ( const amrex::Vector& mf, amrex::Vector& geom, const amrex::Vector iteration, const double time, - const amrex::Vector& particle_diags, int nlev, + const amrex::Vector& particle_diags, int /*nlev*/, const std::string prefix, bool plot_raw_fields, bool plot_raw_fields_guards, bool plot_raw_rho, bool plot_raw_F) const { From 536c3b417666b11c7143d17cc5a7759b7af0da9c Mon Sep 17 00:00:00 2001 From: David Grote Date: Thu, 22 Oct 2020 15:12:20 -0700 Subject: [PATCH 10/30] picmi - minor cleanup, removing unneeded input quantities (#1446) --- Python/pywarpx/picmi.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index e6d3f53a968..7e7fbd9d429 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -132,10 +132,6 @@ def initialize_inputs(self, species_number, layout, species, density_scale): if density_scale is not None: species.q_tot *= density_scale - # --- These need to be defined even though they are not used - species.profile = "constant" - species.density = 1 - # --- The PICMI standard doesn't yet have a way of specifying these values. # --- They should default to the size of the domain. They are not typically # --- necessary though since any particles outside the domain are rejected. @@ -293,11 +289,6 @@ def initialize_inputs(self, species_number, layout, species, density_scale): if density_scale is not None: species.single_particle_weight *= density_scale - # --- These need to be defined even though they are not used - species.profile = "constant" - species.density = 1 - species.momentum_distribution_type = 'constant' - class ParticleDistributionPlanarInjector(picmistandard.PICMI_ParticleDistributionPlanarInjector): pass From cb199e221ae698ac13fdda691985e001ee84039b Mon Sep 17 00:00:00 2001 From: NeilZaim <49716072+NeilZaim@users.noreply.github.com> Date: Fri, 23 Oct 2020 04:48:16 +0200 Subject: [PATCH 11/30] Remove a few segfaults when there is zero particle species (#1449) * Remove a few segfaults when there is zero particle species * Docs: Update Example * We don't have `part_per_proc` so exemplify with something else. Co-authored-by: Axel Huebl --- Docs/source/running_cpp/parameters.rst | 2 +- Examples/Tests/Langmuir/README.md | 2 +- Source/Particles/MultiParticleContainer.H | 17 +++++ Source/Particles/MultiParticleContainer.cpp | 72 ++++++++++++++++----- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index f914ed25057..47233f06ad9 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -1433,7 +1433,7 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a * ``.fields_to_plot`` (list of `strings`, optional) Fields written to output. - Possible values: ``Ex`` ``Ey`` ``Ez`` ``Bx`` ``By`` ``Bz`` ``jx`` ``jy`` ``jz`` ``part_per_cell`` ``rho`` ``F`` ``part_per_grid`` ``part_per_proc`` ``divE`` ``divB`` and ``rho_``, where ```` must match the name of one of the available particle species. + Possible values: ``Ex`` ``Ey`` ``Ez`` ``Bx`` ``By`` ``Bz`` ``jx`` ``jy`` ``jz`` ``part_per_cell`` ``rho`` ``F`` ``part_per_grid`` ``divE`` ``divB`` and ``rho_``, where ```` must match the name of one of the available particle species. Default is ``.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz``. * ``.plot_raw_fields`` (`0` or `1`) optional (default `0`) diff --git a/Examples/Tests/Langmuir/README.md b/Examples/Tests/Langmuir/README.md index 8a782851c64..705bf845ca9 100644 --- a/Examples/Tests/Langmuir/README.md +++ b/Examples/Tests/Langmuir/README.md @@ -12,7 +12,7 @@ in this directory. mv plt00010 to plt00010.nolb 4) amrvis3d plt00010.lb plt00010.nolb - set the field to "part_per_proc" + set the field to "part_per_cell" You should see the effect of load balancing based of the number of particles. diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 4a515acf871..ed6c277fecf 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -112,6 +112,14 @@ public: const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz); + /** + * \brief This returns a MultiFAB filled with zeros. It is used to return the charge density + * when there is no particle species. + * + * @param[in] lev the index of the refinement level. + */ + std::unique_ptr GetZeroChargeDensity(const int lev); + /// /// This deposits the particle charge onto a node-centered MultiFab and returns a unique ptr /// to it. The charge density is accumulated over all the particles in the MultiParticleContainer @@ -160,6 +168,15 @@ public: * of the whole simulation BC. */ void ApplyBoundaryConditions (); + /** + * \brief This returns a vector filled with zeros whose size is the number of boxes in the + * simulation boxarray. It is used to return the number of particles in each grid when there is + * no particle species. + * + * @param[in] lev the index of the refinement level. + */ + amrex::Vector GetZeroParticlesInGrid(const int lev) const; + amrex::Vector NumberOfParticlesInGrid(int lev) const; void Increment (amrex::MultiFab& mf, int lev); diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index ef23f9de543..9fb67dc9164 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -359,19 +359,42 @@ MultiParticleContainer::PushP (int lev, Real dt, } } +std::unique_ptr +MultiParticleContainer::GetZeroChargeDensity (const int lev) +{ + WarpX& warpx = WarpX::GetInstance(); + + BoxArray ba = warpx.boxArray(lev); + DistributionMapping dmap = warpx.DistributionMap(lev); + const int ng_rho = warpx.get_ng_depos_rho().max(); + + auto zero_rho = std::make_unique(amrex::convert(ba,IntVect::TheNodeVector()), + dmap,WarpX::ncomps,ng_rho); + zero_rho->setVal(amrex::Real(0.0)); + return zero_rho; +} + std::unique_ptr MultiParticleContainer::GetChargeDensity (int lev, bool local) { - std::unique_ptr rho = allcontainers[0]->GetChargeDensity(lev, true); - for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { - std::unique_ptr rhoi = allcontainers[i]->GetChargeDensity(lev, true); - MultiFab::Add(*rho, *rhoi, 0, 0, rho->nComp(), rho->nGrow()); + if (allcontainers.size() == 0) + { + std::unique_ptr rho = GetZeroChargeDensity(lev); + return rho; } - if (!local) { - const Geometry& gm = allcontainers[0]->Geom(lev); - rho->SumBoundary(gm.periodicity()); + else + { + std::unique_ptr rho = allcontainers[0]->GetChargeDensity(lev, true); + for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { + std::unique_ptr rhoi = allcontainers[i]->GetChargeDensity(lev, true); + MultiFab::Add(*rho, *rhoi, 0, 0, rho->nComp(), rho->nGrow()); + } + if (!local) { + const Geometry& gm = allcontainers[0]->Geom(lev); + rho->SumBoundary(gm.periodicity()); + } + return rho; } - return rho; } void @@ -406,19 +429,36 @@ MultiParticleContainer::ApplyBoundaryConditions () } } +Vector +MultiParticleContainer::GetZeroParticlesInGrid (const int lev) const +{ + WarpX& warpx = WarpX::GetInstance(); + const int num_boxes = warpx.boxArray(lev).size(); + const Vector r(num_boxes, 0); + return r; +} + Vector MultiParticleContainer::NumberOfParticlesInGrid (int lev) const { - const bool only_valid=true, only_local=true; - Vector r = allcontainers[0]->NumberOfParticlesInGrid(lev,only_valid,only_local); - for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { - const auto& ri = allcontainers[i]->NumberOfParticlesInGrid(lev,only_valid,only_local); - for (unsigned j=0, m=ri.size(); j r = GetZeroParticlesInGrid(lev); + return r; + } + else + { + const bool only_valid=true, only_local=true; + Vector r = allcontainers[0]->NumberOfParticlesInGrid(lev,only_valid,only_local); + for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { + const auto& ri = allcontainers[i]->NumberOfParticlesInGrid(lev,only_valid,only_local); + for (unsigned j=0, m=ri.size(); j Date: Thu, 22 Oct 2020 21:15:06 -0700 Subject: [PATCH 12/30] Fix NVCC Regression in Parser (#1458) * Fix NVCC Regression in Parser Fix a regression with the recompilation of the parser that shows up with NVCC and GNUmake on Summit. * Modify Parser's makefile to remove #line and rename bison's output file to .cpp Co-authored-by: Weiqun Zhang --- Source/Parser/GNUmakefile | 5 +- Source/Parser/GpuParser.H | 3 +- Source/Parser/wp_parser.lex.cpp | 384 +++++++++----------- Source/Parser/wp_parser.lex.h | 248 +++---------- Source/Parser/wp_parser.tab.cpp | 612 +++++++++++++------------------- Source/Parser/wp_parser.tab.h | 13 +- 6 files changed, 488 insertions(+), 777 deletions(-) diff --git a/Source/Parser/GNUmakefile b/Source/Parser/GNUmakefile index 50f06816c6e..e3d3d7276d7 100644 --- a/Source/Parser/GNUmakefile +++ b/Source/Parser/GNUmakefile @@ -1,4 +1,5 @@ default: - bison -d wp_parser.y - flex -o wp_parser.lex.cpp --header-file=wp_parser.lex.h wp_parser.l + bison -d --no-lines wp_parser.y + flex --noline -o wp_parser.lex.cpp --header-file=wp_parser.lex.h wp_parser.l + mv -f wp_parser.tab.c wp_parser.tab.cpp diff --git a/Source/Parser/GpuParser.H b/Source/Parser/GpuParser.H index 0b5ac8d7f67..393fd48e74e 100644 --- a/Source/Parser/GpuParser.H +++ b/Source/Parser/GpuParser.H @@ -40,12 +40,13 @@ public: operator() (Ts... var) const noexcept { #ifdef AMREX_USE_GPU - amrex::GpuArray l_var{var...}; #if AMREX_DEVICE_COMPILE // WarpX compiled for GPU, function compiled for __device__ + amrex::GpuArray l_var{var...}; return wp_ast_eval<0>(m_gpu_parser_ast, l_var.data()); #else // WarpX compiled for GPU, function compiled for __host__ + amrex::ignore_unused(var...); return wp_ast_eval<0>(m_cpu_parser->ast, nullptr); #endif diff --git a/Source/Parser/wp_parser.lex.cpp b/Source/Parser/wp_parser.lex.cpp index 2dbac3dedf0..1991770e6c5 100644 --- a/Source/Parser/wp_parser.lex.cpp +++ b/Source/Parser/wp_parser.lex.cpp @@ -1,6 +1,3 @@ -#line 2 "wp_parser.lex.cpp" - -#line 4 "wp_parser.lex.cpp" #define YY_INT_ALIGNED short int @@ -9,7 +6,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 +#define YY_FLEX_SUBMINOR_VERSION 0 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -84,48 +81,60 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -/* begin standard C++ headers. */ +#ifdef __cplusplus -/* TODO: this is always defined, so inline it */ -#define yyconst const +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const #else -#define yynoreturn +#define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * + /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START + /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) +#define YY_NEW_FILE yyrestart(yyin ) + #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -155,14 +164,14 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern int yyleng; +extern yy_size_t yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) @@ -179,6 +188,7 @@ extern FILE *yyin, *yyout; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) + #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -193,7 +203,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - int yy_buf_size; + yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -221,7 +231,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -249,7 +259,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -260,6 +270,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) + /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -268,10 +279,10 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; +yy_size_t yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; +static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -280,59 +291,65 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart ( FILE *input_file ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); -void yy_delete_buffer ( YY_BUFFER_STATE b ); -void yy_flush_buffer ( YY_BUFFER_STATE b ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state ( void ); +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); -static void yyensure_buffer_stack ( void ); -static void yy_load_buffer_state ( void ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); -void *yyalloc ( yy_size_t ); -void *yyrealloc ( void *, yy_size_t ); -void yyfree ( void * ); +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); #define yy_new_buffer yy_create_buffer + #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } + #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } + #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define yywrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; -FILE *yyin = NULL, *yyout = NULL; +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; + int yylineno = 1; extern char *yytext; @@ -341,20 +358,24 @@ extern char *yytext; #endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state ( void ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); -static int yy_get_next_buffer ( void ); -static void yynoreturn yy_fatal_error ( const char* msg ); +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +#if defined(__GNUC__) && __GNUC__ >= 3 +__attribute__((__noreturn__)) +#endif +static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; + #define YY_NUM_RULES 47 #define YY_END_OF_BUFFER 48 /* This struct is not used in this scanner, @@ -364,7 +385,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[104] = +static yyconst flex_int16_t yy_accept[104] = { 0, 0, 0, 48, 46, 43, 45, 46, 10, 11, 3, 1, 7, 2, 46, 4, 41, 8, 5, 9, 39, @@ -380,7 +401,7 @@ static const flex_int16_t yy_accept[104] = 39, 36, 0 } ; -static const YY_CHAR yy_ec[256] = +static yyconst YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -412,7 +433,7 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[45] = +static yyconst YY_CHAR yy_meta[45] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, @@ -421,7 +442,7 @@ static const YY_CHAR yy_meta[45] = 3, 3, 3, 1 } ; -static const flex_int16_t yy_base[106] = +static yyconst flex_uint16_t yy_base[106] = { 0, 0, 0, 156, 157, 157, 157, 138, 157, 157, 147, 157, 157, 157, 32, 141, 37, 135, 134, 133, 0, @@ -437,7 +458,7 @@ static const flex_int16_t yy_base[106] = 32, 0, 157, 53, 115 } ; -static const flex_int16_t yy_def[106] = +static yyconst flex_int16_t yy_def[106] = { 0, 103, 1, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 104, @@ -453,7 +474,7 @@ static const flex_int16_t yy_def[106] = 104, 104, 0, 103, 103 } ; -static const flex_int16_t yy_nxt[202] = +static yyconst flex_uint16_t yy_nxt[202] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 17, 18, 19, 20, 20, @@ -480,7 +501,7 @@ static const flex_int16_t yy_nxt[202] = 103 } ; -static const flex_int16_t yy_chk[202] = +static yyconst flex_int16_t yy_chk[202] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -521,16 +542,11 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "wp_parser.l" -#line 3 "wp_parser.l" #include "wp_parser_y.h" #include "wp_parser.tab.h" -#line 529 "wp_parser.lex.cpp" -#line 10 "wp_parser.l" - /* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ - /* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ - /* Used leater to define NUMBER */ -#line 534 "wp_parser.lex.cpp" +/* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ +/* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ +/* Used leater to define NUMBER */ #define INITIAL 0 @@ -546,36 +562,36 @@ char *yytext; #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals ( void ); +static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy ( void ); +int yylex_destroy (void ); -int yyget_debug ( void ); +int yyget_debug (void ); -void yyset_debug ( int debug_flag ); +void yyset_debug (int debug_flag ); -YY_EXTRA_TYPE yyget_extra ( void ); +YY_EXTRA_TYPE yyget_extra (void ); -void yyset_extra ( YY_EXTRA_TYPE user_defined ); +void yyset_extra (YY_EXTRA_TYPE user_defined ); -FILE *yyget_in ( void ); +FILE *yyget_in (void ); -void yyset_in ( FILE * _in_str ); +void yyset_in (FILE * _in_str ); -FILE *yyget_out ( void ); +FILE *yyget_out (void ); -void yyset_out ( FILE * _out_str ); +void yyset_out (FILE * _out_str ); - int yyget_leng ( void ); +yy_size_t yyget_leng (void ); -char *yyget_text ( void ); +char *yyget_text (void ); -int yyget_lineno ( void ); +int yyget_lineno (void ); -void yyset_lineno ( int _line_number ); +void yyset_lineno (int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -583,9 +599,9 @@ void yyset_lineno ( int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap ( void ); +extern "C" int yywrap (void ); #else -extern int yywrap ( void ); +extern int yywrap (void ); #endif #endif @@ -594,18 +610,19 @@ extern int yywrap ( void ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int ); +static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * ); +static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT + #ifdef __cplusplus -static int yyinput ( void ); +static int yyinput (void ); #else -static int input ( void ); +static int input (void ); #endif #endif @@ -625,7 +642,7 @@ static int input ( void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -636,7 +653,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -649,7 +666,7 @@ static int input ( void ); else \ { \ errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -738,17 +755,13 @@ YY_DECL if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); + yy_create_buffer(yyin,YY_BUF_SIZE ); } - yy_load_buffer_state( ); + yy_load_buffer_state( ); } { -#line 16 "wp_parser.l" - - -#line 752 "wp_parser.lex.cpp" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -776,9 +789,9 @@ YY_DECL { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 157 ); @@ -806,216 +819,168 @@ YY_DECL goto yy_find_action; case 1: -#line 19 "wp_parser.l" case 2: -#line 20 "wp_parser.l" case 3: -#line 21 "wp_parser.l" case 4: -#line 22 "wp_parser.l" case 5: -#line 23 "wp_parser.l" case 6: -#line 24 "wp_parser.l" case 7: -#line 25 "wp_parser.l" case 8: -#line 26 "wp_parser.l" case 9: -#line 27 "wp_parser.l" case 10: -#line 28 "wp_parser.l" case 11: YY_RULE_SETUP -#line 28 "wp_parser.l" { return yytext[0]; } /* simply pass through */ YY_BREAK /* yylval is union type defined in wp_parser.tab.h that is generated * by bison with wp_parser.y */ case 12: YY_RULE_SETUP -#line 33 "wp_parser.l" { yylval.f1 = WP_SQRT; return F1; } YY_BREAK case 13: YY_RULE_SETUP -#line 34 "wp_parser.l" { yylval.f1 = WP_EXP; return F1; } YY_BREAK case 14: YY_RULE_SETUP -#line 35 "wp_parser.l" { yylval.f1 = WP_LOG; return F1; } YY_BREAK case 15: YY_RULE_SETUP -#line 36 "wp_parser.l" { yylval.f1 = WP_LOG10; return F1; } YY_BREAK case 16: YY_RULE_SETUP -#line 37 "wp_parser.l" { yylval.f1 = WP_SIN; return F1; } YY_BREAK case 17: YY_RULE_SETUP -#line 38 "wp_parser.l" { yylval.f1 = WP_COS; return F1; } YY_BREAK case 18: YY_RULE_SETUP -#line 39 "wp_parser.l" { yylval.f1 = WP_TAN; return F1; } YY_BREAK case 19: YY_RULE_SETUP -#line 40 "wp_parser.l" { yylval.f1 = WP_ASIN; return F1; } YY_BREAK case 20: YY_RULE_SETUP -#line 41 "wp_parser.l" { yylval.f1 = WP_ACOS; return F1; } YY_BREAK case 21: YY_RULE_SETUP -#line 42 "wp_parser.l" { yylval.f1 = WP_ATAN; return F1; } YY_BREAK case 22: YY_RULE_SETUP -#line 43 "wp_parser.l" { yylval.f1 = WP_SINH; return F1; } YY_BREAK case 23: YY_RULE_SETUP -#line 44 "wp_parser.l" { yylval.f1 = WP_COSH; return F1; } YY_BREAK case 24: YY_RULE_SETUP -#line 45 "wp_parser.l" { yylval.f1 = WP_TANH; return F1; } YY_BREAK case 25: YY_RULE_SETUP -#line 46 "wp_parser.l" { yylval.f1 = WP_ABS; return F1; } YY_BREAK case 26: YY_RULE_SETUP -#line 47 "wp_parser.l" { yylval.f1 = WP_ABS; return F1; } YY_BREAK case 27: YY_RULE_SETUP -#line 48 "wp_parser.l" { yylval.f2 = WP_POW; return POW;} YY_BREAK case 28: YY_RULE_SETUP -#line 49 "wp_parser.l" { yylval.f2 = WP_POW; return POW;} YY_BREAK case 29: YY_RULE_SETUP -#line 50 "wp_parser.l" { yylval.f2 = WP_GEQ; return GEQ;} YY_BREAK case 30: YY_RULE_SETUP -#line 51 "wp_parser.l" { yylval.f2 = WP_LEQ; return LEQ;} YY_BREAK case 31: YY_RULE_SETUP -#line 52 "wp_parser.l" { yylval.f2 = WP_EQ; return EQ;} YY_BREAK case 32: YY_RULE_SETUP -#line 53 "wp_parser.l" { yylval.f2 = WP_NEQ; return NEQ;} YY_BREAK case 33: YY_RULE_SETUP -#line 54 "wp_parser.l" { yylval.f2 = WP_AND; return AND;} YY_BREAK case 34: YY_RULE_SETUP -#line 55 "wp_parser.l" { yylval.f2 = WP_OR; return OR;} YY_BREAK case 35: YY_RULE_SETUP -#line 56 "wp_parser.l" { yylval.f2 = WP_POW; return F2; } YY_BREAK case 36: YY_RULE_SETUP -#line 57 "wp_parser.l" { yylval.f2 = WP_HEAVISIDE; return F2; } YY_BREAK case 37: YY_RULE_SETUP -#line 58 "wp_parser.l" { yylval.f2 = WP_MIN; return F2; } YY_BREAK case 38: YY_RULE_SETUP -#line 59 "wp_parser.l" { yylval.f2 = WP_MAX; return F2; } YY_BREAK /* We use SYMBOL to hold variables and constants */ case 39: YY_RULE_SETUP -#line 62 "wp_parser.l" { yylval.s = wp_makesymbol(yytext); return SYMBOL; } YY_BREAK /* Number */ case 40: -#line 66 "wp_parser.l" case 41: YY_RULE_SETUP -#line 66 "wp_parser.l" { yylval.d = atof(yytext); return NUMBER; } YY_BREAK /* Special characters */ case 42: YY_RULE_SETUP -#line 69 "wp_parser.l" YY_BREAK case 43: YY_RULE_SETUP -#line 70 "wp_parser.l" /* ignore white space */ YY_BREAK case 44: /* rule 44 can match eol */ YY_RULE_SETUP -#line 71 "wp_parser.l" /* ignore line continuation */ YY_BREAK case 45: /* rule 45 can match eol */ YY_RULE_SETUP -#line 72 "wp_parser.l" { return EOL; } YY_BREAK /* everything else */ case 46: YY_RULE_SETUP -#line 75 "wp_parser.l" { yyerror("Unknown character %c\n", *yytext); } YY_BREAK case 47: YY_RULE_SETUP -#line 77 "wp_parser.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1019 "wp_parser.lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1093,7 +1058,7 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1160,7 +1125,7 @@ static int yy_get_next_buffer (void) { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); - int number_to_move, i; + yy_size_t number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1189,7 +1154,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1202,7 +1167,7 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1216,7 +1181,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1225,12 +1190,11 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) ); + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; + b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1258,7 +1222,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); + yyrestart(yyin ); } else @@ -1272,15 +1236,12 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1313,9 +1274,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; @@ -1341,9 +1302,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[yy_c]; + yy_c = yy_meta[(unsigned int) yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 103); return yy_is_jam ? 0 : yy_current_state; @@ -1377,7 +1338,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1394,14 +1355,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - yyrestart( yyin ); + yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) - return 0; + if ( yywrap( ) ) + return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1438,11 +1399,11 @@ static int yy_get_next_buffer (void) if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); + yy_create_buffer(yyin,YY_BUF_SIZE ); } - yy_init_buffer( YY_CURRENT_BUFFER, input_file ); - yy_load_buffer_state( ); + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. @@ -1470,7 +1431,7 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1498,22 +1459,22 @@ static void yy_load_buffer_state (void) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = (yy_size_t)size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer( b, file ); + yy_init_buffer(b,file ); return b; } @@ -1532,9 +1493,9 @@ static void yy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf ); + yyfree((void *) b->yy_ch_buf ); - yyfree( (void *) b ); + yyfree((void *) b ); } /* Initializes or reinitializes a buffer. @@ -1546,7 +1507,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - yy_flush_buffer( b ); + yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1589,7 +1550,7 @@ static void yy_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -1620,7 +1581,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -1639,7 +1600,7 @@ void yypop_buffer_state (void) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1657,15 +1618,15 @@ static void yyensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1694,7 +1655,7 @@ static void yyensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { @@ -1704,23 +1665,23 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return NULL; + return 0; - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; + b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer( b ); + yy_switch_to_buffer(b ); return b; } @@ -1733,10 +1694,10 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (const char * yystr ) +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { - return yy_scan_bytes( yystr, (int) strlen(yystr) ); + return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will @@ -1746,16 +1707,16 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n ); + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); @@ -1764,7 +1725,7 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n ); + b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1780,9 +1741,9 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) #define YY_EXIT_FAILURE 2 #endif -static void yynoreturn yy_fatal_error (const char* msg ) +static void yy_fatal_error (yyconst char* msg ) { - fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1810,7 +1771,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) */ int yyget_lineno (void) { - + return yylineno; } @@ -1833,7 +1794,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -int yyget_leng (void) +yy_size_t yyget_leng (void) { return yyleng; } @@ -1889,10 +1850,10 @@ static int yy_init_globals (void) * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = NULL; + (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = NULL; + (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; @@ -1901,8 +1862,8 @@ static int yy_init_globals (void) yyin = stdin; yyout = stdout; #else - yyin = NULL; - yyout = NULL; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by @@ -1917,7 +1878,7 @@ int yylex_destroy (void) /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1938,7 +1899,7 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n ) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { int i; @@ -1948,7 +1909,7 @@ static void yy_flex_strncpy (char* s1, const char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s ) +static int yy_flex_strlen (yyconst char * s ) { int n; for ( n = 0; s[n]; ++n ) @@ -1960,7 +1921,7 @@ static int yy_flex_strlen (const char * s ) void *yyalloc (yy_size_t size ) { - return malloc(size); + return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) @@ -1973,7 +1934,7 @@ void *yyrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return realloc(ptr, size); + return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr ) @@ -1983,6 +1944,3 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 77 "wp_parser.l" - - diff --git a/Source/Parser/wp_parser.lex.h b/Source/Parser/wp_parser.lex.h index 272cf15211f..71f0f7a3c60 100644 --- a/Source/Parser/wp_parser.lex.h +++ b/Source/Parser/wp_parser.lex.h @@ -2,10 +2,6 @@ #define yyHEADER_H 1 #define yyIN_HEADER 1 -#line 6 "wp_parser.lex.h" - -#line 8 "wp_parser.lex.h" - #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ @@ -13,7 +9,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 +#define YY_FLEX_SUBMINOR_VERSION 0 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -88,23 +84,29 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -/* begin standard C++ headers. */ +#ifdef __cplusplus -/* TODO: this is always defined, so inline it */ -#define yyconst const +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const #else -#define yynoreturn +#define yyconst #endif /* Size of default input buffer. */ @@ -130,7 +132,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern int yyleng; +extern yy_size_t yyleng; extern FILE *yyin, *yyout; @@ -146,7 +148,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - int yy_buf_size; + yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -174,7 +176,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -185,21 +187,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void yyrestart ( FILE *input_file ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); -void yy_delete_buffer ( YY_BUFFER_STATE b ); -void yy_flush_buffer ( YY_BUFFER_STATE b ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state ( void ); +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); -void *yyalloc ( yy_size_t ); -void *yyrealloc ( void *, yy_size_t ); -void yyfree ( void * ); +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); /* Begin user sect3 */ @@ -234,31 +236,31 @@ extern char *yytext; /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy ( void ); +int yylex_destroy (void ); -int yyget_debug ( void ); +int yyget_debug (void ); -void yyset_debug ( int debug_flag ); +void yyset_debug (int debug_flag ); -YY_EXTRA_TYPE yyget_extra ( void ); +YY_EXTRA_TYPE yyget_extra (void ); -void yyset_extra ( YY_EXTRA_TYPE user_defined ); +void yyset_extra (YY_EXTRA_TYPE user_defined ); -FILE *yyget_in ( void ); +FILE *yyget_in (void ); -void yyset_in ( FILE * _in_str ); +void yyset_in (FILE * _in_str ); -FILE *yyget_out ( void ); +FILE *yyget_out (void ); -void yyset_out ( FILE * _out_str ); +void yyset_out (FILE * _out_str ); - int yyget_leng ( void ); +yy_size_t yyget_leng (void ); -char *yyget_text ( void ); +char *yyget_text (void ); -int yyget_lineno ( void ); +int yyget_lineno (void ); -void yyset_lineno ( int _line_number ); +void yyset_lineno (int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -266,18 +268,18 @@ void yyset_lineno ( int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap ( void ); +extern "C" int yywrap (void ); #else -extern int yywrap ( void ); +extern int yywrap (void ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int ); +static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * ); +static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT @@ -324,154 +326,6 @@ extern int yylex (void); #undef YY_DECL #endif -#ifndef yy_create_buffer_ALREADY_DEFINED -#undef yy_create_buffer -#endif -#ifndef yy_delete_buffer_ALREADY_DEFINED -#undef yy_delete_buffer -#endif -#ifndef yy_scan_buffer_ALREADY_DEFINED -#undef yy_scan_buffer -#endif -#ifndef yy_scan_string_ALREADY_DEFINED -#undef yy_scan_string -#endif -#ifndef yy_scan_bytes_ALREADY_DEFINED -#undef yy_scan_bytes -#endif -#ifndef yy_init_buffer_ALREADY_DEFINED -#undef yy_init_buffer -#endif -#ifndef yy_flush_buffer_ALREADY_DEFINED -#undef yy_flush_buffer -#endif -#ifndef yy_load_buffer_state_ALREADY_DEFINED -#undef yy_load_buffer_state -#endif -#ifndef yy_switch_to_buffer_ALREADY_DEFINED -#undef yy_switch_to_buffer -#endif -#ifndef yypush_buffer_state_ALREADY_DEFINED -#undef yypush_buffer_state -#endif -#ifndef yypop_buffer_state_ALREADY_DEFINED -#undef yypop_buffer_state -#endif -#ifndef yyensure_buffer_stack_ALREADY_DEFINED -#undef yyensure_buffer_stack -#endif -#ifndef yylex_ALREADY_DEFINED -#undef yylex -#endif -#ifndef yyrestart_ALREADY_DEFINED -#undef yyrestart -#endif -#ifndef yylex_init_ALREADY_DEFINED -#undef yylex_init -#endif -#ifndef yylex_init_extra_ALREADY_DEFINED -#undef yylex_init_extra -#endif -#ifndef yylex_destroy_ALREADY_DEFINED -#undef yylex_destroy -#endif -#ifndef yyget_debug_ALREADY_DEFINED -#undef yyget_debug -#endif -#ifndef yyset_debug_ALREADY_DEFINED -#undef yyset_debug -#endif -#ifndef yyget_extra_ALREADY_DEFINED -#undef yyget_extra -#endif -#ifndef yyset_extra_ALREADY_DEFINED -#undef yyset_extra -#endif -#ifndef yyget_in_ALREADY_DEFINED -#undef yyget_in -#endif -#ifndef yyset_in_ALREADY_DEFINED -#undef yyset_in -#endif -#ifndef yyget_out_ALREADY_DEFINED -#undef yyget_out -#endif -#ifndef yyset_out_ALREADY_DEFINED -#undef yyset_out -#endif -#ifndef yyget_leng_ALREADY_DEFINED -#undef yyget_leng -#endif -#ifndef yyget_text_ALREADY_DEFINED -#undef yyget_text -#endif -#ifndef yyget_lineno_ALREADY_DEFINED -#undef yyget_lineno -#endif -#ifndef yyset_lineno_ALREADY_DEFINED -#undef yyset_lineno -#endif -#ifndef yyget_column_ALREADY_DEFINED -#undef yyget_column -#endif -#ifndef yyset_column_ALREADY_DEFINED -#undef yyset_column -#endif -#ifndef yywrap_ALREADY_DEFINED -#undef yywrap -#endif -#ifndef yyget_lval_ALREADY_DEFINED -#undef yyget_lval -#endif -#ifndef yyset_lval_ALREADY_DEFINED -#undef yyset_lval -#endif -#ifndef yyget_lloc_ALREADY_DEFINED -#undef yyget_lloc -#endif -#ifndef yyset_lloc_ALREADY_DEFINED -#undef yyset_lloc -#endif -#ifndef yyalloc_ALREADY_DEFINED -#undef yyalloc -#endif -#ifndef yyrealloc_ALREADY_DEFINED -#undef yyrealloc -#endif -#ifndef yyfree_ALREADY_DEFINED -#undef yyfree -#endif -#ifndef yytext_ALREADY_DEFINED -#undef yytext -#endif -#ifndef yyleng_ALREADY_DEFINED -#undef yyleng -#endif -#ifndef yyin_ALREADY_DEFINED -#undef yyin -#endif -#ifndef yyout_ALREADY_DEFINED -#undef yyout -#endif -#ifndef yy_flex_debug_ALREADY_DEFINED -#undef yy_flex_debug -#endif -#ifndef yylineno_ALREADY_DEFINED -#undef yylineno -#endif -#ifndef yytables_fload_ALREADY_DEFINED -#undef yytables_fload -#endif -#ifndef yytables_destroy_ALREADY_DEFINED -#undef yytables_destroy -#endif -#ifndef yyTABLES_NAME_ALREADY_DEFINED -#undef yyTABLES_NAME -#endif - -#line 77 "wp_parser.l" - - -#line 476 "wp_parser.lex.h" +#line 330 "wp_parser.lex.h" #undef yyIN_HEADER #endif /* yyHEADER_H */ diff --git a/Source/Parser/wp_parser.tab.cpp b/Source/Parser/wp_parser.tab.cpp index 56bff07bb82..581cf7fdf96 100644 --- a/Source/Parser/wp_parser.tab.cpp +++ b/Source/Parser/wp_parser.tab.cpp @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.5.1. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,14 +40,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.5.1" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -65,8 +61,8 @@ -/* First part of user prologue. */ -#line 2 "wp_parser.y" +/* Copy the first part of user declarations. */ + #include #include @@ -74,26 +70,13 @@ #include "wp_parser_y.h" int yylex (void); -#line 78 "wp_parser.tab.c" -# ifndef YY_CAST -# ifdef __cplusplus -# define YY_CAST(Type, Val) static_cast (Val) -# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) -# else -# define YY_CAST(Type, Val) ((Type) (Val)) -# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) -# endif -# endif + # ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr # else -# define YY_NULLPTR ((void*)0) +# define YY_NULLPTR 0 # endif # endif @@ -105,8 +88,8 @@ # define YYERROR_VERBOSE 0 #endif -/* Use api.header.include to #include this header - instead of duplicating it here. */ +/* In a future release of Bison, this section will be replaced + by #include "wp_parser.tab.h". */ #ifndef YY_YY_WP_PARSER_TAB_H_INCLUDED # define YY_YY_WP_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -142,9 +125,10 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + union YYSTYPE { -#line 19 "wp_parser.y" + struct wp_node* n; amrex_real d; @@ -152,9 +136,9 @@ union YYSTYPE enum wp_f1_t f1; enum wp_f2_t f2; -#line 156 "wp_parser.tab.c" }; + typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -167,81 +151,36 @@ int yyparse (void); #endif /* !YY_YY_WP_PARSER_TAB_H_INCLUDED */ +/* Copy the second part of user declarations. */ + #ifdef short # undef short #endif -/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure - and (if available) are included - so that the code can choose integer types of a good width. */ - -#ifndef __PTRDIFF_MAX__ -# include /* INFRINGES ON USER NAME SPACE */ -# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_STDINT_H -# endif -#endif - -/* Narrow types that promote to a signed type and that can represent a - signed or unsigned integer of at least N bits. In tables they can - save space and decrease cache pressure. Promoting to a signed type - helps avoid bugs in integer arithmetic. */ - -#ifdef __INT_LEAST8_MAX__ -typedef __INT_LEAST8_TYPE__ yytype_int8; -#elif defined YY_STDINT_H -typedef int_least8_t yytype_int8; +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; #else -typedef signed char yytype_int8; +typedef unsigned char yytype_uint8; #endif -#ifdef __INT_LEAST16_MAX__ -typedef __INT_LEAST16_TYPE__ yytype_int16; -#elif defined YY_STDINT_H -typedef int_least16_t yytype_int16; +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; #else -typedef short yytype_int16; +typedef signed char yytype_int8; #endif -#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST8_TYPE__ yytype_uint8; -#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST8_MAX <= INT_MAX) -typedef uint_least8_t yytype_uint8; -#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX -typedef unsigned char yytype_uint8; +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; #else -typedef short yytype_uint8; +typedef unsigned short int yytype_uint16; #endif -#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST16_TYPE__ yytype_uint16; -#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST16_MAX <= INT_MAX) -typedef uint_least16_t yytype_uint16; -#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX -typedef unsigned short yytype_uint16; +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; #else -typedef int yytype_uint16; -#endif - -#ifndef YYPTRDIFF_T -# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ -# define YYPTRDIFF_T __PTRDIFF_TYPE__ -# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ -# elif defined PTRDIFF_MAX -# ifndef ptrdiff_t -# include /* INFRINGES ON USER NAME SPACE */ -# endif -# define YYPTRDIFF_T ptrdiff_t -# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX -# else -# define YYPTRDIFF_T long -# define YYPTRDIFF_MAXIMUM LONG_MAX -# endif +typedef short int yytype_int16; #endif #ifndef YYSIZE_T @@ -249,27 +188,15 @@ typedef int yytype_uint16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned +# define YYSIZE_T unsigned int # endif #endif -#define YYSIZE_MAXIMUM \ - YY_CAST (YYPTRDIFF_T, \ - (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ - ? YYPTRDIFF_MAXIMUM \ - : YY_CAST (YYSIZE_T, -1))) - -#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) - -/* Stored state numbers (used for stacks). */ -typedef yytype_int8 yy_state_t; - -/* State numbers in computations. */ -typedef int yy_state_fast_t; +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -283,19 +210,30 @@ typedef int yy_state_fast_t; # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else -# define YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + #ifndef YY_ATTRIBUTE_UNUSED -# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) # else -# define YY_ATTRIBUTE_UNUSED +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif @@ -306,13 +244,13 @@ typedef int yy_state_fast_t; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -325,20 +263,6 @@ typedef int yy_state_fast_t; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif -#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ -# define YY_IGNORE_USELESS_CAST_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") -# define YY_IGNORE_USELESS_CAST_END \ - _Pragma ("GCC diagnostic pop") -#endif -#ifndef YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_END -#endif - - -#define YY_ASSERT(E) ((void) (0 && (E))) #if ! defined yyoverflow || YYERROR_VERBOSE @@ -415,17 +339,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yy_state_t yyss_alloc; + yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -438,11 +362,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYPTRDIFF_T yynewbytes; \ + YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / YYSIZEOF (*yyptr); \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) @@ -454,12 +378,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYPTRDIFF_T yyi; \ + YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -482,18 +406,17 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 50 +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 272 - -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ -static const yytype_int8 yytranslate[] = + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -527,7 +450,7 @@ static const yytype_int8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_int8 yyrline[] = +static const yytype_uint8 yyrline[] = { 0, 67, 67, 68, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, @@ -550,7 +473,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_int16 yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 94, 265, 266, 267, 268, 269, 270, 61, 60, 62, @@ -558,14 +481,14 @@ static const yytype_int16 yytoknum[] = }; # endif -#define YYPACT_NINF (-24) +#define YYPACT_NINF -24 -#define yypact_value_is_default(Yyn) \ - ((Yyn) == YYPACT_NINF) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-24))) -#define YYTABLE_NINF (-1) +#define YYTABLE_NINF -1 -#define yytable_value_is_error(Yyn) \ +#define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -582,7 +505,7 @@ static const yytype_int16 yypact[] = /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_int8 yydefact[] = +static const yytype_uint8 yydefact[] = { 2, 0, 1, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 20, 19, 0, 3, 0, 0, 0, @@ -606,7 +529,7 @@ static const yytype_int8 yydefgoto[] = /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int8 yytable[] = +static const yytype_uint8 yytable[] = { 13, 14, 15, 11, 30, 31, 12, 17, 0, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, @@ -654,7 +577,7 @@ static const yytype_int8 yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_int8 yystos[] = +static const yytype_uint8 yystos[] = { 0, 30, 0, 4, 5, 6, 7, 20, 21, 26, 31, 26, 26, 31, 31, 31, 8, 9, 11, 12, @@ -664,7 +587,7 @@ static const yytype_int8 yystos[] = }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_int8 yyr1[] = +static const yytype_uint8 yyr1[] = { 0, 29, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, @@ -672,7 +595,7 @@ static const yytype_int8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_int8 yyr2[] = +static const yytype_uint8 yyr2[] = { 0, 2, 0, 3, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, @@ -692,22 +615,22 @@ static const yytype_int8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) /* Error token number */ #define YYTERROR 1 @@ -747,39 +670,37 @@ do { \ } while (0) -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyoutput = yyo; - YYUSE (yyoutput); + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyo, "%s %s (", + YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyo, yytype, yyvaluep); - YYFPRINTF (yyo, ")"); + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. @@ -788,7 +709,7 @@ yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -811,20 +732,20 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - int yylno = yyrline[yyrule]; + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[+yyssp[yyi + 1 - yynrhs]], - &yyvsp[(yyi + 1) - (yynrhs)] + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } @@ -868,13 +789,13 @@ int yydebug; # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H -# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) +# define yystrlen strlen # else /* Return the length of YYSTR. */ -static YYPTRDIFF_T +static YYSIZE_T yystrlen (const char *yystr) { - YYPTRDIFF_T yylen; + YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; @@ -910,12 +831,12 @@ yystpcpy (char *yydest, const char *yysrc) backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYPTRDIFF_T +static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - YYPTRDIFF_T yyn = 0; + YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) @@ -928,10 +849,7 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - else - goto append; - - append: + /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; @@ -946,10 +864,10 @@ yytnamerr (char *yyres, const char *yystr) do_not_strip_quotes: ; } - if (yyres) - return yystpcpy (yyres, yystr) - yyres; - else + if (! yyres) return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; } # endif @@ -962,19 +880,19 @@ yytnamerr (char *yyres, const char *yystr) *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int -yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, - yy_state_t *yyssp, int yytoken) +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat: reported tokens (one for the "unexpected", - one per "expected"). */ + /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Actual size of YYARG. */ + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ int yycount = 0; - /* Cumulated lengths of YYARG. */ - YYPTRDIFF_T yysize = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then @@ -1001,9 +919,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, */ if (yytoken != YYEMPTY) { - int yyn = yypact[+*yyssp]; - YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - yysize = yysize0; + int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { @@ -1028,12 +944,11 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYPTRDIFF_T yysize1 - = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } } } @@ -1045,7 +960,6 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break - default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1056,13 +970,10 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, } { - /* Don't count the "%s"s in the final size, but reserve room for - the terminator. */ - YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1088,8 +999,8 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, } else { - ++yyp; - ++yyformat; + yyp++; + yyformat++; } } return 0; @@ -1132,7 +1043,7 @@ int yynerrs; int yyparse (void) { - yy_state_fast_t yystate; + int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1144,16 +1055,16 @@ yyparse (void) to reallocate them elsewhere. */ /* The state stack. */ - yy_state_t yyssa[YYINITDEPTH]; - yy_state_t *yyss; - yy_state_t *yyssp; + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; - YYPTRDIFF_T yystacksize; + YYSIZE_T yystacksize; int yyn; int yyresult; @@ -1167,7 +1078,7 @@ yyparse (void) /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; - YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1188,54 +1099,46 @@ yyparse (void) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; - /*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | +| yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ -yynewstate: + yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - -/*--------------------------------------------------------------------. -| yysetstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - YY_IGNORE_USELESS_CAST_BEGIN - *yyssp = YY_CAST (yy_state_t, yystate); - YY_IGNORE_USELESS_CAST_END + yysetstate: + *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - goto yyexhaustedlab; -#else { /* Get the current used size of the three stacks, in elements. */ - YYPTRDIFF_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = yyssp - yyss + 1; -# if defined yyoverflow +#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ - yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * YYSIZEOF (*yyssp), - &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); + yyss = yyss1; yyvs = yyvs1; } -# else /* defined YYSTACK_RELOCATE */ +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1244,43 +1147,42 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yy_state_t *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = - YY_CAST (union yyalloc *, - YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif +#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YY_IGNORE_USELESS_CAST_BEGIN - YYDPRINTF ((stderr, "Stack size increased to %ld\n", - YY_CAST (long, yystacksize))); - YY_IGNORE_USELESS_CAST_END + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: + /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1330,13 +1232,15 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END - /* Discard the shifted token. */ - yychar = YYEMPTY; goto yynewstate; @@ -1351,7 +1255,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- do a reduction. | +| yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1371,136 +1275,135 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: -#line 68 "wp_parser.y" - { + case 3: + + { wp_defexpr((yyvsp[-1].n)); } -#line 1380 "wp_parser.tab.c" + break; case 4: -#line 77 "wp_parser.y" - { (yyval.n) = wp_newnumber((yyvsp[0].d)); } -#line 1386 "wp_parser.tab.c" + + { (yyval.n) = wp_newnumber((yyvsp[0].d)); } + break; case 5: -#line 78 "wp_parser.y" - { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } -#line 1392 "wp_parser.tab.c" + + { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } + break; case 6: -#line 79 "wp_parser.y" - { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1398 "wp_parser.tab.c" + + { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 7: -#line 80 "wp_parser.y" - { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1404 "wp_parser.tab.c" + + { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 8: -#line 81 "wp_parser.y" - { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1410 "wp_parser.tab.c" + + { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 9: -#line 82 "wp_parser.y" - { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1416 "wp_parser.tab.c" + + { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 10: -#line 83 "wp_parser.y" - { (yyval.n) = (yyvsp[-1].n); } -#line 1422 "wp_parser.tab.c" + + { (yyval.n) = (yyvsp[-1].n); } + break; case 11: -#line 84 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1428 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 12: -#line 85 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1434 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 13: -#line 86 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1440 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 14: -#line 87 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1446 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 15: -#line 88 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1452 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 16: -#line 89 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1458 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 17: -#line 90 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1464 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 18: -#line 91 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1470 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 19: -#line 92 "wp_parser.y" - { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } -#line 1476 "wp_parser.tab.c" + + { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } + break; case 20: -#line 93 "wp_parser.y" - { (yyval.n) = (yyvsp[0].n); } -#line 1482 "wp_parser.tab.c" + + { (yyval.n) = (yyvsp[0].n); } + break; case 21: -#line 94 "wp_parser.y" - { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } -#line 1488 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } + break; case 22: -#line 95 "wp_parser.y" - { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } -#line 1494 "wp_parser.tab.c" + + { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } + break; case 23: -#line 96 "wp_parser.y" - { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } -#line 1500 "wp_parser.tab.c" + + { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } + break; -#line 1504 "wp_parser.tab.c" default: break; } @@ -1526,13 +1429,14 @@ yyparse (void) /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -1564,7 +1468,7 @@ yyparse (void) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; @@ -1615,10 +1519,12 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1680,7 +1586,6 @@ yyparse (void) yyresult = 0; goto yyreturn; - /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1688,7 +1593,6 @@ yyparse (void) yyresult = 1; goto yyreturn; - #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1699,10 +1603,6 @@ yyparse (void) /* Fall through. */ #endif - -/*-----------------------------------------------------. -| yyreturn -- parsing is finished, return the result. | -`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1719,7 +1619,7 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[+*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1732,5 +1632,5 @@ yyparse (void) #endif return yyresult; } -#line 99 "wp_parser.y" + diff --git a/Source/Parser/wp_parser.tab.h b/Source/Parser/wp_parser.tab.h index aba980f57a7..54fa231f4fc 100644 --- a/Source/Parser/wp_parser.tab.h +++ b/Source/Parser/wp_parser.tab.h @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.5.1. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,9 +30,6 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - #ifndef YY_YY_WP_PARSER_TAB_H_INCLUDED # define YY_YY_WP_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -69,9 +65,10 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + union YYSTYPE { -#line 19 "wp_parser.y" + struct wp_node* n; amrex_real d; @@ -79,9 +76,9 @@ union YYSTYPE enum wp_f1_t f1; enum wp_f2_t f2; -#line 83 "wp_parser.tab.h" }; + typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 From bc3bf28155c3257e7fd6386bd43a9f9fd52b7287 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 22 Oct 2020 21:32:25 -0700 Subject: [PATCH 13/30] CMake: HIP Compute Hint (#1454) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdb675cfda0..21c6e43f9b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ if(NOT WarpX_PRECISION IN_LIST WarpX_PRECISION_VALUES) endif() set(WarpX_COMPUTE_VALUES NOACC OMP CUDA DPCPP HIP) -set(WarpX_COMPUTE OMP CACHE STRING "On-node, accelerated computing backend (NOACC/OMP/CUDA/DPCPP)") +set(WarpX_COMPUTE OMP CACHE STRING "On-node, accelerated computing backend (NOACC/OMP/CUDA/DPCPP/HIP)") set_property(CACHE WarpX_COMPUTE PROPERTY STRINGS ${WarpX_COMPUTE_VALUES}) if(NOT WarpX_COMPUTE IN_LIST WarpX_COMPUTE_VALUES) message(FATAL_ERROR "WarpX_PRECISION (${WarpX_COMPUTE}) must be one of ${WarpX_COMPUTE_VALUES}") From eb160d079e86176a2f42e431f1a6178a32075fed Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Fri, 23 Oct 2020 12:41:46 -0700 Subject: [PATCH 14/30] Fix Warning for SigmaBox FabFactory (#1466) --- Source/BoundaryConditions/PML.H | 53 +++++++++++-------- Source/BoundaryConditions/PML.cpp | 2 +- .../FlushFormats/FlushFormatSensei.cpp | 3 +- Source/Filter/Filter.cpp | 22 +++++--- Source/Particles/WarpXParticleContainer.cpp | 6 +++ Source/Python/WarpXWrappers.cpp | 2 +- 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/Source/BoundaryConditions/PML.H b/Source/BoundaryConditions/PML.H index a1be76d9472..e01d89aff01 100644 --- a/Source/BoundaryConditions/PML.H +++ b/Source/BoundaryConditions/PML.H @@ -49,29 +49,36 @@ struct SigmaBox }; -namespace amrex { - template<> - class FabFactory - { - public: - FabFactory (const BoxArray& grid_ba, const Real* dx, int ncell, int delta) - : m_grids(grid_ba), m_dx(dx), m_ncell(ncell), m_delta(delta) {} - virtual SigmaBox* create (const Box& box, int /*ncomps*/, - const FabInfo& /*info*/, int /*box_index*/) const final - { return new SigmaBox(box, m_grids, m_dx, m_ncell, m_delta); } - virtual void destroy (SigmaBox* fab) const final { - delete fab; - } - virtual FabFactory* clone () const { - return new FabFactory(*this); - } - private: - const BoxArray& m_grids; - const Real* m_dx; - int m_ncell; - int m_delta; - }; -} +class SigmaBoxFactory + : public amrex::FabFactory +{ +public: + SigmaBoxFactory (const amrex::BoxArray& grid_ba, const amrex::Real* dx, int ncell, int delta) + : m_grids(grid_ba), m_dx(dx), m_ncell(ncell), m_delta(delta) {} + virtual ~SigmaBoxFactory () = default; + + SigmaBoxFactory (const SigmaBoxFactory&) = default; + SigmaBoxFactory (SigmaBoxFactory&&) noexcept = default; + + SigmaBoxFactory () = delete; + SigmaBoxFactory& operator= (const SigmaBoxFactory&) = delete; + SigmaBoxFactory& operator= (SigmaBoxFactory&&) = delete; + + virtual SigmaBox* create (const amrex::Box& box, int /*ncomps*/, + const amrex::FabInfo& /*info*/, int /*box_index*/) const final + { return new SigmaBox(box, m_grids, m_dx, m_ncell, m_delta); } + virtual void destroy (SigmaBox* fab) const final { + delete fab; + } + virtual SigmaBoxFactory* clone () const final { + return new SigmaBoxFactory(*this); + } +private: + const amrex::BoxArray& m_grids; + const amrex::Real* m_dx; + int m_ncell; + int m_delta; +}; class MultiSigmaBox : public amrex::FabArray diff --git a/Source/BoundaryConditions/PML.cpp b/Source/BoundaryConditions/PML.cpp index 3824ddcef5e..e27f1ebf379 100644 --- a/Source/BoundaryConditions/PML.cpp +++ b/Source/BoundaryConditions/PML.cpp @@ -389,7 +389,7 @@ SigmaBox::ComputePMLFactorsE (const Real* a_dx, Real dt) MultiSigmaBox::MultiSigmaBox (const BoxArray& ba, const DistributionMapping& dm, const BoxArray& grid_ba, const Real* dx, int ncell, int delta) : FabArray(ba,dm,1,0,MFInfo(), - FabFactory(grid_ba,dx,ncell,delta)) + SigmaBoxFactory(grid_ba,dx,ncell,delta)) {} void diff --git a/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp b/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp index 0bd91c2f06f..ed58f120aaa 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp @@ -16,8 +16,7 @@ FlushFormatSensei::FlushFormatSensei (amrex::AmrMesh *amr_mesh, m_amr_mesh(amr_mesh) { #ifndef BL_USE_SENSEI_INSITU - (void)amr_mesh; - (void)diag_name; + amrex::ignore_unused(m_insitu_pin_mesh, m_insitu_bridge, m_amr_mesh, diag_name); #else amrex::ParmParse pp(diag_name); diff --git a/Source/Filter/Filter.cpp b/Source/Filter/Filter.cpp index e99288ac887..be9887b28ff 100644 --- a/Source/Filter/Filter.cpp +++ b/Source/Filter/Filter.cpp @@ -109,6 +109,7 @@ void Filter::DoFilter (const Box& tbx, #endif amrex::Real const* AMREX_RESTRICT sz = stencil_z.data(); Dim3 slen_local = slen; +#if (AMREX_SPACEDIM == 3) AMREX_PARALLEL_FOR_4D ( tbx, ncomp, i, j, k, n, { Real d = 0.0; @@ -116,12 +117,7 @@ void Filter::DoFilter (const Box& tbx, for (int iz=0; iz < slen_local.z; ++iz){ for (int iy=0; iy < slen_local.y; ++iy){ for (int ix=0; ix < slen_local.x; ++ix){ -#if (AMREX_SPACEDIM == 3) Real sss = sx[ix]*sy[iy]*sz[iz]; -#else - Real sss = sx[ix]*sz[iy]; -#endif -#if (AMREX_SPACEDIM == 3) d += sss*( tmp(i-ix,j-iy,k-iz,scomp+n) +tmp(i+ix,j-iy,k-iz,scomp+n) +tmp(i-ix,j+iy,k-iz,scomp+n) @@ -130,18 +126,32 @@ void Filter::DoFilter (const Box& tbx, +tmp(i+ix,j-iy,k+iz,scomp+n) +tmp(i-ix,j+iy,k+iz,scomp+n) +tmp(i+ix,j+iy,k+iz,scomp+n)); + } + } + } + + dst(i,j,k,dcomp+n) = d; + }); #else + AMREX_PARALLEL_FOR_4D ( tbx, ncomp, i, j, k, n, + { + Real d = 0.0; + + for (int iz=0; iz < slen_local.z; ++iz){ + for (int iy=0; iy < slen_local.y; ++iy){ + for (int ix=0; ix < slen_local.x; ++ix){ + Real sss = sx[ix]*sz[iy]; d += sss*( tmp(i-ix,j-iy,k,scomp+n) +tmp(i+ix,j-iy,k,scomp+n) +tmp(i-ix,j+iy,k,scomp+n) +tmp(i+ix,j+iy,k,scomp+n)); -#endif } } } dst(i,j,k,dcomp+n) = d; }); +#endif } #else diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 2374703fc59..63b1125c2fa 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -272,14 +272,17 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti, tilebox = amrex::coarsen(pti.tilebox(),ref_ratio); } +#ifndef AMREX_USE_GPU // Staggered tile boxes (different in each direction) Box tbx = convert( tilebox, jx->ixType().toIntVect() ); Box tby = convert( tilebox, jy->ixType().toIntVect() ); Box tbz = convert( tilebox, jz->ixType().toIntVect() ); +#endif tilebox.grow(ng_J); #ifdef AMREX_USE_GPU + amrex::ignore_unused(thread_num); // GPU, no tiling: j_arr point to the full j arrays auto & jx_fab = jx->get(pti); auto & jy_fab = jy->get(pti); @@ -474,14 +477,17 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector& wp, tilebox = amrex::coarsen(pti.tilebox(),ref_ratio); } +#ifndef AMREX_USE_GPU // Staggered tile box Box tb = amrex::convert( tilebox, rho->ixType().toIntVect() ); +#endif tilebox.grow(ng_rho); const int nc = WarpX::ncomps; #ifdef AMREX_USE_GPU + amrex::ignore_unused(thread_num); // GPU, no tiling: rho_fab points to the full rho array MultiFab rhoi(*rho, amrex::make_alias, icomp*nc, nc); auto & rho_fab = rhoi.get(pti); diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp index 0944e1c06e1..ac0f60449b9 100644 --- a/Source/Python/WarpXWrappers.cpp +++ b/Source/Python/WarpXWrappers.cpp @@ -125,7 +125,7 @@ extern "C" } #endif - void amrex_finalize (int finalize_mpi) + void amrex_finalize (int /*finalize_mpi*/) { amrex::Finalize(); } From b231efe16c6cc9ee917e83d3ffe0718bc703f5e6 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 23 Oct 2020 21:46:47 +0200 Subject: [PATCH 15/30] provide last AMReX and WarpX working commits on Juwels (#1465) --- Docs/source/building/juwels.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Docs/source/building/juwels.rst b/Docs/source/building/juwels.rst index 7506563fe3f..b0eccb5cba5 100644 --- a/Docs/source/building/juwels.rst +++ b/Docs/source/building/juwels.rst @@ -5,7 +5,11 @@ Juwels (JSC) .. note:: - There's currently a bug when building WarpX on Juwels! In order to compile on Juwels, please contact the WarpX developer team. + There's currently a bug when building WarpX on Juwels! WarpX does not compile on the latest version of the development branches of WarpX and AMReX. + Below are the latest working commits. Please, checkout to those commits before compiling. + If you need more recent features, select the specific commits with `git cherry-pick ` + * WarpX: a548b14e8108ab22294f85516c4e9ea8b1462703 + * AMReX: 21269eff092d0a03aff9269b1200c0e408fde90e The `Juwels supercomputer `_ is located at JSC. From 7dc36a89ac978ac52ae0454c9e4f1509e24a0c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=ADgia=20Diana=20Amorim?= Date: Fri, 23 Oct 2020 20:48:48 +0100 Subject: [PATCH 16/30] Fix Warning message (#1461) --- Source/Parallelization/WarpXRegrid.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Parallelization/WarpXRegrid.cpp b/Source/Parallelization/WarpXRegrid.cpp index 1fdfd6564e6..9f8546fa1a2 100644 --- a/Source/Parallelization/WarpXRegrid.cpp +++ b/Source/Parallelization/WarpXRegrid.cpp @@ -12,6 +12,7 @@ #include #include +#include using namespace amrex; @@ -77,7 +78,7 @@ WarpX::LoadBalance () pmap = newdm.ProcessorMap(); } else { - pmap.resize(nboxes); + pmap.resize(static_cast(nboxes)); } ParallelDescriptor::Bcast(&pmap[0], pmap.size(), ParallelDescriptor::IOProcessorNumber()); From 76e6a9dfea8edb96107fc0099347d895c3b3f925 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Sat, 24 Oct 2020 01:56:19 +0200 Subject: [PATCH 17/30] fix 'comparison of integer expressions of different signedness' warning in parser (#1463) fix 'comparison of integer expressions of different signedness' warning in parser Co-authored-by: Tools --- Source/Parser/wp_parser.lex.cpp | 321 +++++++++--------- Source/Parser/wp_parser.lex.h | 240 +++++++++++--- Source/Parser/wp_parser.tab.cpp | 564 +++++++++++++++++--------------- Source/Parser/wp_parser.tab.h | 11 +- 4 files changed, 653 insertions(+), 483 deletions(-) diff --git a/Source/Parser/wp_parser.lex.cpp b/Source/Parser/wp_parser.lex.cpp index 1991770e6c5..0497ab7d508 100644 --- a/Source/Parser/wp_parser.lex.cpp +++ b/Source/Parser/wp_parser.lex.cpp @@ -6,7 +6,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -81,60 +81,48 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ +/* begin standard C++ headers. */ -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -164,14 +152,14 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t yyleng; +extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) @@ -188,7 +176,6 @@ extern FILE *yyin, *yyout; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -203,7 +190,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -231,7 +218,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -259,7 +246,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -270,7 +257,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -279,10 +265,10 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -291,65 +277,59 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); #define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define yywrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; extern int yylineno; - int yylineno = 1; extern char *yytext; @@ -358,24 +338,20 @@ extern char *yytext; #endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -#if defined(__GNUC__) && __GNUC__ >= 3 -__attribute__((__noreturn__)) -#endif -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - #define YY_NUM_RULES 47 #define YY_END_OF_BUFFER 48 /* This struct is not used in this scanner, @@ -385,7 +361,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[104] = +static const flex_int16_t yy_accept[104] = { 0, 0, 0, 48, 46, 43, 45, 46, 10, 11, 3, 1, 7, 2, 46, 4, 41, 8, 5, 9, 39, @@ -401,7 +377,7 @@ static yyconst flex_int16_t yy_accept[104] = 39, 36, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -433,7 +409,7 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[45] = +static const YY_CHAR yy_meta[45] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, @@ -442,7 +418,7 @@ static yyconst YY_CHAR yy_meta[45] = 3, 3, 3, 1 } ; -static yyconst flex_uint16_t yy_base[106] = +static const flex_int16_t yy_base[106] = { 0, 0, 0, 156, 157, 157, 157, 138, 157, 157, 147, 157, 157, 157, 32, 141, 37, 135, 134, 133, 0, @@ -458,7 +434,7 @@ static yyconst flex_uint16_t yy_base[106] = 32, 0, 157, 53, 115 } ; -static yyconst flex_int16_t yy_def[106] = +static const flex_int16_t yy_def[106] = { 0, 103, 1, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 104, @@ -474,7 +450,7 @@ static yyconst flex_int16_t yy_def[106] = 104, 104, 0, 103, 103 } ; -static yyconst flex_uint16_t yy_nxt[202] = +static const flex_int16_t yy_nxt[202] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 17, 18, 19, 20, 20, @@ -501,7 +477,7 @@ static yyconst flex_uint16_t yy_nxt[202] = 103 } ; -static yyconst flex_int16_t yy_chk[202] = +static const flex_int16_t yy_chk[202] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -544,9 +520,9 @@ int yy_flex_debug = 0; char *yytext; #include "wp_parser_y.h" #include "wp_parser.tab.h" -/* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ -/* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ -/* Used leater to define NUMBER */ + /* Tokens NUMBER, SYMBOL, F1, POW, F2, etc. are defined in wp_parser.y. */ + /* Types WP_SQRT, WP_SQRT, etc. are defined in wp_parser_y.h. */ + /* Used leater to define NUMBER */ #define INITIAL 0 @@ -562,36 +538,36 @@ char *yytext; #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); +int yylex_destroy ( void ); -int yyget_debug (void ); +int yyget_debug ( void ); -void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *yyget_in (void ); +FILE *yyget_in ( void ); -void yyset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str ); -FILE *yyget_out (void ); +FILE *yyget_out ( void ); -void yyset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t yyget_leng (void ); + int yyget_leng ( void ); -char *yyget_text (void ); +char *yyget_text ( void ); -int yyget_lineno (void ); +int yyget_lineno ( void ); -void yyset_lineno (int _line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -599,9 +575,9 @@ void yyset_lineno (int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif @@ -610,19 +586,18 @@ extern int yywrap (void ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif #endif @@ -642,7 +617,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -653,7 +628,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -666,7 +641,7 @@ static int input (void ); else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -755,10 +730,10 @@ YY_DECL if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_load_buffer_state( ); + yy_load_buffer_state( ); } { @@ -789,9 +764,9 @@ YY_DECL { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 157 ); @@ -1058,7 +1033,7 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1125,7 +1100,7 @@ static int yy_get_next_buffer (void) { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1154,7 +1129,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1167,7 +1142,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1181,7 +1156,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1190,11 +1165,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1222,7 +1198,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); + yyrestart( yyin ); } else @@ -1236,12 +1212,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1274,9 +1253,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1302,9 +1281,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 104 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 103); return yy_is_jam ? 0 : yy_current_state; @@ -1338,7 +1317,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1355,14 +1334,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - yyrestart(yyin ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1399,11 +1378,11 @@ static int yy_get_next_buffer (void) if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. @@ -1431,7 +1410,7 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1459,22 +1438,22 @@ static void yy_load_buffer_state (void) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } @@ -1493,9 +1472,9 @@ static void yy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - yyfree((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. @@ -1507,7 +1486,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - yy_flush_buffer(b ); + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1550,7 +1529,7 @@ static void yy_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -1581,7 +1560,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -1600,7 +1579,7 @@ void yypop_buffer_state (void) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1618,15 +1597,15 @@ static void yyensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1655,7 +1634,7 @@ static void yyensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { @@ -1665,23 +1644,23 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } @@ -1694,10 +1673,10 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return yy_scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will @@ -1707,16 +1686,16 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); @@ -1725,7 +1704,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1741,9 +1720,9 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1771,7 +1750,7 @@ static void yy_fatal_error (yyconst char* msg ) */ int yyget_lineno (void) { - + return yylineno; } @@ -1794,7 +1773,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -yy_size_t yyget_leng (void) +int yyget_leng (void) { return yyleng; } @@ -1850,10 +1829,10 @@ static int yy_init_globals (void) * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; @@ -1862,8 +1841,8 @@ static int yy_init_globals (void) yyin = stdin; yyout = stdout; #else - yyin = (FILE *) 0; - yyout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by @@ -1878,7 +1857,7 @@ int yylex_destroy (void) /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1899,7 +1878,7 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { int i; @@ -1909,7 +1888,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { int n; for ( n = 0; s[n]; ++n ) @@ -1921,7 +1900,7 @@ static int yy_flex_strlen (yyconst char * s ) void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } void *yyrealloc (void * ptr, yy_size_t size ) @@ -1934,7 +1913,7 @@ void *yyrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } void yyfree (void * ptr ) diff --git a/Source/Parser/wp_parser.lex.h b/Source/Parser/wp_parser.lex.h index 71f0f7a3c60..8ed383d3735 100644 --- a/Source/Parser/wp_parser.lex.h +++ b/Source/Parser/wp_parser.lex.h @@ -9,7 +9,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -84,29 +84,23 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +/* begin standard C++ headers. */ -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Size of default input buffer. */ @@ -132,7 +126,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t yyleng; +extern int yyleng; extern FILE *yyin, *yyout; @@ -148,7 +142,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -176,7 +170,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -187,21 +181,21 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); /* Begin user sect3 */ @@ -236,31 +230,31 @@ extern char *yytext; /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); +int yylex_destroy ( void ); -int yyget_debug (void ); +int yyget_debug ( void ); -void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *yyget_in (void ); +FILE *yyget_in ( void ); -void yyset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str ); -FILE *yyget_out (void ); +FILE *yyget_out ( void ); -void yyset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t yyget_leng (void ); + int yyget_leng ( void ); -char *yyget_text (void ); +char *yyget_text ( void ); -int yyget_lineno (void ); +int yyget_lineno ( void ); -void yyset_lineno (int _line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -268,18 +262,18 @@ void yyset_lineno (int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT @@ -326,6 +320,150 @@ extern int yylex (void); #undef YY_DECL #endif -#line 330 "wp_parser.lex.h" +#ifndef yy_create_buffer_ALREADY_DEFINED +#undef yy_create_buffer +#endif +#ifndef yy_delete_buffer_ALREADY_DEFINED +#undef yy_delete_buffer +#endif +#ifndef yy_scan_buffer_ALREADY_DEFINED +#undef yy_scan_buffer +#endif +#ifndef yy_scan_string_ALREADY_DEFINED +#undef yy_scan_string +#endif +#ifndef yy_scan_bytes_ALREADY_DEFINED +#undef yy_scan_bytes +#endif +#ifndef yy_init_buffer_ALREADY_DEFINED +#undef yy_init_buffer +#endif +#ifndef yy_flush_buffer_ALREADY_DEFINED +#undef yy_flush_buffer +#endif +#ifndef yy_load_buffer_state_ALREADY_DEFINED +#undef yy_load_buffer_state +#endif +#ifndef yy_switch_to_buffer_ALREADY_DEFINED +#undef yy_switch_to_buffer +#endif +#ifndef yypush_buffer_state_ALREADY_DEFINED +#undef yypush_buffer_state +#endif +#ifndef yypop_buffer_state_ALREADY_DEFINED +#undef yypop_buffer_state +#endif +#ifndef yyensure_buffer_stack_ALREADY_DEFINED +#undef yyensure_buffer_stack +#endif +#ifndef yylex_ALREADY_DEFINED +#undef yylex +#endif +#ifndef yyrestart_ALREADY_DEFINED +#undef yyrestart +#endif +#ifndef yylex_init_ALREADY_DEFINED +#undef yylex_init +#endif +#ifndef yylex_init_extra_ALREADY_DEFINED +#undef yylex_init_extra +#endif +#ifndef yylex_destroy_ALREADY_DEFINED +#undef yylex_destroy +#endif +#ifndef yyget_debug_ALREADY_DEFINED +#undef yyget_debug +#endif +#ifndef yyset_debug_ALREADY_DEFINED +#undef yyset_debug +#endif +#ifndef yyget_extra_ALREADY_DEFINED +#undef yyget_extra +#endif +#ifndef yyset_extra_ALREADY_DEFINED +#undef yyset_extra +#endif +#ifndef yyget_in_ALREADY_DEFINED +#undef yyget_in +#endif +#ifndef yyset_in_ALREADY_DEFINED +#undef yyset_in +#endif +#ifndef yyget_out_ALREADY_DEFINED +#undef yyget_out +#endif +#ifndef yyset_out_ALREADY_DEFINED +#undef yyset_out +#endif +#ifndef yyget_leng_ALREADY_DEFINED +#undef yyget_leng +#endif +#ifndef yyget_text_ALREADY_DEFINED +#undef yyget_text +#endif +#ifndef yyget_lineno_ALREADY_DEFINED +#undef yyget_lineno +#endif +#ifndef yyset_lineno_ALREADY_DEFINED +#undef yyset_lineno +#endif +#ifndef yyget_column_ALREADY_DEFINED +#undef yyget_column +#endif +#ifndef yyset_column_ALREADY_DEFINED +#undef yyset_column +#endif +#ifndef yywrap_ALREADY_DEFINED +#undef yywrap +#endif +#ifndef yyget_lval_ALREADY_DEFINED +#undef yyget_lval +#endif +#ifndef yyset_lval_ALREADY_DEFINED +#undef yyset_lval +#endif +#ifndef yyget_lloc_ALREADY_DEFINED +#undef yyget_lloc +#endif +#ifndef yyset_lloc_ALREADY_DEFINED +#undef yyset_lloc +#endif +#ifndef yyalloc_ALREADY_DEFINED +#undef yyalloc +#endif +#ifndef yyrealloc_ALREADY_DEFINED +#undef yyrealloc +#endif +#ifndef yyfree_ALREADY_DEFINED +#undef yyfree +#endif +#ifndef yytext_ALREADY_DEFINED +#undef yytext +#endif +#ifndef yyleng_ALREADY_DEFINED +#undef yyleng +#endif +#ifndef yyin_ALREADY_DEFINED +#undef yyin +#endif +#ifndef yyout_ALREADY_DEFINED +#undef yyout +#endif +#ifndef yy_flex_debug_ALREADY_DEFINED +#undef yy_flex_debug +#endif +#ifndef yylineno_ALREADY_DEFINED +#undef yylineno +#endif +#ifndef yytables_fload_ALREADY_DEFINED +#undef yytables_fload +#endif +#ifndef yytables_destroy_ALREADY_DEFINED +#undef yytables_destroy +#endif +#ifndef yyTABLES_NAME_ALREADY_DEFINED +#undef yyTABLES_NAME +#endif + #undef yyIN_HEADER #endif /* yyHEADER_H */ diff --git a/Source/Parser/wp_parser.tab.cpp b/Source/Parser/wp_parser.tab.cpp index 581cf7fdf96..6b276e89fb4 100644 --- a/Source/Parser/wp_parser.tab.cpp +++ b/Source/Parser/wp_parser.tab.cpp @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.5.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,8 +65,7 @@ -/* Copy the first part of user declarations. */ - +/* First part of user prologue. */ #include #include @@ -71,12 +74,24 @@ int yylex (void); - +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -88,8 +103,8 @@ # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "wp_parser.tab.h". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_YY_WP_PARSER_TAB_H_INCLUDED # define YY_YY_WP_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -125,11 +140,9 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { - struct wp_node* n; amrex_real d; struct wp_symbol* s; @@ -138,7 +151,6 @@ union YYSTYPE }; - typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -151,36 +163,81 @@ int yyparse (void); #endif /* !YY_YY_WP_PARSER_TAB_H_INCLUDED */ -/* Copy the second part of user declarations. */ - #ifdef short # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; +#else +typedef short yytype_int16; +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; #else -typedef short int yytype_int16; +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -188,15 +245,27 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + +/* Stored state numbers (used for stacks). */ +typedef yytype_int8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -210,30 +279,19 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif @@ -244,13 +302,13 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -263,6 +321,20 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) #if ! defined yyoverflow || YYERROR_VERBOSE @@ -339,17 +411,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -362,11 +434,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -378,12 +450,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -406,17 +478,18 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 50 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 272 + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -450,7 +523,7 @@ static const yytype_uint8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = +static const yytype_int8 yyrline[] = { 0, 67, 67, 68, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, @@ -473,7 +546,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 94, 265, 266, 267, 268, 269, 270, 61, 60, 62, @@ -481,14 +554,14 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -24 +#define YYPACT_NINF (-24) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-24))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF (-1) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -505,7 +578,7 @@ static const yytype_int16 yypact[] = /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_uint8 yydefact[] = +static const yytype_int8 yydefact[] = { 2, 0, 1, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 20, 19, 0, 3, 0, 0, 0, @@ -529,7 +602,7 @@ static const yytype_int8 yydefgoto[] = /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint8 yytable[] = +static const yytype_int8 yytable[] = { 13, 14, 15, 11, 30, 31, 12, 17, 0, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, @@ -577,7 +650,7 @@ static const yytype_int8 yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 30, 0, 4, 5, 6, 7, 20, 21, 26, 31, 26, 26, 31, 31, 31, 8, 9, 11, 12, @@ -587,7 +660,7 @@ static const yytype_uint8 yystos[] = }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { 0, 29, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, @@ -595,7 +668,7 @@ static const yytype_uint8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 0, 3, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, @@ -615,22 +688,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -670,37 +743,39 @@ do { \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -709,7 +784,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -732,20 +807,20 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + yystos[+yyssp[yyi + 1 - yynrhs]], + &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } @@ -789,13 +864,13 @@ int yydebug; # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen +# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) # else /* Return the length of YYSTR. */ -static YYSIZE_T +static YYPTRDIFF_T yystrlen (const char *yystr) { - YYSIZE_T yylen; + YYPTRDIFF_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; @@ -831,12 +906,12 @@ yystpcpy (char *yydest, const char *yysrc) backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYSIZE_T +static YYPTRDIFF_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - YYSIZE_T yyn = 0; + YYPTRDIFF_T yyn = 0; char const *yyp = yystr; for (;;) @@ -849,7 +924,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -864,10 +942,10 @@ yytnamerr (char *yyres, const char *yystr) do_not_strip_quotes: ; } - if (! yyres) + if (yyres) + return yystpcpy (yyres, yystr) - yyres; + else return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; } # endif @@ -880,19 +958,19 @@ yytnamerr (char *yyres, const char *yystr) *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, + yy_state_t *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ + /* Arguments of yyformat: reported tokens (one for the "unexpected", + one per "expected"). */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ + /* Actual size of YYARG. */ int yycount = 0; + /* Cumulated lengths of YYARG. */ + YYPTRDIFF_T yysize = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then @@ -919,7 +997,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, */ if (yytoken != YYEMPTY) { - int yyn = yypact[*yyssp]; + int yyn = yypact[+*yyssp]; + YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + yysize = yysize0; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { @@ -944,11 +1024,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + YYPTRDIFF_T yysize1 + = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -960,6 +1041,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -970,10 +1052,13 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + /* Don't count the "%s"s in the final size, but reserve room for + the terminator. */ + YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -999,8 +1084,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } else { - yyp++; - yyformat++; + ++yyp; + ++yyformat; } } return 0; @@ -1043,7 +1128,7 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1055,16 +1140,16 @@ yyparse (void) to reallocate them elsewhere. */ /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss; + yy_state_t *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; - YYSIZE_T yystacksize; + YYPTRDIFF_T yystacksize; int yyn; int yyresult; @@ -1078,7 +1163,7 @@ yyparse (void) /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1099,46 +1184,54 @@ yyparse (void) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1147,42 +1240,43 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1232,15 +1326,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1255,7 +1347,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1275,132 +1367,90 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: - - { + case 3: + { wp_defexpr((yyvsp[-1].n)); } - break; case 4: - - { (yyval.n) = wp_newnumber((yyvsp[0].d)); } - + { (yyval.n) = wp_newnumber((yyvsp[0].d)); } break; case 5: - - { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } - + { (yyval.n) = wp_newsymbol((yyvsp[0].s)); } break; case 6: - - { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newnode(WP_ADD, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 7: - - { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newnode(WP_SUB, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 8: - - { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newnode(WP_MUL, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 9: - - { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newnode(WP_DIV, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 10: - - { (yyval.n) = (yyvsp[-1].n); } - + { (yyval.n) = (yyvsp[-1].n); } break; case 11: - - { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_LT, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 12: - - { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_GT, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 13: - - { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_LEQ, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 14: - - { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_GEQ, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 15: - - { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_EQ, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 16: - - { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_NEQ, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 17: - - { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_AND, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 18: - - { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_OR, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 19: - - { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } - + { (yyval.n) = wp_newnode(WP_NEG, (yyvsp[0].n), NULL); } break; case 20: - - { (yyval.n) = (yyvsp[0].n); } - + { (yyval.n) = (yyvsp[0].n); } break; case 21: - - { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } - + { (yyval.n) = wp_newf2(WP_POW, (yyvsp[-2].n), (yyvsp[0].n)); } break; case 22: - - { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } - + { (yyval.n) = wp_newf1((yyvsp[-3].f1), (yyvsp[-1].n)); } break; case 23: - - { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } - + { (yyval.n) = wp_newf2((yyvsp[-5].f2), (yyvsp[-3].n), (yyvsp[-1].n)); } break; @@ -1429,14 +1479,13 @@ yyparse (void) /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -1468,7 +1517,7 @@ yyparse (void) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); if (!yymsg) { yymsg = yymsgbuf; @@ -1519,12 +1568,10 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1586,6 +1633,7 @@ yyparse (void) yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1593,6 +1641,7 @@ yyparse (void) yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1603,6 +1652,10 @@ yyparse (void) /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1619,7 +1672,7 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[+*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1633,4 +1686,3 @@ yyparse (void) return yyresult; } - diff --git a/Source/Parser/wp_parser.tab.h b/Source/Parser/wp_parser.tab.h index 54fa231f4fc..89f1f341b0f 100644 --- a/Source/Parser/wp_parser.tab.h +++ b/Source/Parser/wp_parser.tab.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +31,9 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + #ifndef YY_YY_WP_PARSER_TAB_H_INCLUDED # define YY_YY_WP_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -65,11 +69,9 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { - struct wp_node* n; amrex_real d; struct wp_symbol* s; @@ -78,7 +80,6 @@ union YYSTYPE }; - typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 From 9ab0e8eb6d014424c97f1bacfed7b04f608ee691 Mon Sep 17 00:00:00 2001 From: NeilZaim <49716072+NeilZaim@users.noreply.github.com> Date: Sat, 24 Oct 2020 10:13:46 +0200 Subject: [PATCH 18/30] Update a couple of asserts if warpx.numprocs is used (#1440) * Update a couple of asserts if warpx.numprocs is used * Set blocking factor to 1 when warpx.numprocs is used * Apply suggestions from code review Co-authored-by: Axel Huebl --- Docs/source/running_cpp/parameters.rst | 5 ++++- Source/Diagnostics/FullDiagnostics.cpp | 27 ++++++++++++++++++------ Source/Initialization/WarpXAMReXInit.cpp | 12 +++++++++++ Source/WarpX.H | 9 ++++++++ 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index 47233f06ad9..a197367a1a5 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -1462,7 +1462,10 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a * ``.coarsening_ratio`` (list of `int`) optional (default `1 1 1`) Reduce size of the field output by this ratio in each dimension. (This is done by averaging the field over 1 or 2 points along each direction, depending on the staggering). - ``plot_coarsening_ratio`` should be an integer divisor of ``blocking_factor``, defined in the :ref:`parallelization ` section. + If ``blocking_factor`` and ``max_grid_size`` are used for the domain decomposition, as detailed in + the :ref:`parallelization ` section, ``coarsening_ratio`` should be an integer + divisor of ``blocking_factor``. If ``warpx.numprocs`` is used instead, the total number of cells in a given + dimension must be a multiple of the ``coarsening_ratio`` multiplied by ``numprocs`` in that dimension. * ``.file_prefix`` (`string`) optional (default `diags/plotfiles/plt`) Root for output file names. Supports sub-directories. diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index d302755df2e..640474419a4 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -249,10 +249,19 @@ FullDiagnostics::InitializeFieldBufferData (int i_buffer, int lev ) { amrex::BoxArray ba = warpx.boxArray(lev); amrex::DistributionMapping dmap = warpx.DistributionMap(lev); // Check if warpx BoxArray is coarsenable. - AMREX_ALWAYS_ASSERT_WITH_MESSAGE ( - ba.coarsenable(m_crse_ratio), - "Invalid coarsening ratio for warpx boxArray. Must be an integer divisor of the blocking factor." - ); + if (warpx.get_numprocs() == 0) + { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE ( + ba.coarsenable(m_crse_ratio), "Invalid coarsening ratio for field diagnostics." + "Must be an integer divisor of the blocking factor."); + } + else + { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE ( + ba.coarsenable(m_crse_ratio), "Invalid coarsening ratio for field diagnostics." + "The total number of cells must be a multiple of the coarsening ratio multiplied by numprocs."); + } + // Find if user-defined physical dimensions are different from the simulation domain. for (int idim=0; idim < AMREX_SPACEDIM; ++idim) { // To ensure that the diagnostic lo and hi are within the domain defined at level, lev. @@ -266,9 +275,13 @@ FullDiagnostics::InitializeFieldBufferData (int i_buffer, int lev ) { use_warpxba = false; // User-defined value for coarsening should be an integer divisor of - // blocking factor at level, lev. - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( blockingFactor[idim] % m_crse_ratio[idim]==0, - " coarsening ratio must be integer divisor of blocking factor"); + // blocking factor at level, lev. This assert is not relevant and thus + // removed if warpx.numprocs is used for the domain decomposition. + if (warpx.get_numprocs() == 0) + { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( blockingFactor[idim] % m_crse_ratio[idim]==0, + " coarsening ratio must be integer divisor of blocking factor"); + } } if (use_warpxba == false) { diff --git a/Source/Initialization/WarpXAMReXInit.cpp b/Source/Initialization/WarpXAMReXInit.cpp index bbb646f2660..0bfdb378ec9 100644 --- a/Source/Initialization/WarpXAMReXInit.cpp +++ b/Source/Initialization/WarpXAMReXInit.cpp @@ -24,6 +24,18 @@ namespace { bool abort_on_out_of_gpu_memory = true; // AMReX' default: false pp.query("abort_on_out_of_gpu_memory", abort_on_out_of_gpu_memory); pp.add("abort_on_out_of_gpu_memory", abort_on_out_of_gpu_memory); + + // Work-around: + // If warpx.numprocs is used for the domain decomposition, we will not use blocking factor + // to generate grids. Nonetheless, AMReX has asserts in place that validate that the + // number of cells is a multiple of blocking factor. We set the blocking factor to 1 so those + // AMReX asserts will always pass. + amrex::ParmParse pp_warpx("warpx"); + if (pp_warpx.contains("numprocs")) + { + amrex::ParmParse pp_amr("amr"); + pp_amr.add("blocking_factor", 1); + } } } diff --git a/Source/WarpX.H b/Source/WarpX.H index c7f44ff4eeb..9553121e79e 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -491,6 +491,15 @@ public: const amrex::IntVect get_ng_depos_J() const {return guard_cells.ng_depos_J;} const amrex::IntVect get_ng_depos_rho() const {return guard_cells.ng_depos_rho;} + /** Coarsest-level Domain Decomposition + * + * If specified, the domain will be chopped into the exact number + * of pieces in each dimension as specified by this parameter. + * + * @return the number of MPI processes per dimension if specified, otherwise a 0-vector + */ + const amrex::IntVect get_numprocs() const {return numprocs;} + void ComputeSpaceChargeField (bool const reset_fields); void AddSpaceChargeField (WarpXParticleContainer& pc); void computePhi (const amrex::Vector >& rho, From 35f494b0648e1f92af1e41ffbb6cf7a63f8554a8 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 26 Oct 2020 09:35:04 -0700 Subject: [PATCH 19/30] Ascent: Fix Contour Plots (#1469) Fix the missing ngrow of one cells for Ascent, which guarantees that the `FillBoundary` calls after centering field data provide an extra cell for contouring. Also fix a few doc typos and unused variable warnings. --- Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp | 6 +++--- Source/Diagnostics/FullDiagnostics.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp b/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp index e14199b02b2..03cc282e158 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp @@ -16,7 +16,6 @@ FlushFormatAscent::WriteToFile ( bool plot_raw_fields_guards, bool /*plot_raw_rho*/, bool plot_raw_F) const { #ifdef AMREX_USE_ASCENT - auto & warpx = WarpX::GetInstance(); // wrap mesh data @@ -43,9 +42,10 @@ FlushFormatAscent::WriteToFile ( #else amrex::ignore_unused(varnames, mf, geom, iteration, time, - particle_diags, nlev, prefix, plot_raw_fields, - plot_raw_fields_guards, plot_raw_F); + particle_diags, nlev); #endif // AMREX_USE_ASCENT + amrex::ignore_unused(prefix, plot_raw_fields, plot_raw_fields_guards, + plot_raw_F); } #ifdef AMREX_USE_ASCENT diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index 640474419a4..8e856503216 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -75,7 +75,7 @@ FullDiagnostics::ReadParameters () "to file for a restart"); } // Number of buffers = 1 for FullDiagnostics. - // It is used to allocate the number of output multu-level MultiFab, m_mf_output + // It is used to allocate the number of output multi-level MultiFab, m_mf_output m_num_buffers = 1; } @@ -336,7 +336,7 @@ FullDiagnostics::InitializeFieldBufferData (int i_buffer, int lev ) { // is different from the lo and hi physical co-ordinates of the simulation domain. if (use_warpxba == false) dmap = amrex::DistributionMapping{ba}; // Allocate output MultiFab for diagnostics. The data will be stored at cell-centers. - int ngrow = (m_format == "sensei") ? 1 : 0; + int ngrow = (m_format == "sensei" || m_format == "ascent") ? 1 : 0; // The zero is hard-coded since the number of output buffers = 1 for FullDiagnostics m_mf_output[i_buffer][lev] = amrex::MultiFab(ba, dmap, m_varnames.size(), ngrow); From 9da57f5e82a7949e67ce349f45d307e5e845464c Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 26 Oct 2020 17:43:21 +0100 Subject: [PATCH 20/30] Fix warning related to external laser binary file (#1470) * fix read of binary file * removed useless include --- .../LaserProfileFromTXYEFile.cpp | 72 +++++++++---------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/Source/Laser/LaserProfilesImpl/LaserProfileFromTXYEFile.cpp b/Source/Laser/LaserProfilesImpl/LaserProfileFromTXYEFile.cpp index 5c4092aa6a0..65f02c9c09a 100644 --- a/Source/Laser/LaserProfilesImpl/LaserProfileFromTXYEFile.cpp +++ b/Source/Laser/LaserProfilesImpl/LaserProfileFromTXYEFile.cpp @@ -19,7 +19,6 @@ #include #include - using namespace amrex; void @@ -123,17 +122,15 @@ WarpXLaserProfiles::FromTXYEFileLaserProfile::parse_txye_file(std::string txye_f //Uniform grid flag char flag; inp.read(&flag, 1); - if(!inp) Abort("Failed to read sizes from txye file"); + if(!inp) Abort("Failed to read grid type from txye file"); m_params.is_grid_uniform=flag; //Grid points along t, x and y - auto const three_uint32_size = sizeof(uint32_t)*3; - char buf[three_uint32_size]; - inp.read(buf, three_uint32_size); + inp.read(reinterpret_cast(&m_params.nt), sizeof(uint32_t)); + inp.read(reinterpret_cast(&m_params.nx), sizeof(uint32_t)); + inp.read(reinterpret_cast(&m_params.ny), sizeof(uint32_t)); if(!inp) Abort("Failed to read sizes from txye file"); - m_params.nt = reinterpret_cast(buf)[0]; - m_params.nx = reinterpret_cast(buf)[1]; - m_params.ny = reinterpret_cast(buf)[2]; + if(m_params.nt <= 1) Abort("nt in txye file must be >=2"); if(m_params.nx <= 1) Abort("nx in txye file must be >=2"); #if (AMREX_SPACEDIM == 3) @@ -143,48 +140,45 @@ WarpXLaserProfiles::FromTXYEFileLaserProfile::parse_txye_file(std::string txye_f #endif //Coordinates - Vector buf_t, buf_x, buf_y; + Vector dbuf_t, dbuf_x, dbuf_y; if(m_params.is_grid_uniform){ - buf_t.resize(2); - buf_x.resize(2); + dbuf_t.resize(2); + dbuf_x.resize(2); #if (AMREX_SPACEDIM == 3) - buf_y.resize(2); + dbuf_y.resize(2); #elif(AMREX_SPACEDIM == 2) - buf_y.resize(1); + dbuf_y.resize(1); #endif } else{ - buf_t.resize(m_params.nt); - buf_x.resize(m_params.nx); - buf_y.resize(m_params.ny); + dbuf_t.resize(m_params.nt); + dbuf_x.resize(m_params.nx); + dbuf_y.resize(m_params.ny); } - inp.read(reinterpret_cast(buf_t.dataPtr()), - buf_t.size()*sizeof(double)); - if(!inp) - Abort("Failed to read coords from txye file"); - if (!std::is_sorted(buf_t.begin(), buf_t.end())) - Abort("Coordinates are not sorted in txye file"); - inp.read(reinterpret_cast(buf_x.dataPtr()), - buf_x.size()*sizeof(double)); - if(!inp) - Abort("Failed to read coords from txye file"); - if (!std::is_sorted(buf_x.begin(), buf_x.end())) + + inp.read(reinterpret_cast(dbuf_t.dataPtr()), + dbuf_t.size()*sizeof(double)); + inp.read(reinterpret_cast(dbuf_x.dataPtr()), + dbuf_x.size()*sizeof(double)); + inp.read(reinterpret_cast(dbuf_y.dataPtr()), + dbuf_y.size()*sizeof(double)); + if(!inp) Abort("Failed to read coords from txye file"); + + m_params.t_coords.resize(dbuf_t.size()); + m_params.h_x_coords.resize(dbuf_x.size()); + m_params.h_y_coords.resize(dbuf_y.size()); + + if (!std::is_sorted(dbuf_t.begin(), dbuf_t.end()) || + !std::is_sorted(dbuf_x.begin(), dbuf_x.end()) || + !std::is_sorted(dbuf_y.begin(), dbuf_y.end())) Abort("Coordinates are not sorted in txye file"); - inp.read(reinterpret_cast(buf_y.dataPtr()), - buf_y.size()*sizeof(double)); - if(!inp) - Abort("Failed to read coords from txye file"); - if (!std::is_sorted(buf_y.begin(), buf_y.end())) - Abort("Coordinates are not sorted in txye file"); - m_params.t_coords.resize(buf_t.size()); - m_params.h_x_coords.resize(buf_x.size()); - m_params.h_y_coords.resize(buf_y.size()); + // Convert from double to amrex::Real - std::transform(buf_t.begin(), buf_t.end(), m_params.t_coords.begin(), + std::transform(dbuf_t.begin(), dbuf_t.end(), m_params.t_coords.begin(), [](auto x) {return static_cast(x);} ); - std::transform(buf_x.begin(), buf_x.end(), m_params.h_x_coords.begin(), + std::transform(dbuf_x.begin(), dbuf_x.end(), m_params.h_x_coords.begin(), [](auto x) {return static_cast(x);} ); - std::transform(buf_y.begin(), buf_y.end(), m_params.h_y_coords.begin(), + std::transform(dbuf_y.begin(), dbuf_y.end(), m_params.h_y_coords.begin(), [](auto x) {return static_cast(x);} ); } From 45367593e84db10b762cc702c91a958816fe4577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=ADgia=20Diana=20Amorim?= Date: Mon, 26 Oct 2020 16:44:57 +0000 Subject: [PATCH 21/30] Docs: Build on Summit (OLCF) with CMake (#1462) * Changed compiling commands to cmake & added link * Applied reviewer suggestions --- Docs/source/building/summit.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Docs/source/building/summit.rst b/Docs/source/building/summit.rst index bd3b9779a03..64d5baebfca 100644 --- a/Docs/source/building/summit.rst +++ b/Docs/source/building/summit.rst @@ -134,9 +134,12 @@ Then, ``cd`` into the directory ``$HOME/src/warpx`` and use the following comman .. code-block:: bash - make -j 16 COMP=gcc USE_GPU=TRUE USE_OPENPMD=TRUE + mkdir -p build + cd build + cmake .. -DWarpX_OPENPMD=ON -DWarpX_DIMS=3 -DWarpX_COMPUTE=CUDA -DCMAKE_CUDA_ARCHITECTURES=70 -DCUDA_ARCH=7.0 + make -j 10 -The other :ref:`general compile-time options ` apply as usual. +The general :ref:`cmake compile-time options ` apply as usual. Running From 3678d01e72b77949ed2326012855a638b5ad2cc2 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 26 Oct 2020 11:21:22 -0700 Subject: [PATCH 22/30] CMake 3.18+: CUDA Arch Policy (OLD) (#1459) --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c6e43f9b9..2f610b17188 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,15 @@ if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() +# CMake policies ############################################################## +# +# CMake 3.18+: CMAKE_CUDA_ARCHITECTURES +# https://cmake.org/cmake/help/latest/policy/CMP0104.html +if(POLICY CMP0104) + cmake_policy(SET CMP0104 OLD) +endif() + + # CCache Support ############################################################## # # this is an optional tool that stores compiled object files; allows fast From 4535d1544baeee07810157ae6bdb4b5615c1760a Mon Sep 17 00:00:00 2001 From: NeilZaim <49716072+NeilZaim@users.noreply.github.com> Date: Mon, 26 Oct 2020 20:28:10 +0100 Subject: [PATCH 23/30] Initialize last element of PML sigma_star arrays (#1460) --- Source/BoundaryConditions/PML.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/BoundaryConditions/PML.cpp b/Source/BoundaryConditions/PML.cpp index e27f1ebf379..04545c1bea6 100644 --- a/Source/BoundaryConditions/PML.cpp +++ b/Source/BoundaryConditions/PML.cpp @@ -49,7 +49,7 @@ namespace p_sigma[i-slo] = fac*(offset*offset); // sigma_cumsum is the analytical integral of sigma function at same points than sigma p_sigma_cumsum[i-slo] = (fac*(offset*offset*offset)/3.)/PhysConst::c; - if (i <= ohi) { + if (i <= ohi+1) { offset = static_cast(glo-i) - 0.5; p_sigma_star[i-sslo] = fac*(offset*offset); // sigma_star_cumsum is the analytical integral of sigma function at same points than sigma_star @@ -79,7 +79,7 @@ namespace Real offset = static_cast(i-ghi-1); p_sigma[i-slo] = fac*(offset*offset); p_sigma_cumsum[i-slo] = (fac*(offset*offset*offset)/3.)/PhysConst::c; - if (i <= ohi) { + if (i <= ohi+1) { offset = static_cast(i-ghi) - 0.5; p_sigma_star[i-sslo] = fac*(offset*offset); p_sigma_star_cumsum[i-sslo] = (fac*(offset*offset*offset)/3.)/PhysConst::c; @@ -106,7 +106,7 @@ namespace i += olo; p_sigma[i-slo] = Real(0.0); p_sigma_cumsum[i-slo] = Real(0.0); - if (i <= ohi) { + if (i <= ohi+1) { p_sigma_star[i-sslo] = Real(0.0); p_sigma_star_cumsum[i-sslo] = Real(0.0); } From 19c97706b6e71e70a46791f589b8518550d142b5 Mon Sep 17 00:00:00 2001 From: Igor Andriyash Date: Mon, 26 Oct 2020 20:30:15 +0100 Subject: [PATCH 24/30] Explicit choice of `max_iters` for MLMG solver (#1471) * added an option to set explicitely `max_iters` for MLMG solver * fix EOL white spaces * fix EOL white spaces 2 --- Docs/source/running_cpp/parameters.rst | 5 +++++ Source/FieldSolver/ElectrostaticSolver.cpp | 6 ++++-- Source/Particles/PhysicalParticleContainer.cpp | 1 + Source/Particles/WarpXParticleContainer.H | 1 + Source/WarpX.H | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index a197367a1a5..f5f0969be10 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -376,6 +376,11 @@ Particle initialization precision within a reasonable time ; in that case, users can set a relaxed precision requirement through ``self_fields_required_precision``. +* ``.self_fields_max_iters`` (`integer`, default: 200) + Maximum number of iterations used for MLMG solver for initial space-charge + fields calculation. In case if MLMG converges but fails to reach the desired + ``self_fields_required_precision``, this parameter may be increased. + * ``.profile`` (`string`) Density profile for this species. The options are: diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 73d7048b73b..91b20e92253 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -71,7 +71,7 @@ WarpX::AddSpaceChargeField (WarpXParticleContainer& pc) for (Real& beta_comp : beta) beta_comp /= PhysConst::c; // Normalize // Compute the potential phi, by solving the Poisson equation - computePhi( rho, phi, beta, pc.self_fields_required_precision ); + computePhi( rho, phi, beta, pc.self_fields_required_precision, pc.self_fields_max_iters ); // Compute the corresponding electric and magnetic field, from the potential phi computeE( Efield_fp, phi, beta ); @@ -96,7 +96,8 @@ void WarpX::computePhi (const amrex::Vector >& rho, amrex::Vector >& phi, std::array const beta, - Real const required_precision) const + Real const required_precision, + int const max_iters) const { // Define the boundary conditions Array lobc, hibc; @@ -127,6 +128,7 @@ WarpX::computePhi (const amrex::Vector >& rho, // Solve the Poisson equation MLMG mlmg(linop); mlmg.setVerbose(2); + mlmg.setMaxIter(max_iters); mlmg.solve( GetVecOfPtrs(phi), GetVecOfConstPtrs(rho), required_precision, 0.0); // Normalize by the correct physical constant diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 7af6c4dd3aa..7bddac6ea0d 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -116,6 +116,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_continuous_injection", do_continuous_injection); pp.query("initialize_self_fields", initialize_self_fields); pp.query("self_fields_required_precision", self_fields_required_precision); + pp.query("self_fields_max_iters", self_fields_max_iters); // Whether to plot back-transformed (lab-frame) diagnostics // for this species. pp.query("do_back_transformed_diagnostics", do_back_transformed_diagnostics); diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 12dbd128991..2f22c78f1cc 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -274,6 +274,7 @@ public: bool do_splitting = false; bool initialize_self_fields = false; amrex::Real self_fields_required_precision = 1.e-11; + int self_fields_max_iters = 200; // split along diagonals (0) or axes (1) int split_type = 0; diff --git a/Source/WarpX.H b/Source/WarpX.H index 9553121e79e..68dd45949bd 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -505,7 +505,8 @@ public: void computePhi (const amrex::Vector >& rho, amrex::Vector >& phi, std::array const beta = {{0,0,0}}, - amrex::Real const required_precision=1.e-11 ) const; + amrex::Real const required_precision=1.e-11, + const int max_iters=200) const; void computeE (amrex::Vector, 3> >& E, const amrex::Vector >& phi, std::array const beta = {{0,0,0}} ) const; From 8ca2524beb867f46a63ccc82529d2fac763fba34 Mon Sep 17 00:00:00 2001 From: NeilZaim <49716072+NeilZaim@users.noreply.github.com> Date: Mon, 26 Oct 2020 20:34:28 +0100 Subject: [PATCH 25/30] PSATD: only deposit charge if needed (#1428) * PSATD: only deposit charge if needed * Update Source/FieldSolver/WarpXPushFieldsEM.cpp Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> --- Docs/source/running_cpp/parameters.rst | 7 ++++++- Source/FieldSolver/WarpXPushFieldsEM.cpp | 7 +++++-- Source/WarpX.cpp | 19 ++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index f5f0969be10..2ac0a9ffc71 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -1214,7 +1214,7 @@ Numerics and algorithms This option guarantees charge conservation only when used in combination with ``psatd.periodic_single_box_fft=1``, namely for periodic single-box simulations with global FFTs without guard cells. The implementation for domain decomposition with local FFTs over guard cells is planned but not yet completed. -* ``psatd.update_with_rho`` (`0` or `1`; default: `0`) +* ``psatd.update_with_rho`` (`0` or `1`) If true, the update equation for the electric field is expressed in terms of both the current density and the charge density, namely :math:`\widehat{\boldsymbol{J}}^{\,n+1/2}`, :math:`\widehat\rho^{n}`, and :math:`\widehat\rho^{n+1}`. If false, instead, the update equation for the electric field is expressed in terms of the current density :math:`\widehat{\boldsymbol{J}}^{\,n+1/2}` only. If charge is expected to be conserved (by setting, for example, ``psatd.current_correction=1``), then the two formulations are expected to be equivalent. @@ -1281,6 +1281,11 @@ Numerics and algorithms The coefficients :math:`C`, :math:`S`, :math:`\theta`, :math:`\nu`, :math:`\chi_1`, :math:`\chi_2`, and :math:`\chi_3` are defined in (`Lehe et al, PRE 94, 2016 `_). + The default value for ``psatd.update_with_rho`` is ``1`` if ``psatd.v_galilean`` is non-zero or + in RZ geometry and ``0`` otherwise. + + Note that ``psatd.update_with_rho=0`` is not supported in RZ geometry. + * ``pstad.v_galilean`` (`3 floats`, in units of the speed of light; default `0. 0. 0.`) Defines the galilean velocity. Non-zero `v_galilean` activates Galilean algorithm, which suppresses the Numerical Cherenkov instability diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index a03026f10a6..c1716139636 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -72,8 +72,11 @@ namespace { solver.ForwardTransform(*current[1], Idx::Jy); #endif solver.ForwardTransform(*current[2], Idx::Jz); - solver.ForwardTransform(*rho, Idx::rho_old, 0); - solver.ForwardTransform(*rho, Idx::rho_new, 1); + + if (rho) { + solver.ForwardTransform(*rho, Idx::rho_old, 0); + solver.ForwardTransform(*rho, Idx::rho_new, 1); + } #ifdef WARPX_DIM_RZ if (WarpX::use_kspace_filter) { solver.ApplyFilter(Idx::rho_old); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 740eaacba96..0f7e2b4db28 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -674,17 +674,24 @@ WarpX::ReadParameters () // Scale the velocity by the speed of light for (int i=0; i<3; i++) m_v_galilean[i] *= PhysConst::c; +# ifdef WARPX_DIM_RZ + update_with_rho = true; // Must be true for RZ PSATD +# else if (m_v_galilean[0] == 0. && m_v_galilean[1] == 0. && m_v_galilean[2] == 0.) { update_with_rho = false; // standard PSATD } else { update_with_rho = true; // Galilean PSATD } +# endif // Overwrite update_with_rho with value set in input file pp.query("update_with_rho", update_with_rho); # ifdef WARPX_DIM_RZ + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(update_with_rho, + "psatd.update_with_rho must be equal to 1 in RZ geometry"); + if (!Geom(0).isPeriodic(1)) { use_damp_fields_in_z_guard = true; } @@ -973,7 +980,13 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm Efield_avg_fp[lev][1] = std::make_unique(amrex::convert(ba,Ey_nodal_flag),dm,ncomps,ngE); Efield_avg_fp[lev][2] = std::make_unique(amrex::convert(ba,Ez_nodal_flag),dm,ncomps,ngE); - if (do_dive_cleaning || (plot_rho && do_back_transformed_diagnostics)) +#ifdef WARPX_USE_PSATD + const bool deposit_charge = do_dive_cleaning || (plot_rho && do_back_transformed_diagnostics) + || update_with_rho || current_correction; +#else + const bool deposit_charge = do_dive_cleaning || (plot_rho && do_back_transformed_diagnostics); +#endif + if (deposit_charge) { rho_fp[lev] = std::make_unique(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho); } @@ -990,10 +1003,6 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm F_fp[lev] = std::make_unique(amrex::convert(ba,IntVect::TheUnitVector()),dm,ncomps, ngF.max()); } #ifdef WARPX_USE_PSATD - else - { - rho_fp[lev] = std::make_unique(amrex::convert(ba,rho_nodal_flag),dm,2*ncomps,ngRho); - } // Allocate and initialize the spectral solver # if (AMREX_SPACEDIM == 3) RealVect dx_vect(dx[0], dx[1], dx[2]); From 434116fe2841341da15c39a0c4fc01143ae523aa Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 26 Oct 2020 20:47:11 +0100 Subject: [PATCH 26/30] Improve 2D laser injection test (#1422) * improved 2D laser injection test * correct typo in documentation * fix non-ascii character * fixed unused variables * fixed missing checksum * fix non-ascii character * updated benchmark * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * fixed check in analysis script * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * reorganized main function * added a comment * Update Examples/Modules/laser_injection/analysis_2d.py Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> * fix calculation of dz * fixed bug Co-authored-by: NeilZaim <49716072+NeilZaim@users.noreply.github.com> --- .../Modules/laser_injection/analysis_2d.py | 200 ++++++++++++++++++ Examples/Modules/laser_injection/inputs_2d_rt | 30 +-- .../benchmarks_json/LaserInjection_2d.json | 20 +- Regression/WarpX-tests.ini | 2 +- 4 files changed, 227 insertions(+), 25 deletions(-) create mode 100755 Examples/Modules/laser_injection/analysis_2d.py diff --git a/Examples/Modules/laser_injection/analysis_2d.py b/Examples/Modules/laser_injection/analysis_2d.py new file mode 100755 index 00000000000..4037427d33a --- /dev/null +++ b/Examples/Modules/laser_injection/analysis_2d.py @@ -0,0 +1,200 @@ +#! /usr/bin/env python + +# Copyright 2019 Andrew Myers, Jean-Luc Vay, Maxence Thevenet +# Remi Lehe, Weiqun Zhang, Luca Fedeli +# +# This file is part of WarpX. +# +# License: BSD-3-Clause-LBNL + +# This file is part of the WarpX automated test suite. Its purpose is to test the +# injection of a Gaussian laser pulse from an antenna in a 2D simulation. +# In order to avoid privileged directions, the laser is injected at +# approximately 27 degrees with respect to the x axis. Moreover the polarization axis is neither +# parallel nor perpendicular to the xz plane. Finally moving window along the +# x axis is enabled. +# The test calculates the envelope of each component of the laser pulse at the end of +# the simulation and it compares it with theory. It also checks that the +# central frequency of the Fourier transform is the expected one. + +import yt +import sys +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt +import numpy as np +from scipy.signal import hilbert +from mpl_toolkits.axes_grid1 import make_axes_locatable +sys.path.insert(1, '../../../../warpx/Regression/Checksum/') +import checksumAPI + +# Maximum acceptable error for this test +relative_error_threshold = 0.05 + +# A small number +small_num = 1.0e-8 + +# Physical parameters +um = 1.e-6 +fs = 1.e-15 +c = 299792458 + +# Parameters of the gaussian beam +wavelength = 1.*um +w0 = 5.*um +tt = 10.*fs +x_c = 10.*um +t_c = 20.*fs +# foc_dist = 13.109*um (not actually used) +E_max = 4e12 + +# laser direction +dir_vector = np.array([2.,0,1.0]) +dir_vector /= np.linalg.norm(dir_vector) + +rot_angle = np.arctan(dir_vector[2]/dir_vector[0]) + +# polarization vector +pol_vector = np.array([1.0,1.0,-2.0]) +pol_vector /= np.linalg.norm(pol_vector) + +# Calculates the envelope of a Gaussian beam +def gauss_env(T,XX,ZZ): + '''Function to compute the theory for the envelope + ''' + + Z = np.cos(rot_angle)*(XX-x_c) + np.sin(rot_angle)*ZZ + X = -np.sin(rot_angle)*(XX-x_c) + np.cos(rot_angle)*ZZ + + inv_tau2 = 1./tt/tt + inv_w_2 = 1.0/(w0*w0) + exp_arg = - (X*X)*inv_w_2 - inv_tau2 / c/c * (Z-T*c)*(Z-T*c) + return E_max * np.real(np.exp(exp_arg)) + +# Checks envelope and central frequency for a given laser component +def check_component(data, component, t_env_theory, coeff, X,Z,dx,dz): + print("*** Checking " + component + " ***") + field = data['boxlib', component].v.squeeze() + env = abs(hilbert(field)) + + env_theory = t_env_theory*np.abs(coeff) + + # Plot results + fig = plt.figure(figsize=(12,6)) + + ax1 = fig.add_subplot(221, aspect='equal') + ax1.set_title('PIC field') + p1 = ax1.pcolormesh(X,Z,field) + cax1 = make_axes_locatable(ax1).append_axes('right', size='5%', pad=0.05) + fig.colorbar(p1, cax=cax1, orientation='vertical') + + ax2 = fig.add_subplot(222, aspect='equal') + ax2.set_title('PIC envelope') + p2 = ax2.pcolormesh(X,Z,env) + cax2 = make_axes_locatable(ax2).append_axes('right', size='5%', pad=0.05) + fig.colorbar(p2, cax=cax2, orientation='vertical') + + ax3 = fig.add_subplot(223, aspect='equal') + ax3.set_title('Theory envelope') + p3 = ax3.pcolormesh(X,Z,env_theory) + cax3 = make_axes_locatable(ax3).append_axes('right', size='5%', pad=0.05) + fig.colorbar(p3, cax=cax3, orientation='vertical') + + ax4 = fig.add_subplot(224, aspect='equal') + ax4.set_title('Difference') + p4 = ax4.pcolormesh(X,Z,env-env_theory) + cax4 = make_axes_locatable(ax4).append_axes('right', size='5%', pad=0.05) + fig.colorbar(p4, cax=cax4, orientation='vertical') + + plt.tight_layout() + plt.savefig("plt_" + component + ".png", bbox_inches='tight') + + if(np.abs(coeff) < small_num): + is_field_zero = np.sum(np.abs(env)) < small_num + if is_field_zero : + print("[OK] Field component expected to be 0 is ~ 0") + else : + print("[FAIL] Field component expected to be 0 is NOT ~ 0") + assert(is_field_zero) + print("******\n") + return + + relative_error_env = np.sum(np.abs(env-env_theory)) / np.sum(np.abs(env_theory)) + is_env_ok = relative_error_env < relative_error_threshold + if is_env_ok : + print("[OK] Relative error envelope: {:6.3f} %".format(relative_error_env*100)) + else : + print("[FAIL] Relative error envelope: {:6.3f} %".format(relative_error_env*100)) + assert(is_env_ok) + + fft_field = np.fft.fft2(field) + + freq_rows = np.fft.fftfreq(fft_field.shape[0],dx/c) + freq_cols = np.fft.fftfreq(fft_field.shape[1],dz/c) + + pos_max = np.unravel_index(np.abs(fft_field).argmax(), fft_field.shape) + + freq = np.sqrt((freq_rows[pos_max[0]])**2 + (freq_cols[pos_max[1]]**2)) + exp_freq = c/wavelength + + relative_error_freq = np.abs(freq-exp_freq)/exp_freq + is_freq_ok = relative_error_freq < relative_error_threshold + if is_freq_ok : + print("[OK] Relative error frequency: {:6.3f} %".format(relative_error_freq*100)) + else : + print("[FAIL] Relative error frequency: {:6.3f} %".format(relative_error_freq*100)) + assert(is_freq_ok) + + print("******\n") + +def check_laser(filename): + ds = yt.load(filename) + + x = np.linspace( + ds.domain_left_edge[0].v, + ds.domain_right_edge[0].v, + ds.domain_dimensions[0]) + + dx = (ds.domain_right_edge[0].v-ds.domain_left_edge[0].v)/(ds.domain_dimensions[0]-1) + + z = np.linspace( + ds.domain_left_edge[1].v, + ds.domain_right_edge[1].v, + ds.domain_dimensions[1]) + + dz = (ds.domain_right_edge[1].v-ds.domain_left_edge[1].v)/(ds.domain_dimensions[1]-1) + + X, Z = np.meshgrid(x, z, indexing='ij') + + # Compute the theory for envelope + env_theory = gauss_env(+t_c-ds.current_time.to_value(),X,Z)+gauss_env(-t_c+ds.current_time.to_value(),X,Z) + + # Read laser field in PIC simulation, and compute envelope + all_data_level_0 = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions) + + b_vector = np.cross(dir_vector, pol_vector) + + components = ["Ex", "Ey", "Ez", "Bx", "By", "Bz"] + coeffs = [ + pol_vector[0], + pol_vector[1], + pol_vector[2], + b_vector[0], + b_vector[1], + b_vector[2]] + + field_facts = [1, 1, 1, 1/c, 1/c, 1/c] + + for comp, coeff, field_fact in zip(components, coeffs, field_facts): + check_component(all_data_level_0, comp, field_fact*env_theory, coeff, X, Z, dx, dz) + +def main(): + filename_end = sys.argv[1] + + check_laser(filename_end) + + test_name = filename_end[:-9] # Could also be os.path.split(os.getcwd())[1] + checksumAPI.evaluate_checksum(test_name, filename_end) + +if __name__ == "__main__": + main() diff --git a/Examples/Modules/laser_injection/inputs_2d_rt b/Examples/Modules/laser_injection/inputs_2d_rt index 7e86e5eee9f..694d55de97f 100644 --- a/Examples/Modules/laser_injection/inputs_2d_rt +++ b/Examples/Modules/laser_injection/inputs_2d_rt @@ -1,8 +1,8 @@ # Maximum number of time steps -max_step = 100 +max_step = 220 # number of grid points -amr.n_cell = 240 64 +amr.n_cell = 480 352 # Maximum allowable size of each subdomain in the problem domain; # this is used to decompose the domain for parallel calculations. @@ -14,8 +14,8 @@ amr.max_level = 0 # Geometry geometry.coord_sys = 0 # 0: Cartesian geometry.is_periodic = 0 1 # Is periodic? -geometry.prob_lo = -12.e-6 -20.e-6 # physical domain -geometry.prob_hi = 12.e-6 20.e-6 +geometry.prob_lo = -20.e-6 -15.e-6 # physical domain +geometry.prob_hi = 20.e-6 15.e-6 warpx.serialize_ics = 1 @@ -31,19 +31,21 @@ warpx.cfl = 1.0 # Laser lasers.names = laser1 laser1.profile = Gaussian -laser1.position = 9.e-6 0. 0. # This point is on the laser plane -laser1.direction = 1. 0. 0. # The plane normal direction -laser1.polarization = 0. 1. 0. # The main polarization vector -laser1.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) -laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) -laser1.profile_waist = 5.e-6 # The waist of the laser (in meters) -laser1.profile_duration = 15.e-15 # The duration of the laser (in seconds) -laser1.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) -laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) +laser1.position = 10.e-6 0.e-6 0.e-6 # This point is on the laser plane +laser1.direction = 2. 0. 1. # The plane normal direction +laser1.polarization = 1. 1. -2. # The main polarization vector +laser1.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) +laser1.wavelength = 1.0e-6 # The wavelength of the laser (in meters) +laser1.profile_waist = 5.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 10.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 20.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 13.109e-6 # Focal distance from the antenna (in meters) + # With this focal distance the laser is at focus + # at the end of the simulation. # Diagnostics diagnostics.diags_names = diag1 -diag1.period = 10000 +diag1.period = 220 diag1.diag_type = Full warpx.do_pml = 0 diff --git a/Regression/Checksum/benchmarks_json/LaserInjection_2d.json b/Regression/Checksum/benchmarks_json/LaserInjection_2d.json index 3c5fac5ac68..4f0b5adb49f 100644 --- a/Regression/Checksum/benchmarks_json/LaserInjection_2d.json +++ b/Regression/Checksum/benchmarks_json/LaserInjection_2d.json @@ -1,13 +1,13 @@ { "lev=0": { - "Bx": 372733.10337870487, - "By": 0.0, - "Bz": 13765158.2515458, - "Ex": 0.0, - "Ey": 4119361390924632.5, - "Ez": 0.0, - "jx": 0.0, - "jy": 3.032119320338747e+18, - "jz": 0.0 + "Bx": 19661649.2843472324311733245849609375000000000000, + "By": 101030587.3703132718801498413085937500000000000000, + "Bz": 39719434.3724947720766067504882812500000000000000, + "Ex": 13838472033041280.0000000000000000000000000000000000000000, + "Ey": 13195219839199646.0000000000000000000000000000000000000000, + "Ez": 26772619800801276.0000000000000000000000000000000000000000, + "jx": 40346610039036864.0000000000000000000000000000000000000000, + "jy": 40346609403930968.0000000000000000000000000000000000000000, + "jz": 80693222329514336.0000000000000000000000000000000000000000 } -} \ No newline at end of file +} diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 3fadf586cd6..ae6589d837b 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -767,7 +767,7 @@ numthreads = 2 compileTest = 0 doVis = 0 compareParticles = 0 -analysisRoutine = Examples/analysis_default_regression.py +analysisRoutine = Examples/Modules/laser_injection/analysis_2d.py tolerance = 1.e-14 [LaserAcceleration] From e85b70c01aa81f28958e8d9080a220f06a08250a Mon Sep 17 00:00:00 2001 From: NeilZaim <49716072+NeilZaim@users.noreply.github.com> Date: Mon, 26 Oct 2020 20:52:33 +0100 Subject: [PATCH 27/30] FieldMaximum reduced diag: average all components to cell centers (#1411) * FieldMaximum reduced diag: average all components to cell centers * Remove read_raw_data.py in reduced diag automated test * No longer output raw fields in reduced diags tests * Modify a comment --- Docs/source/running_cpp/parameters.rst | 6 +- .../reduced_diags/analysis_reduced_diags.py | 28 +--- Examples/Tests/reduced_diags/inputs | 1 - Regression/WarpX-tests.ini | 1 - .../Diagnostics/ReducedDiags/FieldMaximum.cpp | 156 +++++++++++------- 5 files changed, 111 insertions(+), 81 deletions(-) diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index 2ac0a9ffc71..49b0d4485de 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -1445,9 +1445,10 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a Fields written to output. Possible values: ``Ex`` ``Ey`` ``Ez`` ``Bx`` ``By`` ``Bz`` ``jx`` ``jy`` ``jz`` ``part_per_cell`` ``rho`` ``F`` ``part_per_grid`` ``divE`` ``divB`` and ``rho_``, where ```` must match the name of one of the available particle species. Default is ``.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz``. + Note that the fields are averaged on the cell centers before they are written to file. * ``.plot_raw_fields`` (`0` or `1`) optional (default `0`) - By default, the fields written in the plot files are averaged on the nodes. + By default, the fields written in the plot files are averaged on the cell centers. When ```warpx.plot_raw_fields`` is `1`, then the raw (i.e. unaveraged) fields are also saved in the output files. Only works with ``.format = plotfile``. @@ -1674,6 +1675,9 @@ Reduced Diagnostics the maximum value of the norm :math:`|B|` of the magnetic field, at mesh refinement levels from 0 to :math:`n`. + Note that the fields are averaged on the cell centers before their maximum values are + computed. + * ``ParticleNumber`` This type computes the total number of macroparticles in the simulation (for each species and summed over all species). It can be useful in particular for simulations with creation diff --git a/Examples/Tests/reduced_diags/analysis_reduced_diags.py b/Examples/Tests/reduced_diags/analysis_reduced_diags.py index cc0c10dd778..11edd234739 100755 --- a/Examples/Tests/reduced_diags/analysis_reduced_diags.py +++ b/Examples/Tests/reduced_diags/analysis_reduced_diags.py @@ -25,7 +25,6 @@ import yt import numpy as np import scipy.constants as scc -import read_raw_data sys.path.insert(1, '../../../../warpx/Regression/Checksum/') import checksumAPI @@ -62,21 +61,6 @@ num_photon = w.shape[0] num_total = num_electron + num_proton + num_photon -# Use raw field plotfiles to compare with maximum field reduced diag -ad_raw = read_raw_data.read_data(fn) -Ex_raw = ad_raw[0]['Ex_aux'] -Ey_raw = ad_raw[0]['Ey_aux'] -Ez_raw = ad_raw[0]['Ez_aux'] -Bx_raw = ad_raw[0]['Bx_aux'] -By_raw = ad_raw[0]['By_aux'] -Bz_raw = ad_raw[0]['Bz_aux'] -max_Ex = np.amax(np.abs(Ex_raw)) -max_Ey = np.amax(np.abs(Ey_raw)) -max_Ez = np.amax(np.abs(Ez_raw)) -max_Bx = np.amax(np.abs(Bx_raw)) -max_By = np.amax(np.abs(By_raw)) -max_Bz = np.amax(np.abs(Bz_raw)) - ad = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions) Ex = ad['Ex'].to_ndarray() Ey = ad['Ey'].to_ndarray() @@ -84,15 +68,19 @@ Bx = ad['Bx'].to_ndarray() By = ad['By'].to_ndarray() Bz = ad['Bz'].to_ndarray() -# Maximum value of |E| and |B| are obtained after interpolation so we do not use raw fields for -# these -max_E = np.sqrt(np.amax(Ex**2+Ey**2+Ez**2)) -max_B = np.sqrt(np.amax(Bx**2+By**2+Bz**2)) Es = np.sum(Ex**2)+np.sum(Ey**2)+np.sum(Ez**2) Bs = np.sum(Bx**2)+np.sum(By**2)+np.sum(Bz**2) N = np.array( ds.domain_width / ds.domain_dimensions ) dV = N[0]*N[1]*N[2] EFyt = 0.5*Es*scc.epsilon_0*dV + 0.5*Bs/scc.mu_0*dV +max_Ex = np.amax(np.abs(Ex)) +max_Ey = np.amax(np.abs(Ey)) +max_Ez = np.amax(np.abs(Ez)) +max_Bx = np.amax(np.abs(Bx)) +max_By = np.amax(np.abs(By)) +max_Bz = np.amax(np.abs(Bz)) +max_E = np.sqrt(np.amax(Ex**2+Ey**2+Ez**2)) +max_B = np.sqrt(np.amax(Bx**2+By**2+Bz**2)) # PART2: get results from reduced diagnostics diff --git a/Examples/Tests/reduced_diags/inputs b/Examples/Tests/reduced_diags/inputs index de2b8b37f9d..524bc906b3c 100644 --- a/Examples/Tests/reduced_diags/inputs +++ b/Examples/Tests/reduced_diags/inputs @@ -85,4 +85,3 @@ NP.frequency = 200 diagnostics.diags_names = diag1 diag1.period = 200 diag1.diag_type = Full -diag1.plot_raw_fields = 1 diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index ae6589d837b..ca30ffa63f1 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -1542,7 +1542,6 @@ numthreads = 2 compileTest = 0 doVis = 0 compareParticles = 0 -aux1File = Tools/PostProcessing/read_raw_data.py analysisRoutine = Examples/Tests/reduced_diags/analysis_reduced_diags.py tolerance = 1e-12 diff --git a/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp b/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp index 2fee0546cf3..a7250c5aaa2 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp @@ -122,44 +122,56 @@ void FieldMaximum::ComputeDiags (int step) constexpr int index_Bz = 6; constexpr int index_absB = 7; - // get Maximums of E field components - m_data[lev*noutputs+index_Ex] = Ex.norm0(); - m_data[lev*noutputs+index_Ey] = Ey.norm0(); - m_data[lev*noutputs+index_Ez] = Ez.norm0(); - - // get Maximums of B field components - m_data[lev*noutputs+index_Bx] = Bx.norm0(); - m_data[lev*noutputs+index_By] = By.norm0(); - m_data[lev*noutputs+index_Bz] = Bz.norm0(); - - // General preparation of interpolation and reduction to compute the maximum value of - // |E| and |B| + // General preparation of interpolation and reduction operations const GpuArray cellCenteredtype{0,0,0}; const GpuArray reduction_coarsening_ratio{1,1,1}; constexpr int reduction_comp = 0; - // Prepare reduction for maximum value of |E| + ReduceOps reduceEx_op; + ReduceOps reduceEy_op; + ReduceOps reduceEz_op; + ReduceOps reduceBx_op; + ReduceOps reduceBy_op; + ReduceOps reduceBz_op; ReduceOps reduceE_op; + ReduceOps reduceB_op; + + ReduceData reduceEx_data(reduceEx_op); + ReduceData reduceEy_data(reduceEy_op); + ReduceData reduceEz_data(reduceEz_op); + ReduceData reduceBx_data(reduceBx_op); + ReduceData reduceBy_data(reduceBy_op); + ReduceData reduceBz_data(reduceBz_op); ReduceData reduceE_data(reduceE_op); - using ReduceTuple = typename decltype(reduceE_data)::Type; + ReduceData reduceB_data(reduceB_op); - // Prepare interpolation of E field components to cell center + using ReduceTuple = typename decltype(reduceEx_data)::Type; + + // Prepare interpolation of field components to cell center GpuArray Extype; GpuArray Eytype; GpuArray Eztype; + GpuArray Bxtype; + GpuArray Bytype; + GpuArray Bztype; for (int i = 0; i < AMREX_SPACEDIM; ++i){ Extype[i] = Ex.ixType()[i]; Eytype[i] = Ey.ixType()[i]; Eztype[i] = Ez.ixType()[i]; + Bxtype[i] = Bx.ixType()[i]; + Bytype[i] = By.ixType()[i]; + Bztype[i] = Bz.ixType()[i]; } #if (AMREX_SPACEDIM == 2) Extype[2] = 0; Eytype[2] = 0; Eztype[2] = 0; + Bxtype[2] = 0; + Bytype[2] = 0; + Bztype[2] = 0; #endif - // MFIter loop to interpolate E field components to cell center and get maximum value - // of |E| + // MFIter loop to interpolate fields to cell center and get maximum values #ifdef _OPENMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif @@ -170,6 +182,52 @@ void FieldMaximum::ComputeDiags (int step) const auto& arrEx = Ex[mfi].array(); const auto& arrEy = Ey[mfi].array(); const auto& arrEz = Ez[mfi].array(); + const auto& arrBx = Bx[mfi].array(); + const auto& arrBy = By[mfi].array(); + const auto& arrBz = Bz[mfi].array(); + + reduceEx_op.eval(box, reduceEx_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real Ex_interp = CoarsenIO::Interp(arrEx, Extype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(Ex_interp); + }); + reduceEy_op.eval(box, reduceEy_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real Ey_interp = CoarsenIO::Interp(arrEy, Eytype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(Ey_interp); + }); + reduceEz_op.eval(box, reduceEz_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real Ez_interp = CoarsenIO::Interp(arrEz, Eztype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(Ez_interp); + }); + reduceBx_op.eval(box, reduceBx_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real Bx_interp = CoarsenIO::Interp(arrBx, Bxtype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(Bx_interp); + }); + reduceBy_op.eval(box, reduceBy_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real By_interp = CoarsenIO::Interp(arrBy, Bytype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(By_interp); + }); + reduceBz_op.eval(box, reduceBz_data, + [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple + { + const Real Bz_interp = CoarsenIO::Interp(arrBz, Bztype, cellCenteredtype, + reduction_coarsening_ratio, i, j, k, reduction_comp); + return amrex::Math::abs(Bz_interp); + }); reduceE_op.eval(box, reduceE_data, [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple { @@ -181,47 +239,6 @@ void FieldMaximum::ComputeDiags (int step) reduction_coarsening_ratio, i, j, k, reduction_comp); return Ex_interp*Ex_interp + Ey_interp*Ey_interp + Ez_interp*Ez_interp; }); - } - - Real hv_E = amrex::get<0>(reduceE_data.value()); // highest value of |E|**2 - // MPI reduce - ParallelDescriptor::ReduceRealMax(hv_E); - - m_data[lev*noutputs+index_absE] = std::sqrt(hv_E); - - // Prepare reduction for maximum value of |B| - ReduceOps reduceB_op; - ReduceData reduceB_data(reduceB_op); - using ReduceTuple = typename decltype(reduceB_data)::Type; - - // Prepare interpolation of B field components to cell center - GpuArray Bxtype; - GpuArray Bytype; - GpuArray Bztype; - for (int i = 0; i < AMREX_SPACEDIM; ++i){ - Bxtype[i] = Bx.ixType()[i]; - Bytype[i] = By.ixType()[i]; - Bztype[i] = Bz.ixType()[i]; - } -#if (AMREX_SPACEDIM == 2) - Bxtype[2] = 0; - Bytype[2] = 0; - Bztype[2] = 0; -#endif - - // MFIter loop to interpolate B field components to cell center and get maximum value - // of |B| -#ifdef _OPENMP -#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) -#endif - for ( MFIter mfi(Ex, TilingIfNotGPU()); mfi.isValid(); ++mfi ) - { - // Make the box cell centered to avoid including ghost cells in the calculation - const Box& box = enclosedCells(mfi.nodaltilebox()); - const auto& arrBx = Bx[mfi].array(); - const auto& arrBy = By[mfi].array(); - const auto& arrBz = Bz[mfi].array(); - reduceB_op.eval(box, reduceB_data, [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple { @@ -235,10 +252,33 @@ void FieldMaximum::ComputeDiags (int step) }); } + Real hv_Ex = amrex::get<0>(reduceEx_data.value()); // highest value of |Ex| + Real hv_Ey = amrex::get<0>(reduceEy_data.value()); // highest value of |Ey| + Real hv_Ez = amrex::get<0>(reduceEz_data.value()); // highest value of |Ez| + Real hv_Bx = amrex::get<0>(reduceBx_data.value()); // highest value of |Bx| + Real hv_By = amrex::get<0>(reduceBy_data.value()); // highest value of |By| + Real hv_Bz = amrex::get<0>(reduceBz_data.value()); // highest value of |Bz| + Real hv_E = amrex::get<0>(reduceE_data.value()); // highest value of |E|**2 Real hv_B = amrex::get<0>(reduceB_data.value()); // highest value of |B|**2 + // MPI reduce + ParallelDescriptor::ReduceRealMax(hv_Ex); + ParallelDescriptor::ReduceRealMax(hv_Ey); + ParallelDescriptor::ReduceRealMax(hv_Ez); + ParallelDescriptor::ReduceRealMax(hv_Bx); + ParallelDescriptor::ReduceRealMax(hv_By); + ParallelDescriptor::ReduceRealMax(hv_Bz); + ParallelDescriptor::ReduceRealMax(hv_E); ParallelDescriptor::ReduceRealMax(hv_B); + // Fill output array + m_data[lev*noutputs+index_Ex] = hv_Ex; + m_data[lev*noutputs+index_Ey] = hv_Ey; + m_data[lev*noutputs+index_Ez] = hv_Ez; + m_data[lev*noutputs+index_Bx] = hv_Bx; + m_data[lev*noutputs+index_By] = hv_By; + m_data[lev*noutputs+index_Bz] = hv_Bz; + m_data[lev*noutputs+index_absE] = std::sqrt(hv_E); m_data[lev*noutputs+index_absB] = std::sqrt(hv_B); } // end loop over refinement levels From 1140e9f8c3c20c969363dddfc184696f27c2ac72 Mon Sep 17 00:00:00 2001 From: David Grote Date: Mon, 26 Oct 2020 13:09:50 -0700 Subject: [PATCH 28/30] Filter diagnostic rho (#1295) * First cut of adding filtering of rho diagnostic - not yet working * Fixed the handling of parallel transfers in RhoFunctor when filtering is turned on * Fixed end of line space * In RhoFunctor, only do kspace filter with RZ and PSATD * PICMI analytic applied fields (#1306) * PICMI Added applied fields * PICMI fixed typo in Constants * Change picmistandard version requirement to 0.0.9 * Increment required picmi version Co-authored-by: Remi Lehe * Updated checksums with filter of diagnostic rho * Fix comment in rho diagnostic * Updated LaserIonAcc2d benchmark after filtering rho * Update galilean_rz_psatd benchmark with filtering of rho Co-authored-by: Remi Lehe --- .../benchmarks_json/LaserAcceleration.json | 4 +-- .../benchmarks_json/LaserAccelerationMR.json | 6 ++--- .../benchmarks_json/LaserAccelerationRZ.json | 2 +- .../benchmarks_json/LaserIonAcc2d.json | 4 +-- .../benchmarks_json/galilean_rz_psatd.json | 4 +-- .../ComputeDiagFunctors/RhoFunctor.cpp | 27 +++++++++++++++++-- Source/Parallelization/WarpXComm.cpp | 18 ++++++++----- Source/WarpX.H | 13 +++++++++ 8 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Regression/Checksum/benchmarks_json/LaserAcceleration.json b/Regression/Checksum/benchmarks_json/LaserAcceleration.json index 5af011038de..7a5bc9475c4 100644 --- a/Regression/Checksum/benchmarks_json/LaserAcceleration.json +++ b/Regression/Checksum/benchmarks_json/LaserAcceleration.json @@ -20,6 +20,6 @@ "jx": 555905302485608.94, "jy": 1596092839924503.8, "jz": 1045523884130288.4, - "rho": 2213786555.2727532 + "rho": 2211743042.5513821 } -} \ No newline at end of file +} diff --git a/Regression/Checksum/benchmarks_json/LaserAccelerationMR.json b/Regression/Checksum/benchmarks_json/LaserAccelerationMR.json index 71d1f37cfef..02281dd21e9 100644 --- a/Regression/Checksum/benchmarks_json/LaserAccelerationMR.json +++ b/Regression/Checksum/benchmarks_json/LaserAccelerationMR.json @@ -29,7 +29,7 @@ "jx": 1131265582036586.2, "jy": 2.325136123562568e+18, "jz": 6769514298165733.0, - "rho": 153059939.2876033 + "rho": 152898720.2638083 }, "lev=1": { "Bx": 53303255.15572796, @@ -41,6 +41,6 @@ "jx": 48050235573831.96, "jy": 9.274838877361125e+18, "jz": 1.92627519812193e+16, - "rho": 67241940.12364514 + "rho": 67304284.98422323 } -} \ No newline at end of file +} diff --git a/Regression/Checksum/benchmarks_json/LaserAccelerationRZ.json b/Regression/Checksum/benchmarks_json/LaserAccelerationRZ.json index c4ebe719d0b..567e0d908b0 100644 --- a/Regression/Checksum/benchmarks_json/LaserAccelerationRZ.json +++ b/Regression/Checksum/benchmarks_json/LaserAccelerationRZ.json @@ -31,6 +31,6 @@ "jx": 913724361200.7623, "jy": 2.0581594676890458e+17, "jz": 1772971850765479.5, - "rho": 39161887.06938790 + "rho": 38578930.57390296 } } diff --git a/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json b/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json index 7a2aca2b6fc..9e76938623d 100644 --- a/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json +++ b/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json @@ -29,8 +29,8 @@ "jx": 1.1795616964119449e+20, "jy": 0.0, "jz": 7.413959422336308e+19, - "rho": 893318471772.7588, + "rho": 344505246673.0273, "rho_electrons": 74759628935311.0, "rho_hydrogen": 74759628935311.02 } -} \ No newline at end of file +} diff --git a/Regression/Checksum/benchmarks_json/galilean_rz_psatd.json b/Regression/Checksum/benchmarks_json/galilean_rz_psatd.json index e49a6a66b0c..3b6b666798f 100644 --- a/Regression/Checksum/benchmarks_json/galilean_rz_psatd.json +++ b/Regression/Checksum/benchmarks_json/galilean_rz_psatd.json @@ -29,6 +29,6 @@ "divE": 1349004.6304044977, "jx": 163.91848307748262, "jz": 50271.11378286561, - "rho": 0.0001686919398337135 + "rho": 0.0000120119242959871 } -} \ No newline at end of file +} diff --git a/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.cpp index c8ccb2deda7..e48703e9171 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.cpp @@ -2,6 +2,10 @@ #include "RhoFunctor.H" #include "Utils/CoarsenIO.H" +#ifdef WARPX_DIM_RZ +#include "FieldSolver/SpectralSolver/SpectralFieldData.H" +#endif + #include RhoFunctor::RhoFunctor (const int lev, @@ -21,17 +25,36 @@ RhoFunctor::operator() ( amrex::MultiFab& mf_dst, const int dcomp, const int /*i auto& warpx = WarpX::GetInstance(); std::unique_ptr rho; + // Deposit charge density + // Call this with local=true since the parallel transfers will be handled + // by ApplyFilterandSumBoundaryRho + // Dump total rho if (m_species_index == -1) { auto& mypc = warpx.GetPartContainer(); - rho = mypc.GetChargeDensity(m_lev); + rho = mypc.GetChargeDensity(m_lev, true); } // Dump rho per species else { auto& mypc = warpx.GetPartContainer().GetParticleContainer(m_species_index); - rho = mypc.GetChargeDensity(m_lev); + rho = mypc.GetChargeDensity(m_lev, true); } + // Handle the parallel transfers of guard cells and + // apply the filtering if requested. + warpx.ApplyFilterandSumBoundaryRho(m_lev, m_lev, *rho, 0, rho->nComp()); + +#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD) + using Idx = SpectralAvgFieldIndex; + if (WarpX::use_kspace_filter) { + auto & solver = warpx.get_spectral_solver_fp(m_lev); + solver.ForwardTransform(*rho, Idx::rho_new); + solver.ApplyFilter(Idx::rho_new); + solver.BackwardTransform(*rho, Idx::rho_new); + } +#endif + + #ifdef WARPX_DIM_RZ if (m_convertRZmodes2cartesian) { // In cylindrical geometry, sum real part of all modes of rho in diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp index 667be0696f6..daee2405401 100644 --- a/Source/Parallelization/WarpXComm.cpp +++ b/Source/Parallelization/WarpXComm.cpp @@ -873,17 +873,23 @@ void WarpX::ApplyFilterandSumBoundaryRho (int lev, PatchType patch_type, int icomp, int ncomp) { const int glev = (patch_type == PatchType::fine) ? lev : lev-1; - const auto& period = Geom(glev).periodicity(); auto& r = (patch_type == PatchType::fine) ? rho_fp[lev] : rho_cp[lev]; if (r == nullptr) return; + ApplyFilterandSumBoundaryRho(lev, glev, *r, icomp, ncomp); +} + +void +WarpX::ApplyFilterandSumBoundaryRho (int lev, int glev, amrex::MultiFab& rho, int icomp, int ncomp) +{ + const auto& period = Geom(glev).periodicity(); if (use_filter) { - IntVect ng = r->nGrowVect(); + IntVect ng = rho.nGrowVect(); ng += bilinear_filter.stencil_length_each_dir-1; - MultiFab rf(r->boxArray(), r->DistributionMap(), ncomp, ng); - bilinear_filter.ApplyStencil(rf, *r, icomp, 0, ncomp); - WarpXSumGuardCells(*r, rf, period, icomp, ncomp ); + MultiFab rf(rho.boxArray(), rho.DistributionMap(), ncomp, ng); + bilinear_filter.ApplyStencil(rf, rho, icomp, 0, ncomp); + WarpXSumGuardCells(rho, rf, period, icomp, ncomp ); } else { - WarpXSumGuardCells(*r, period, icomp, ncomp); + WarpXSumGuardCells(rho, period, icomp, ncomp); } } diff --git a/Source/WarpX.H b/Source/WarpX.H index 68dd45949bd..928e40b4229 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -543,6 +543,8 @@ public: */ void ComputeCostsHeuristic (amrex::Vector > >& costs); + void ApplyFilterandSumBoundaryRho (int lev, int glev, amrex::MultiFab& rho, int icomp, int ncomp); + protected: /** @@ -877,7 +879,18 @@ private: amrex::Vector> spectral_solver_fp; amrex::Vector> spectral_solver_cp; # endif + +public: + +# ifdef WARPX_DIM_RZ + SpectralSolverRZ& +# else + SpectralSolver& +# endif + get_spectral_solver_fp (int lev) {return *spectral_solver_fp[lev];} #endif + +private: amrex::Vector> m_fdtd_solver_fp; amrex::Vector> m_fdtd_solver_cp; }; From 51f5af9f1950209948c0e91ff9e2882d9b9c5fed Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 26 Oct 2020 15:35:38 -0700 Subject: [PATCH 29/30] Ascent: Jupyter Replay Workflow (#1473) Document an efficient workflow to quickly iterate on an `ascent_actions.yaml` design. --- Docs/source/visualization/ascent.rst | 26 ++- Tools/Ascent/ascent_replay_warpx.ipynb | 310 +++++++++++++++++++++++++ 2 files changed, 333 insertions(+), 3 deletions(-) create mode 100644 Tools/Ascent/ascent_replay_warpx.ipynb diff --git a/Docs/source/visualization/ascent.rst b/Docs/source/visualization/ascent.rst index a48b936aa5a..6033e1333fd 100644 --- a/Docs/source/visualization/ascent.rst +++ b/Docs/source/visualization/ascent.rst @@ -286,10 +286,30 @@ Workflow .. note:: This section is in-progress. - It will describe how to quickly create and iterate on ``ascent_actions.yaml`` files before running at scale. + TODOs: finalize acceptance testing; update 3D LWFA example - TODOs: finalize acceptance testing; update 3D LWFA example; share Jupyter notebook file +In the preparation of simulations, it is generally useful to run small, under-resolved versions of the planned simulation layout first. +Ascent replay is helpful in the setup of an in situ visualization pipeline during this process. +In the following, a Jupyter-based workflow is shown that can be used to quickly iterate on the design of a ``ascent_actions.yaml`` file, repeatedly rendering the same (small) data. + +First, run a small simulation, e.g. on a local computer, and create conduit blueprint files (see above). +Second, copy the Jupyter Notebook file :download:`ascent_replay_warpx.ipynb <../../../Tools/Ascent/ascent_replay_warpx.ipynb>` into the simulation output directory. +Third, download and start a Docker container with a prepared Jupyter installation and Ascent Python bindings from the simulation output directory: .. code-block:: bash - docker run -v$PWD:/home/user/ascent/install-debug/examples/ascentutorial/ascent_intro/notebooks/replay -p 8000:8000 -p 8888:8888 -p 9000:9000 -p 10000:10000 -t -i alpinedav/ascent-jupyter:latest + docker pull alpinedav/ascent-jupyter:latest + docker run -v$PWD:/home/user/ascent/install-debug/examples/ascent/tutorial/ascent_intro/notebooks/replay -p 8000:8000 -p 8888:8888 -p 9000:9000 -p 10000:10000 -t -i alpinedav/ascent-jupyter:latest + +Now, access Jupyter Lab via: http://localhost:8888/lab (password: ``learn``). + +Inside the Jupyter Lab is a ``replay/`` directory, which mounts the outer working directory. +You can now open ``ascent_replay_warpx.ipynb`` and execute all cells. +The last two cells are the replay action that can be quickly iterated: change ``replay_actions.yaml`` cell and execute both. + +.. note:: + + * Keep an eye on the terminal, if a replay action is erroneous it will show up on the terminal that started the docker container. + (TODO: We might want to catch that inside python and print it in Jupyter instead.) + * If you remove a "key" from the replay action, you might see an error in the ``AscentViewer``. + Restart and execute all cells in that case. diff --git a/Tools/Ascent/ascent_replay_warpx.ipynb b/Tools/Ascent/ascent_replay_warpx.ipynb new file mode 100644 index 00000000000..636e9721c74 --- /dev/null +++ b/Tools/Ascent/ascent_replay_warpx.ipynb @@ -0,0 +1,310 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Replay Data\n", + "This notebook allows quick playing with Ascent actions on created \"conduit blueprint data\". See Ascent's [Extracts](https://ascent.readthedocs.io/en/latest/Actions/Extracts.html) docs for deeper details on Extracts." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import conduit\n", + "import conduit.blueprint\n", + "import conduit.relay\n", + "import ascent\n", + "\n", + "from IPython.display import Image\n", + "\n", + "import glob" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#print(conduit.about())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# show existing conduit blueprint files\n", + "sim = \"./\"\n", + "glob.glob(sim + \"*root\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "# VisIt 2.13 or newer, when built with Conduit support, can visualize meshes from these files.\n", + "# Look at the Blueprint HDF5 extract with VisIt\n", + "#!visit -o conduit_blueprint.cycle_000400.root" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Prepare Data\n", + "Initialize Ascent and Load a Blueprint File" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this step can take a while if the simulation used high resolution\n", + "data = conduit.Node()\n", + "conduit.relay.io.blueprint.read_mesh(data, sim + \"conduit_blueprint.cycle_000400.root\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# we publish this data now once to visualize it in multiple ways below\n", + "a = ascent.Ascent()\n", + "opts = conduit.Node()\n", + "opts[\"actions_file\"] = \"\" # work-around: ascent_actions.yaml file must not overwrite our replay action\n", + "#opts[\"exceptions\"] = \"forward\"\n", + "a.open(opts)\n", + "a.publish(data)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def rerender():\n", + " \"\"\"This is reads an updated Ascent Action and rerenders the image\"\"\"\n", + " actions = conduit.Node()\n", + " actions.load(\"replay_actions.yaml\")\n", + " a.execute(actions)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Relay Example\n", + "The next two cells are as follows:\n", + "1. modify the Ascent action (examples: https://ascent.readthedocs.io/en/latest/Actions/Examples.html)\n", + "2. rerender\n", + "\n", + "By only modifying and executing only those two cells one can quickly iterate over new visualizations." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%writefile replay_actions.yaml\n", + "\n", + "# this block are data pipelines\n", + "# each entry in pipelines: executes a series of functions from top to bottom,\n", + "# results of prior functions can be used in later calls of the same pipeline\n", + "-\n", + " action: \"add_pipelines\"\n", + " pipelines:\n", + " slice_field:\n", + " f1:\n", + " type: \"slice\"\n", + " params:\n", + " topology: topo\n", + " point: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal: {x: 1.0, y: 1.0, z: 0.0}\n", + " \n", + " sampled_particles:\n", + " f1:\n", + " type: histsampling\n", + " params:\n", + " field: particle_electrons_uz\n", + " bins: 64\n", + " sample_rate: 0.90\n", + " f2:\n", + " type: \"clip\"\n", + " params:\n", + " topology: particle_electrons # particle data\n", + " multi_plane:\n", + " point1: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal1: {x: 1.0, y: 0.0, z: 0.0}\n", + " point2: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal2: {x: 0.7, y: -0.7, z: 0.0}\n", + "\n", + " clipped_volume:\n", + " f0:\n", + " type: \"contour\"\n", + " params:\n", + " field: \"Ez\"\n", + " levels: 10\n", + " f1:\n", + " type: \"clip\"\n", + " params:\n", + " topology: topo # name of the amr mesh\n", + " multi_plane:\n", + " point1: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal1: {x: 1.0, y: 0.0, z: 0.0}\n", + " point2: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal2: {x: 0.3, y: -0.3, z: 0.0}\n", + "\n", + " mag_clipped_volume_E:\n", + " f0: \n", + " type: \"composite_vector\"\n", + " params: \n", + " field1: \"Ex\"\n", + " field2: \"Ey\"\n", + " field3: \"Ez\"\n", + " output_name: \"E_vec\"\n", + " f1: \n", + " type: \"vector_magnitude\"\n", + " params: \n", + " field: \"E_vec\"\n", + " output_name: \"E_mag\"\n", + " f2:\n", + " type: \"contour\"\n", + " params:\n", + " field: \"E_mag\"\n", + " levels: 4\n", + " f3:\n", + " type: \"clip\"\n", + " params:\n", + " topology: topo # name of the amr mesh\n", + " multi_plane:\n", + " point1: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal1: {x: 1.0, y: 0.0, z: 0.0}\n", + " point2: {x: 0.0, y: 0.0, z: 0.0}\n", + " normal2: {x: 0.7, y: -0.7, z: 0.0}\n", + "\n", + "# A scene is describes the things to be rendered and how\n", + "# here one selects either data directly or data that goes into a data pipeline;\n", + "# then, the result gets represented with a visualization \"type\" and according\n", + "# parameters such as colorbars and color ranges (aka transfer functions)\n", + "# reference: https://ascent.readthedocs.io/en/latest/Actions/Scenes.html\n", + "# color tables: https://ascent.readthedocs.io/en/latest/Actions/VTKmColorTables.html\n", + "-\n", + " action: \"add_scenes\"\n", + " scenes:\n", + " scene1:\n", + " plots:\n", + "# p0:\n", + "# type: \"pseudocolor\"\n", + "# field: \"particle_electrons_uz\"\n", + "# pipeline: \"sampled_particles\"\n", + " p1:\n", + " type: \"pseudocolor\"\n", + " field: \"Ez\"\n", + " pipeline: \"clipped_volume\"\n", + "# color_table: \n", + "# name: \"plasma\"\n", + "# reverse: true\n", + "# control_points: \n", + "# - \n", + "# type: \"alpha\"\n", + "# position: 0.0\n", + "# alpha: 0.5\n", + "# - \n", + "# type: \"alpha\"\n", + "# position: 1.0\n", + "# alpha: 0.5\n", + "# p2:\n", + "# type: \"pseudocolor\"\n", + "# field: \"E_mag\"\n", + "# pipeline: \"mag_clipped_volume_E\"\n", + "# color_table: \n", + "# name: \"Black-Body Radiation\"\n", + "# reverse: true\n", + " #p3:\n", + " # type: \"pseudocolor\"\n", + " # field: \"Ez\"\n", + " # pipeline: \"slice_field\"\n", + " # min_value: -3.0e11\n", + " # max_value: 3.0e11\n", + " renders:\n", + " image1:\n", + " image_width: 512\n", + " image_height: 512\n", + " bg_color: [1.0, 1.0, 1.0]\n", + " fg_color: [0.0, 0.0, 0.0]\n", + " image_prefix: \"./replay_%06d\"\n", + " camera:\n", + " azimuth: -70\n", + " elevation: 30\n", + " zoom: 1.5" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rerender()\n", + "ascent.jupyter.AscentViewer(a).show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#!ls *png" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Image(filename=\"lwfa_Ex_e-uz_000400.png\")\n", + "# print(conduit.about())" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 04d180974912e79b69219c597ace654ab69c450f Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 28 Oct 2020 02:42:21 +0100 Subject: [PATCH 30/30] deleted some useless end-of-line ';' (#1478) --- .../QEDInternals/BreitWheelerEngineWrapper.H | 6 +++--- .../QEDInternals/QuantumSyncEngineWrapper.H | 6 +++--- Source/Particles/WarpXParticleContainer.H | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.H b/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.H index a73e2e17f45..bf305db1c96 100644 --- a/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.H +++ b/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.H @@ -70,7 +70,7 @@ public: * does not require control parameters or lookup tables. */ BreitWheelerGetOpticalDepth () - {}; + {} /** * () operator is just a thin wrapper around a very simple function to @@ -111,7 +111,7 @@ public: BreitWheelerEvolveOpticalDepth ( const BW_dndt_table_view table_view, const amrex::ParticleReal bw_minimum_chi_phot): - m_table_view{table_view}, m_bw_minimum_chi_phot{bw_minimum_chi_phot}{}; + m_table_view{table_view}, m_bw_minimum_chi_phot{bw_minimum_chi_phot}{} /** * Evolves the optical depth. It can be used on GPU. @@ -190,7 +190,7 @@ public: * @param[in] table_view a BW_pair_prod_table_view */ BreitWheelerGeneratePairs (const BW_pair_prod_table_view table_view): - m_table_view{table_view}{}; + m_table_view{table_view}{} /** * Generates pairs according to Breit Wheeler process. diff --git a/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.H b/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.H index ece636aad97..48f79e3e208 100644 --- a/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.H +++ b/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.H @@ -70,7 +70,7 @@ public: * does not require control parameters or lookup tables. */ QuantumSynchrotronGetOpticalDepth () - {}; + {} /** * () operator is just a thin wrapper around a very simple function to @@ -110,7 +110,7 @@ public: QuantumSynchrotronEvolveOpticalDepth ( const QS_dndt_table_view table_view, const amrex::ParticleReal qs_minimum_chi_part): - m_table_view{table_view}, m_qs_minimum_chi_part{qs_minimum_chi_part}{}; + m_table_view{table_view}, m_qs_minimum_chi_part{qs_minimum_chi_part}{} /** * Evolves the optical depth. It can be used on GPU. @@ -184,7 +184,7 @@ public: */ QuantumSynchrotronPhotonEmission ( const QS_phot_em_table_view table_view): - m_table_view{table_view}{}; + m_table_view{table_view}{} /** * Generates photons according to Quantum Synchrotron process. diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 2f22c78f1cc..d2c1f380e85 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -396,9 +396,9 @@ protected: //Species can receive a shared pointer to a QED engine (species for //which this is relevant should override these functions) virtual void - set_breit_wheeler_engine_ptr(std::shared_ptr){}; + set_breit_wheeler_engine_ptr(std::shared_ptr){} virtual void - set_quantum_sync_engine_ptr(std::shared_ptr){}; + set_quantum_sync_engine_ptr(std::shared_ptr){} int m_qed_breit_wheeler_ele_product; std::string m_qed_breit_wheeler_ele_product_name;