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: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  // Save the inputs file name for later.
111  if (!strchr(argv[1], '=')) {
112  inputs_name = argv[1];
113  }
114 
115  // timer for profiling
116  BL_PROFILE_VAR("main()", pmain);
117 
118  // wallclock time
119  const Real strt_total = amrex::second();
120 
121  {
122  // constructor - reads in parameters from inputs file
123  // - sizes multilevel arrays and data structures
124  ERF erf;
125 
126  // initialize AMR data
127  erf.InitData();
128 
129  // advance solution to final time
130  erf.Evolve();
131 
132  // wallclock time
133  Real end_total = amrex::second() - strt_total;
134 
135  // print wallclock time
136  ParallelDescriptor::ReduceRealMax(end_total ,ParallelDescriptor::IOProcessorNumber());
137  if (erf.Verbose()) {
138  amrex::Print() << "\nTotal Time: " << end_total << '\n';
139  }
140  }
141 
142  // destroy timer for profiling
143  BL_PROFILE_VAR_STOP(pmain);
144 #ifdef ERF_USE_WW3_COUPLING
145  MPI_Barrier(MPI_COMM_WORLD);
146 #endif
147  amrex::Finalize();
148 #ifdef AMREX_USE_MPI
149 #ifdef ERF_USE_WW3_COUPLING
150  amrex::MPMD::Finalize();
151 #else
152  MPI_Finalize();
153 #endif
154 #endif
155 }
Definition: ERF.H:102
void Evolve()
Definition: ERF.cpp:452
static void print_banner(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:60
void InitData()
Definition: ERF.cpp:722
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().