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

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

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

Variable Documentation

◆ inputs_name

std::string inputs_name

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