### Hello World C++ Example Source: https://amrex-codes.github.io/amrex/docs_html/GettingStarted.html A basic C++ program demonstrating the initialization, version printing, and finalization of the AMReX framework. ```cpp #include #include int main(int argc, char* argv[]) { amrex::Initialize(argc,argv); amrex::Print() << "Hello world from AMReX version " << amrex::Version() << "\n"; amrex::Finalize(); } ``` -------------------------------- ### Install AMReX via Spack Source: https://amrex-codes.github.io/amrex/docs_html/GettingStarted.html Command to install the AMReX framework using the Spack package manager. ```shell spack install amrex ``` -------------------------------- ### Build and Execute Heat Equation Solver Source: https://amrex-codes.github.io/amrex/docs_html/GettingStarted.html Steps to compile the heat equation example code for 2D dimensions and execute the resulting binary using an input parameter file. ```bash make DIM=2 ./main2d.gnu.ex inputs_2d ``` -------------------------------- ### Run AMReX Executable Source: https://amrex-codes.github.io/amrex/docs_html/GettingStarted.html Command to execute the compiled AMReX binary generated by the build process. ```shell ./main3d.gnu.DEBUG.ex ``` -------------------------------- ### Build BoxArray and DistributionMapping in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Demonstrates initializing a BoxArray from a box, setting grid constraints, and building a DistributionMapping. ```Fortran integer :: n_cell type(amrex_box) :: domain type(amrex_boxarray) : ba type(amrex_distromap) :: dm domain = amrex_box((/0,0,0/), (/n_cell-1, n_cell-1, n_cell-1/)) call amrex_boxarray_build(ba, domain) call ba%maxSize(max_grid_size) call amrex_distromap_build(dm, ba) call amrex_distromap_distromap(dm) call amrex_boxarray_destroy(ba) ``` -------------------------------- ### Run Parallel AMReX Executables Source: https://amrex-codes.github.io/amrex/docs_html/GettingStarted.html Commands to execute AMReX applications configured with MPI, OpenMP, or a hybrid of both. These commands demonstrate how to set environment variables and utilize mpiexec for process management. ```bash mpiexec -n 4 ./main3d.gnu.DEBUG.MPI.ex amrex.v=1 OMP_NUM_THREADS=4 ./main3d.gnu.DEBUG.OMP.ex OMP_NUM_THREADS=4 mpiexec -n 2 ./main3d.gnu.DEBUG.MPI.OMP.ex ``` -------------------------------- ### Construct and Manage MultiFab in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Illustrates building standard and nodal MultiFab objects and performing cleanup. ```Fortran integer :: ncomp, nghost type(amrex_boxarray) : ba type(amrex_distromap) :: dm type(amrex_multifab) :: mf, ndmf call amrex_multifab_build(mf, ba, dm, ncomp, nghost) call amrex_multifab_build(ndmf,ba,dm,ncomp,nghost,(/.true.,.true.,.true./)) call amrex_multifab_destroy(mf) call amrex_multifab_destroy(ndmf) ``` -------------------------------- ### Build AMReX using CMake Source: https://amrex-codes.github.io/amrex/docs_html/_sources/BuildingAMReX.rst.txt This console snippet outlines the process of building and installing AMReX using CMake. It involves creating a build directory, navigating into it, running CMake with configuration options (like build type and install prefix), and then executing 'make install' to complete the installation. An optional 'make test_install' step is also shown. ```console mkdir /path/to/builddir cd /path/to/builddir cmake [options] -DCMAKE_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel] -DCMAKE_INSTALL_PREFIX=/path/to/installdir /path/to/amrex make install make test_install # optional step to test if the installation is working ``` -------------------------------- ### Install yt with Conda and Pip Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Visualization.rst.txt This console command sequence illustrates how to set up a Python environment using Anaconda at NERSC, install the yt library, and activate the environment. This is a prerequisite for using yt interactively with Jupyter notebooks on the Cori system. ```console module load python/3.5-anaconda conda create -p $HOME/yt-conda numpy source activate $HOME/yt-conda pip install yt ``` -------------------------------- ### ParmParse TOML-like configuration examples Source: https://amrex-codes.github.io/amrex/docs_html/Basics.html Examples illustrating key-value assignment, array syntax, and table header structures within the ParmParse input format. ```text # Allowed in ParmParse, but do NOT do this if TOML compatibility is needed. a = 1 a = 2 ``` ```text a = [3+4, 5+6] # Not allowed b = 3+4 5+6 # Allowed in ParmParse, but not in TOML. Same as b = [7,11]. ``` ```text k = 1 p.k = 2 [a] k = 3 # the full key/pair is a.k = 3 b.k = 4 # the full key/pair is a.b.k = 4 [b.c] k = 5 # the full key/pair is b.c.k = 5 d.e.k = 6 # the full key/pair is b.c.d.e.k = 6 ``` ```text # Allowed in ParmParse, but do NOT do this if TOML compatibility is needed. [a] b = 1 [a.b] # a.b already defined c = 2 ``` ```text # Allowed in ParmParse, but do NOT do this if TOML compatibility is needed. [a] k = 1 [a] # [a] already defined b = 2 ``` -------------------------------- ### Install and Configure AMReX via Spack Source: https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html Commands to install the AMReX library using the Spack package manager. Includes basic installation, viewing configuration options, and advanced installation with specific build variants. ```bash spack install amrex ``` ```bash spack info amrex ``` ```bash spack install amrex@develop dimensions=2 +cuda cuda_arch=60 ``` -------------------------------- ### Build and Install AMReX with CMake Source: https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html Standard workflow for building AMReX using CMake, involving directory creation, configuration, and installation. This process supports various build types and custom installation prefixes. ```bash mkdir /path/to/builddir cd /path/to/builddir cmake [options] -DCMAKE_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel] -DCMAKE_INSTALL_PREFIX=/path/to/installdir /path/to/amrex make install make test_install ``` -------------------------------- ### AmrLevel Tutorial Setup Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Visualization.rst.txt A sequence of shell commands to clone the AMReX tutorials and prepare the environment for a SENSEI-Catalyst simulation run. ```bash ssh cori.nersc.gov cd $SCRATCH git clone https://github.com/AMReX-Codes/amrex.git git clone https://github.com/AMReX-Codes/amrex-tutorials.git cd amrex-tutorials/ExampleCodes/Amr/Advection_AmrLevel/Exec/SingleVortex module use /usr/common/software/sensei/modulefiles module load sensei/2.1.0-catalyst-shared source sensei_config vim GNUmakefile # USE_SENSEI_INSITU=TRUE make -j4 -f GNUmakefile vim inputs # sensei.enabled=1 ``` -------------------------------- ### Perform Parallel Communication on MultiFab Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Examples of using fill_boundary and parallel_copy procedures for MultiFab objects in Fortran. ```Fortran type(amrex_geometry) :: geom type(amrex_multifab) :: mf, mfsrc call mf%fill_boundary(geom) ! Fill all components call mf%fill_boundary(geom, 1, 3) ! Fill 3 components starting with component 1 call mf%parallel_copy(mfsrc, geom) ! Parallel copy from another multifab ``` -------------------------------- ### Specify Custom Compilers (Make) Source: https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html This example shows how to define custom compiler commands (`CXX`, `CC`, `FC`, `F90`) within the `Make.local` file. It includes conditional logic based on the `USE_MPI` variable to select either MPI wrappers or specific compiler versions like `g++-8`. ```makefile ifeq ($(USE_MPI),TRUE) CXX = mpicxx CC = mpicc FC = mpif90 F90 = mpif90 else CXX = g++-8 CC = gcc-8 FC = gfortran-8 F90 = gfortran-8 endif ``` -------------------------------- ### ParmParse Configuration Syntax Examples Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Illustrates the behavior of variable overwriting, array definitions, and table scoping in the ParmParse configuration format. ```python # Variable overwriting a = 1 a = 2 # Array definition b = 3+4 5+6 # Same as b = [7,11] # Table scoping [a] k = 3 # a.k = 3 b.k = 4 # a.b.k = 4 ``` -------------------------------- ### Define Geometry and Domain in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Shows how to define a physical domain using an amrex_box and build an amrex_geometry object. ```Fortran integer :: n_cell type(amrex_box) :: domain type(amrex_geometry) : geom ! Define a single box covering the domain domain = amrex_box((/0,0,0/), (/n_cell-1, n_cell-1, n_cell-1/)) ! This defines a amrex_geometry object. call amrex_geometry_build(geom, domain) call amrex_geometry_destroy(geom) ``` -------------------------------- ### Setting Up Boundary Conditions in C++ Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Illustrates how to set up boundary conditions for a MultiFab in C++ using the BCRec object. It shows how to define different boundary types (interior, extrapolation) for each component and direction, considering periodic boundaries. ```c++ // Set up BC; see ``amrex/Src/Base/AMREX_BC_TYPES.H`` for supported types Vector bc(phi.nComp()); for (int n = 0; n < phi.nComp(); ++n) { for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { if (geom.isPeriodic(idim)) { bc[n].setLo(idim, BCType::int_dir); // interior bc[n].setHi(idim, BCType::int_dir); } else { bc[n].setLo(idim, BCType::foextrap); // first-order extrapolation bc[n].setHi(idim, BCType::foextrap); } } } ``` -------------------------------- ### AMR Lifecycle Management in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Demonstrates the standard initialization and finalization sequence for an AMReX-based Fortran application, including user-defined hooks. ```Fortran program main use amrex_amr_module implicit none call amrex_init() call amrex_amrcore_init() call my_amr_init() ! user's own code, not part of AMReX ! ... call my_amr_finalize() ! user's own code, not part of AMReX call amrex_amrcore_finalize() call amrex_finalize() end program main ``` -------------------------------- ### Iterating over AMReX Multifab with Tiling in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Demonstrates how to use `amrex_mfiter` to loop over `amrex_multifab` data with tiling enabled. It shows how to obtain tile boxes, access data pointers, and call a subroutine to update the data. The component index for `amrex_multifab` starts at 1 in Fortran. ```Fortran integer :: plo(4), phi(4) type(amrex_box) :: bx real(amrex_real), contiguous, dimension(:,:,:,:), pointer :: po, pn type(amrex_multifab) :: old_phi, new_phi type(amrex_mfiter) :: mfi ! Define old_phi and new_phi ... ! In this example they are built with the same boxarray and distromap. ! And they have the same number of ghost cells and 1 component. call amrex_mfiter_build(mfi, old_phi, tiling=.true.) do while (mfi%next()) bx = mfi%tilebox() po => old_phi%dataptr(mfi) pn => new_phi%dataptr(mfi) plo = lbound(po) phi = ubound(po) call update_phi(bx%lo, bx&hi, po, pn, plo, phi) end do call amrex_mfiter_destroy(mfi) ``` -------------------------------- ### Create and Configure yt Scene for Visualization Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Visualization.rst.txt This Python snippet demonstrates how to create a visualization scene using the yt library, set a specific field for visualization, configure transfer function bounds and opacity, and display the scene. It's useful for initial data exploration and setting up plots. ```python sc = yt.create_scene(ds, field="density", lens_type="perspective") source = sc[0] source.tfh.set_bounds((1e8, 1e15)) source.tfh.set_log(True) source.tfh.grey_opacity = True sc.show() ``` -------------------------------- ### Setting AMReX Home Directory in Tcsh Source: https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html Illustrates how to set the AMREX_HOME environment variable in Tcsh, similar to the Bash example. This variable is essential for the GNUmakefile to find the AMReX installation path. ```tcsh setenv AMREX_HOME /path/to/amrex ``` -------------------------------- ### Constructing and Defining DistributionMapping in C++ Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Demonstrates how to initialize a DistributionMapping object using a BoxArray, copying an existing mapping, or manually defining one via a process ID array. ```cpp DistributionMapping dm {ba}; DistributionMapping dm {another_dm}; DistributionMapping dm; // empty object Vector pmap {...}; // The user fills the pmap array with the values specifying owner processes dm.define(pmap); // Build DistributionMapping given an array of process IDs. ``` -------------------------------- ### Converting C Pointer to TagBoxArray Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Shows how to cast a C pointer received in the error estimation callback into a native Fortran amrex_tagboxarray object. ```Fortran type(amrex_tagboxarray) :: tag tag = tags ``` -------------------------------- ### Configure SYCL build options in GNU Make Source: https://amrex-codes.github.io/amrex/docs_html/GPU.html These are example configurations for building AMReX with SYCL support using GNU Make. They demonstrate setting SYCL-specific variables like ahead-of-time compilation, register file mode, and oneDPL usage. ```makefile # Example SYCL configuration variables SYCL_AOT=TRUE SYCL_AOT_GRF_MODE=Large AMREX_INTEL_ARCH=pvc SYCL_SPLIT_KERNEL=TRUE USE_ONEDPL=YES SYCL_SUB_GROUP_SIZE=64 SYCL_PARALLEL_LINK_JOBS=2 ``` -------------------------------- ### Initialize and Query ParmParse in Fortran Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Demonstrates how to build a ParmParse object, query integer parameters, and destroy the object to prevent memory leaks. ```Fortran type(amrex_parmparse) :: pp integer :: n_cell, max_grid_size call amrex_parmparse_build(pp) call pp%get("n_cell", n_cell) max_grid_size = 32 ! default size call pp%query("max_grid_size", max_grid_size) call amrex_parmpase_destroy(pp) ! optional if compiler supports finalization ``` -------------------------------- ### AMR Callback Procedure Interfaces Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Provides the required procedure signatures for level management and error estimation, utilizing C-binding for interoperability with the AMReX C++ core. ```Fortran subroutine amrex_make_level_proc (lev, time, ba, dm) bind(c) import implicit none integer, intent(in), value :: lev real(amrex_real), intent(in), value :: time type(c_ptr), intent(in), value :: ba, dm end subroutine amrex_make_level_proc subroutine amrex_clear_level_proc (lev) bind(c) import implicit none integer, intent(in) , value :: lev end subroutine amrex_clear_level_proc subroutine amrex_error_est_proc (lev, tags, time, tagval, clearval) bind(c) import implicit none integer, intent(in), value :: lev type(c_ptr), intent(in), value :: tags real(amrex_real), intent(in), value :: time character(c_char), intent(in), value :: tagval, clearval end subroutine amrex_error_est_proc ``` -------------------------------- ### Reading Basic Parameters with ParmParse Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Demonstrates how to read arrays, strings, and prefixed parameters using ParmParse. It shows the difference between 'get' and 'query' for error handling and how to use prefixes for namespacing. ```c++ pp.getarr("ncells", numcells); amrex::Print() << numcells.size() << "\n"; // 3 Vector xr {-1.0, 1.0}; if (!pp.queryarr("xrange", xr)) { amrex::Print() << "Cannot find xrange in inputs, " << "so the default {-1.0,1.0} will be used\n"; } std::string title; pp.query("title", title); // query string ParmParse pph("hydro"); // with prefix 'hydro' Real cfl; pph.get("cfl", cfl); // get parameter with prefix std::vector> my_2d_table; pp.gettable("my_2d_table", my_2d_table); ``` -------------------------------- ### Registering Virtual Functions for AMR Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Defines the interface for registering callback procedures required by AMReX to manage mesh levels, including creation, clearing, and error estimation. ```Fortran subroutine amrex_init_virtual_functions (mk_lev_scrtch, mk_lev_crse, & mk_lev_re, clr_lev, err_est) procedure(amrex_make_level_proc) :: mk_lev_scrtch procedure(amrex_make_level_proc) :: mk_lev_crse procedure(amrex_make_level_proc) :: mk_lev_re procedure(amrex_clear_level_proc) :: clr_lev procedure(amrex_error_est_proc) :: err_est end subroutine amrex_init_virtual_functions ``` -------------------------------- ### Initialize and Finalize AMReX Fortran Program Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html A basic Fortran program demonstrating the initialization and finalization of the AMReX environment. It uses the amrex_base_module to print a message from the IO processor. ```fortran program main use amrex_base_module implicit none call amrex_init() if (amrex_parallel_ioprocessor()) then print *, "Hello world!" end if call amrex_finalize() end program main ``` -------------------------------- ### Construct MultiFab Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Shows different methods for initializing a MultiFab, including direct constructor usage and the define method for deferred initialization. ```c++ // Direct construction int ncomp = 4; int ngrow = 1; MultiFab mf(ba, dm, ncomp, ngrow); // Deferred definition MultiFab mf; mf.define(ba, dm, ncomp, ngrow); ``` -------------------------------- ### Initialize and Finalize Octree Grids (Fortran) Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Demonstrates the required procedure calls for initializing and finalizing octree grids in AMReX using the `amrex_octree_module`. `amrex_octree_init` must be called before `amrex_amrcore_init`. ```Fortran program main use amrex_amrcore_module use amrex_octree_module implicit none call amrex_init() call amrex_octree_int() ! This should be called before amrex_amrcore_init. call amrex_amrcore_init() call my_amr_init() ! user's own code, not part of AMReX ! ... call my_amr_finalize() ! user's own code, not part of AMReX call amrex_amrcore_finalize() call amrex_octree_finalize() call amrex_finalize() end program main ``` -------------------------------- ### Enable OpenMP Support in AMReX Build Source: https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html This example demonstrates how to enable OpenMP support during the AMReX build process using CMake. It specifies the AMReX_OMP variable to 'YES' and sets an installation prefix. This is useful for parallelizing computations on multi-core processors. ```bash cmake -DAMReX_OMP=YES -DCMAKE_INSTALL_PREFIX=/path/to/installdir /path/to/amrex ``` -------------------------------- ### ParmParse: Input File Example Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Demonstrates the format of an AMReX input file, including definitions for integers, floating-point numbers, lists, strings, nested structures with prefixes, and multi-line tables. ```python nsteps = 100 # integer nsteps = 1000 # nsteps appears a second time dt = 0.03 # floating point number ncells = 128 64 32 # a list of 3 ints xrange = -0.5 0.5 # a list of 2 reals title = "Three Kingdoms" # a string hydro.cfl = 0.8 # with prefix, hydro my_2d_table = \ # col 1 2 3 {{ 11.0, 12.0, 13.0 } # row 1 { 21.0, 22.0, 23.0 } # row 2 { 31.0, 32.0, 33.0 } # row 3 { 41.0, 42.0, 43.0 } } # row 4 # or my_2d_table = # col 1 2 3 {{ 11, 12, 13 } # row 1 { 21, 22, 23 } # row 2 { 31, 32, 33 } # row 3 { 41, 42, 43 } } # row 4 # or my_2d_table = # col 1 2 3 {{ 11, 12, 13 }, # row 1 { 21, 22, 23 }, # row 2 { 31, 32, 33 }, # row 3 { 41, 42, 43 } } # row 4 ``` -------------------------------- ### Iterate Over Octree Grid Leaves (Fortran) Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Shows how to use `amrex_octree_iter` to iterate over the leaves of an octree grid. It retrieves the level, grid index, and box for each leaf, and accesses the corresponding data pointer. ```Fortran type(amrex_octree_iter) :: oti type(multifab) :: phi_new(*) integer :: ilev, igrd type(amrex_box) :: bx real(amrex_real), contiguous, pointer, dimension(:,:,:,:) :: pout call amrex_octree_iter_build(oti) do while(oti%next()) ilev = oti%level() igrd = oti%grid_index() bx = oti%box() pout => phi_new(ilev)%dataptr(igrd) ! ... end do call amrex_octree_iter_destroy(oti) ``` -------------------------------- ### Fortran Multifab Assignment and Ownership Transfer Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html Illustrates how assignment (`=`) works for `amrex_multifab` in Fortran, resulting in a shallow copy and potential data loss if not managed carefully. It also shows the use of the `move` procedure to explicitly transfer data ownership, preventing unintended data destruction. ```Fortran type(amrex_multifab) :: mf1, mf2 call amrex_multifab_build(mf1, ...) call amrex_multifab_build(mf2, ...) ! At this point, both mf1 and mf2 are data owners mf2 = mf1 ! This will destroy the original data in mf2. ! Then mf2 becomes a shallow copy of mf1. ! mf1 is still the owner of the data. call amrex_multifab_destroy(mf1) ! mf2 no longer contains a valid pointer because mf1 has been destroyed. call amrex_multifab_destroy(mf2) ! But we still need to destroy it. ``` ```Fortran type(amrex_multifab) :: mf1, mf2 call amrex_multifab_build(mf1, ...) call mf2%move(mf1) ! mf2 is now the data owner and mf1 is not. call amrex_multifab_destroy(mf1) call amrex_multifab_destroy(mf2) ``` -------------------------------- ### C++ Hello World Example with AMReX Initialization and Finalization Source: https://amrex-codes.github.io/amrex/docs_html/_sources/GettingStarted.rst.txt A basic C++ program demonstrating the core AMReX structure. It includes initialization and finalization functions, prints a 'Hello world' message, and displays the AMReX version. Requires AMReX header files. ```c++ #include #include int main(int argc, char* argv[]) { amrex::Initialize(argc,argv); amrex::Print() << "Hello world from AMReX version " << amrex::Version() << "\n"; amrex::Finalize(); } ``` -------------------------------- ### Scoped Timer with BL_PROFILE in C++ Source: https://amrex-codes.github.io/amrex/docs_html/AMReX_Profiling_Tools.html This C++ example shows how to use the `BL_PROFILE` macro as a scoped timer in AMReX. The timer automatically starts when the macro is called and stops when the object goes out of scope (at the end of the enclosing block or function). This is ideal for timing entire functions or code blocks cleanly. ```cpp void YourClass::YourFunction() { BL_PROFILE("YourClass::YourFunction()"); // Timer starts here. < Your Function Code Block> } // <------ Timer goes out of scope here, calling stop and returning the function time. ``` -------------------------------- ### Configure and Build AMReX with SENSEI Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Visualization.rst.txt Commands to set up the SENSEI environment and compile AMReX applications. Supports both standard Make and CMake build systems. ```bash source sensei_config make -j4 -f GNUmakefile ``` ```bash cmake -DAMReX_SENSEI=ON -DSENSEI_DIR=//cmake .. make -j4 -f GNUmakefile ``` -------------------------------- ### Fortran Subroutine for Updating Multifab Data Source: https://amrex-codes.github.io/amrex/docs_html/Fortran.html A Fortran subroutine `update_phi` designed to update data within an `amrex_multifab`. It takes spatial bounds, input and output data pointers, and array bounds as arguments. The data pointers are declared as `real(amrex_real)` and their bounds are determined using `lbound` and `ubound`. ```Fortran subroutine update_phi (lo, hi, pold, pnew, plo, phi) integer, intent(in) :: lo(3), hi(3), plo(3), phi(3) real(amrex_real),intent(in ) pold(plo(1):phi(1),plo(2):phi(2),plo(3):phi(3)) real(amrex_real),intent(inout) pnew(plo(1):phi(1),plo(2):phi(2),plo(3):phi(3)) ! ... end subroutine update_phi ``` -------------------------------- ### Initialize AMReX Environment Source: https://amrex-codes.github.io/amrex/docs_html/_sources/Basics.rst.txt Illustrates the mandatory initialization of the AMReX execution environment using MPI communicators and output streams. ```c++ void Initialize (MPI_Comm mpi_comm, std::ostream& a_osout = std::cout, std::ostream& a_oserr = std::cerr); ``` -------------------------------- ### AMReX Macro Launch Syntax (Correct) Source: https://amrex-codes.github.io/amrex/docs_html/GPU.html Provides a correct example for AMReX macro launches, demonstrating how to declare variables within the macro scope to avoid parsing errors. This ensures the macro correctly interprets the code block. ```c++ AMREX_PARALLEL_FOR_3D (bx, tbx, { Real a; <---- OK Real b; }); ```