aboutsummaryrefslogtreecommitdiff
path: root/Source/main.cpp
blob: dc1a00e8b55b53c19ba3518b9e109ef91c35a720 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Copyright 2016-2020 Andrew Myers, Ann Almgren, Axel Huebl
 *                     David Grote, Jean-Luc Vay, Remi Lehe
 *                     Revathi Jambunathan, Weiqun Zhang
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */
#include "WarpX.H"

#include "Initialization/WarpXAMReXInit.H"
#include "Utils/MPIInitHelpers.H"
#include "Utils/WarpXUtil.H"
#include "Utils/WarpXProfilerWrapper.H"

#include <ablastr/warn_manager/WarnManager.H>

#include <AMReX.H>
#include <AMReX_Config.H>
#include <AMReX_ParallelDescriptor.H>
#include <AMReX_Print.H>
#include <AMReX_REAL.H>
#include <AMReX_TinyProfiler.H>
#include <AMReX_Utility.H>

#if defined(AMREX_USE_MPI)
#  include <mpi.h>
#endif

#if defined(AMREX_USE_HIP) && defined(WARPX_USE_PSATD)
// cstddef: work-around for ROCm/rocFFT <=4.3.0
// https://github.com/ROCmSoftwarePlatform/rocFFT/blob/rocm-4.3.0/library/include/rocfft.h#L36-L42
#  include <cstddef>
#  include <rocfft.h>
#endif

int main(int argc, char* argv[])
{
    using namespace amrex;

    utils::warpx_mpi_init(argc, argv);

    warpx_amrex_init(argc, argv);

#if defined(AMREX_USE_HIP) && defined(WARPX_USE_PSATD)
    rocfft_setup();
#endif

    ParseGeometryInput();

    ConvertLabParamsToBoost();
    ReadBCParams();

#ifdef WARPX_DIM_RZ
    CheckGriddingForRZSpectral();
#endif

    {
        WARPX_PROFILE_VAR("main()", pmain);

        const auto strt_total = static_cast<Real>(amrex::second());

        WarpX warpx;

        warpx.InitData();

        warpx.Evolve();

        //Print warning messages at the end of the simulation
        ablastr::warn_manager::GetWMInstance().PrintGlobalWarnings("THE END");

        if (warpx.Verbose()) {
            auto end_total = static_cast<Real>(amrex::second()) - strt_total;
            ParallelDescriptor::ReduceRealMax(end_total, ParallelDescriptor::IOProcessorNumber());
            Print() << "Total Time                     : " << end_total << '\n';
        }

        WARPX_PROFILE_VAR_STOP(pmain);
    }

#if defined(AMREX_USE_HIP) && defined(WARPX_USE_PSATD)
    rocfft_cleanup();
#endif

    Finalize();
#if defined(AMREX_USE_MPI)
    MPI_Finalize();
#endif
}