# ASAGI¶

The software package ASAGI can be used to map gridded simulation properties of the domain to the mesh used for a SeisSol simulation. ASAGI reads NetCDF files, which follow the COARDS Convention for netCDF files. This convention in particular states that:

“1-dimensional netCDF variables whose dimension names are identical to their variable names are regarded as “coordinate variables”.”

Here is an example of the structure of an ASAGI file (generated by ncdump -h test_ASAGI.nc), describing two 2D arrays (strike_slip and dip_slip) indexed by variables u and v.

netcdf test_ASAGI {
types:
compound material {
float strike_slip ;
float dip_slip ;
}; // material
dimensions:
u = 40 ;
v = 20 ;
variables:
float u(u) ;
float v(v) ;
material data(v, u) ;
}


Typically, 1D, 2D, and 3D ASAGI files are used in SeisSol setups.

## Installing ASAGI¶

Be careful that the python and gcc package is the same as for the compilation of SeisSol in a later step!

### example on SuperMuc¶

module load mpi.intel/2019

• get the repository

On a cluster without restricted access to outside sources, you could then clone the repository using:

git clone --recursive https://github.com/TUM-I5/ASAGI.github


On supermuc, you have to set up port forwarding as described in Compiling and running SeisSol on Supermuc.

Then you can clone the project with

git clone git@github.com:TUM-I5/ASAGI.git


followed by running fix_submodules to clone and set up the submodules.

• set compiler options:
export FC=mpif90
export CXX=mpiCC
export CC=mpicc

• install:
mkdir build
cd build
export CMAKE_PREFIX_PATH=\$NETCDF_BASE
cmake ../ -DCMAKE_INSTALL_PREFIX=<path_to_ASAGI>/build
make -j8
make install

• set the following paths
export PKG_CONFIG_PATH=<path_to_ASAGI>/build/lib/pkgconfig
export LD_LIBRARY_PATH=<path_to_ASAGI>/build/lib


## building SeisSol with ASAGI support¶

Simply turn on the option ASAGI=ON in the using ccmake.

## generating the NetCDF input file¶

### using python¶

The most straightforward way to generate ASAGI file is to use the netCDF4 module of python. A typical example which generates a 2D ASAGI file can be found here.

### using asagiconv¶

Asagiconv (Located here) allows querying data, vizualising and exporting to NetCDF data from the 3D Velocity Model for Southern California. For more detail, see ASAGI docu.

### velocity models given as structured grids¶

Asagi expects a 1D, 2D, 3D (or higher dimensions) structured grid NetCDF files. Such files can be generated from an ASCII file using the command: ncgen -b asagi_example.txt
Here is a typical example for the ASCII file:
netcdf asagi_example {
types:
compound material {
float rho ;
float mu ;
float lambda ;
}; // material
dimensions:
x = 3 ; // Number of points in x-direction
y = 2 ; // Number of points in y-direction
z = 1 ; // Number of points in z-direction
variables:
float x(x) ;
float y(y) ;
float z(z);
material data(z, y, x) ;
data:
x = 2, 2.5, 3 ; // Grid points in x-direction (must have the same spacing)
y = -1, 0 ; // Grid points in y-direction (must have the same spacing)
z = 0 ; // Grid points in z-direction (must have the same spacing)

data =
{1, -1, 10}, // rho,mu,lambda for x0, y0, z0
{2, -2, 11}, // rho,mu,lambda for x1, y0, z0
{3, -3, 12}, // rho,mu,lambda for x2, y0, z0
{4, -4, 13}, // rho,mu,lambda for x0, y1, z0
{5, -5, 14}, // rho,mu,lambda for x1, y1, z0
{6, -6, 15} ; // rho,mu,lambda for x2, y1, z0
}


## SeisSol parameter file¶

A simple example file setting the elastic properties using EASI can be found here.

Such a file would be called adding in the namelist equation:

MaterialFileName = 101_asagi.yaml


In this example, the ASAGI file describes 2D arrays. The AffineMap is therefore needed to define the unit vectors used for indexing the 2D arrays. Note that the variables in the affine map can have different names than x, y or z (actually it should be preferred to avoid confusion). An AffineMap may also be used for 3D arrays, in case the coordinates variables are not aligned with the Cartesian coordinate system.

## Further information¶

For further information, the use of asagiconv and asagi and its compilation, please see: ASAGI docu.

## Known issues¶

There is a bug when using ASAGI with MPI. A workaround is described in https://github.com/SeisSol/SeisSol/issues/46.