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:219

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() Also includes the multiblock interface in the case where there is more than one ERF object

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