ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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()

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