# Workflow Overview

This section gives a brief overview of the typical workflow for MARE2DEM. The suite of MARE2DEM codes consists of three parts:

A MATLAB user interface and other routines for building forward and inverse model and preparing data files

The core MARE2DEM code (written in MPI-Fortran and C) for the finite element modeling and inversion of EM responses

MATLAB routines for interactive plotting of inversion models and viewing EM responses and data fits

The typical workflow is outline in the image below:

Input data consists of the transmitters and receivers and response frequencies and any topography and other geologic surfaces that will be incorporated into the model.

In MATLAB, the data parameters (and any EM responses to be inverted) can be written to a MARE2DEM format data file using

`m2d_writeEMData2DFile.m`

. A resistivity model (and possibly an inversion mesh) is built using the interactive`Mamba2D.m`

graphical user interface.The MARE2DEM executable code is run for forward or inverse modeling.

Results are viewed in MATLAB using

`plotMARE2DEM.m`

.For inversion, the resulting model and data fits are inspected and if deemed insufficient, the model parameterization is revised and outlier or noisy data are trimmed and the workflow is repeated.

## Input Files

There are four input files required to run MARE2DEM for forward
modeling; a fifth file is needed for inversion. They are all created by
`Mamba2D.m`

except for the data file. For a model named `demo`

, the
following files are needed:

`demo.0.resistivity`

specifies the resistivity of each model parameter region and whether or not the parameter is fixed or an inversion free parameter, the resistivity anisotropy setting, inversion parameter resistivity bounds and prejudices (if any), and lists the names of the other required files. The file extension 0 specifies the inversion iteration number; 0 means this is is a starting model. When running inversions, a new resistivity file is output for each iteration of the inversion and this number will indicate the inversion iteration.`demo.poly`

specifies the geometry of the model parameter grid (nodes and segments connecting them)`demo.penalty`

contains the inversion’s roughness penalty matrix (only needed for inversion).`demo.emdata`

specifies the sources, receivers and frequencies to be modeled as well the type of data and any real data to be inverted.`mare2dem.settings`

specifies various runtime settings for MARE2DEM, including the accuracy tolerance for EM responses generated by the automatic adaptive mesh refinement, and how the data should be decomposed into subsets for parallel computations.

See the section File Formats section for further details.

## Creating Input Models

Note

No meshing or gridding is needed for forward modeling. Just draw the
desired model structure and assign resistivity values to each
segment bound region, save the files and let MARE2DEM do the rest.
When you run MARE2DEM, it will load in the model that you created
with `Mamba2D.m`

and then MARE2DEM automatically generates
adaptive finite element meshes that conform to the model geometry
and that are iteratively refined to give accurate EM responses for
the particular transmitters and receivers being modeled. All finite
element meshing and refinement in MARE2DEM is done internally behind
the scenes while it runs and these dynamically generated meshes are
not saved to files.

## Running MARE2DEM

After the input files have been created, MARE2DEM can be run locally on your laptop or desktop if the modeling problem is small (a MT data set or a small CSEM problem), or the files can be transferred to a HPC cluster where MARE2DEM is run remotely (e.g., for large CSEM data sets).