ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
main.cpp File Reference
#include <iostream>
#include <AMReX.H>
#include <AMReX_BLProfiler.H>
#include <AMReX_ParallelDescriptor.H>
#include "ERF.H"
Include dependency graph for main.cpp:

Functions

void add_par ()
 
int main (int argc, char *argv[])
 

Variables

std::string inputs_name
 

Function Documentation

◆ add_par()

void add_par ( )

Function to set the refine_grid_layout flags to (1,1,0) by default since the ERF default is different from the amrex default (1,1,1) Also set max_grid_size to very large since the only reason for chopping grids is if Nprocs > Ngrids

24  {
25  ParmParse pp("amr");
26 
27  // Set the refine_grid_layout flags to (1,1,0) by default
28  pp.add("refine_grid_layout_x",1);
29  pp.add("refine_grid_layout_y",1);
30  pp.add("refine_grid_layout_z",0);
31 
32  // n_proper is the minimum number of coarse cells between coarse-fine boundaries
33  // between levels (ell and ell+1) and levels (ell-1 and ell). We want this to be
34  // greater than or equal to the stencil width (a function of spatial order) divided by
35  // ref_ratio (which can be 2,3 or 4). This ensures that fillpatch at level (ell)
36  // does not need to reach beyond level (ell-1). Here to be conservative we set this to 2
37  // (rather than the amrex default of 1).
38  pp.add("n_proper",2);
39 
40  int max_grid_size = 2048;
41  pp.queryAdd("max_grid_size",max_grid_size);
42 
43  // This will set the default value of blocking_factor to be 1, but will allow
44  // the user to override it in the inputs file or on command line
45  int blocking_factor = 1;
46  pp.queryAdd("blocking_factor",blocking_factor);
47 
48  int n_error_buf = 0;
49  pp.queryAdd("n_error_buf",n_error_buf);
50 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:230

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main driver – creates the ERF object, calls ERF.InitData() and ERF.Evolve()

56 {
57 
58 #if defined(AMREX_MPI_THREAD_MULTIPLE)
59  int requested = MPI_THREAD_MULTIPLE;
60  int provided = -1;
61  MPI_Init_thread(&argc, &argv, requested, &provided);
62 #elif defined(AMREX_USE_MPI)
63  MPI_Init(&argc, &argv);
64 #endif
65 
66  if (argc < 2) {
67  // Print usage and exit with error code if no input file was provided.
68  ERF::print_usage(MPI_COMM_WORLD, std::cout);
70  MPI_COMM_WORLD, "No input file provided. Exiting!!");
71  return 1;
72  }
73 
74  // Look for "-h" or "--help" flag and print usage
75  for (auto i = 1; i < argc; i++) {
76  const std::string param(argv[i]);
77  if ((param == "--help") || (param == "-h") || (param == "--usage")) {
78  ERF::print_banner(MPI_COMM_WORLD, std::cout);
79  ERF::print_usage(MPI_COMM_WORLD, std::cout);
80  return 0;
81  }
82  }
83 
84  if (!amrex::FileSystem::Exists(std::string(argv[1]))) {
85  // Print usage and exit with error code if we cannot find the input file
86  ERF::print_usage(MPI_COMM_WORLD, std::cout);
88  MPI_COMM_WORLD, "Input file does not exist = " +
89  std::string(argv[1]) + ". Exiting!!");
90  return 1;
91  }
92 
93  // print_banner(MPI_COMM_WORLD, std::cout);
94  // Check to see if the command line contains --describe
95  if (argc >= 2) {
96  for (auto i = 1; i < argc; i++) {
97  if (std::string(argv[i]) == "--describe") {
98  ERF::writeBuildInfo(std::cout);
99  return 0;
100  }
101  }
102  }
103 #ifdef ERF_USE_WW3_COUPLING
104  MPI_Comm comm = amrex::MPMD::Initialize(argc, argv);
105  amrex::Initialize(argc,argv,true,comm,add_par);
106 #else
107  amrex::Initialize(argc,argv,true,MPI_COMM_WORLD,add_par);
108 #endif
109 
110 #ifdef ERF_USE_KOKKOS
111  // Initialize kokkos
112  if (!Kokkos::is_initialized()) { Kokkos::initialize(); }
113 #endif
114 
115  // Save the inputs file name for later.
116  if (!strchr(argv[1], '=')) {
117  inputs_name = argv[1];
118  }
119 
120  // timer for profiling
121  BL_PROFILE_VAR("main()", pmain);
122 
123  // wallclock time
124  const Real strt_total = amrex::second();
125 
126  {
127  // constructor - reads in parameters from inputs file
128  // - sizes multilevel arrays and data structures
129  ERF erf;
130 
131  // initialize AMR data
132  erf.InitData();
133 
134  // advance solution to final time
135  erf.Evolve();
136 
137  // wallclock time
138  Real end_total = amrex::second() - strt_total;
139 
140  // print wallclock time
141  ParallelDescriptor::ReduceRealMax(end_total ,ParallelDescriptor::IOProcessorNumber());
142  if (erf.Verbose()) {
143  amrex::Print() << "\nTotal Time: " << end_total << '\n';
144  }
145  }
146 
147  // destroy timer for profiling
148  BL_PROFILE_VAR_STOP(pmain);
149 #ifdef ERF_USE_WW3_COUPLING
150  MPI_Barrier(MPI_COMM_WORLD);
151 #endif
152 
153 #ifdef ERF_USE_KOKKOS
154  Kokkos::finalize();
155 #endif
156 
157  amrex::Finalize();
158 #ifdef AMREX_USE_MPI
159 #ifdef ERF_USE_WW3_COUPLING
160  amrex::MPMD::Finalize();
161 #else
162  MPI_Finalize();
163 #endif
164 #endif
165 }
amrex::Real Real
Definition: ERF_ShocInterface.H:16
Definition: ERF.H:111
void Evolve()
Definition: ERF.cpp:477
static void print_banner(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:60
void InitData()
Definition: ERF.cpp:772
static void print_error(MPI_Comm, const std::string &msg)
Definition: ERF_ConsoleIO.cpp:43
static void writeBuildInfo(std::ostream &os)
Definition: ERF_WriteJobInfo.cpp:137
static void print_usage(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:26
void add_par()
Definition: main.cpp:24
std::string inputs_name
Definition: main.cpp:14
Here is the call graph for this function:

Variable Documentation

◆ inputs_name

std::string inputs_name

Referenced by main(), and ERF::writeJobInfo().