YAC 3.8.0
Yet Another Coupler
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
read_icon_grid.c File Reference
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "read_icon_grid.h"
#include "utils_common.h"
#include "io_utils.h"
#include "geometry.h"
#include "read_grid.h"
#include <netcdf.h>
Include dependency graph for read_icon_grid.c:

Go to the source code of this file.

Functions

static int * get_icon_cell_mask (int ncid, size_t nbr_cells)
 
static void get_icon_connect (int ncid, size_t nbr_cells, int **vertex_of_cell, size_t *nv)
 
void yac_read_part_icon_grid_information (const char *filename, int *nbr_vertices, int *nbr_cells, int **num_vertices_per_cell, int **cell_to_vertex, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **global_cell_id, int **cell_mask, int **cell_core_mask, int **global_corner_id, int **corner_core_mask, int rank, int size)
 
void yac_read_icon_grid_information (const char *filename, int *nbr_vertices, int *nbr_cells, int **num_vertices_per_cell, int **cell_to_vertex, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **cell_mask)
 
static int partition_idx_from_element_idx (unsigned element_idx, unsigned num_elements, int num_partitions)
 
static void convert_to_rad (int ncid, int varid, double *array, size_t count)
 
void yac_read_icon_grid_information_parallel (const char *filename, MPI_Comm comm, int *nbr_vertices, int *nbr_cells, int **num_vertices_per_cell, int **cell_to_vertex, int **global_cell_ids, int **cell_owner, int **global_vertex_ids, int **vertex_owner, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **cell_msk)
 
void yac_read_icon_grid_information_parallel_f2c (const char *filename, MPI_Fint comm, int *nbr_vertices, int *nbr_cells, int **num_vertices_per_cell, int **cell_to_vertex, int **global_cell_ids, int **cell_owner, int **global_vertex_ids, int **vertex_owner, double **x_vertices, double **y_vertices, double **x_cells, double **y_cells, int **cell_msk)
 
static int * generate_simple_core_mask (size_t N)
 
static size_t * generate_offsets (size_t N, int *counts)
 
void yac_read_icon_grid_information_parallel_2 (const char *filename, MPI_Comm comm, double **x_vertices, double **y_vertices, yac_int **cell_ids, yac_int **vertex_ids, yac_int **edge_ids, size_t *num_cells, size_t *num_vertices, size_t *num_edges, int **num_vertices_per_cell, int **num_cells_per_vertex, size_t **cell_to_vertex, size_t **cell_to_edge, size_t **vertex_to_cell, size_t **edge_to_vertex, enum yac_edge_type **edge_type, double **x_cells, double **y_cells, int **cell_msk)
 
struct yac_basic_grid_data yac_read_icon_basic_grid_data_parallel (const char *filename, MPI_Comm comm)
 
void yac_read_icon_basic_grid_parallel_2 (char const *filename, char const *gridname, MPI_Comm comm, struct yac_basic_grid **basic_grid, size_t *cell_coordinate_idx, int **cell_mask)
 
struct yac_basic_gridyac_read_icon_basic_grid_parallel (char const *filename, char const *gridname, MPI_Comm comm)
 
struct yac_basic_gridyac_read_icon_basic_grid_parallel_f2c (char const *filename, char const *gridname, MPI_Fint comm)
 
struct yac_basic_grid_data yac_read_icon_basic_grid_data (char const *filename)
 
struct yac_basic_gridyac_read_icon_basic_grid (char const *filename, char const *gridname)
 
void yac_delete_icon_grid_data (int **cell_mask, int **global_cell_id, int **global_cell_id_rank, int **num_vertices_per_cell, int **global_corner_id, int **global_corner_id_rank, int **cell_to_vertex, double **x_cells, double **y_cells, double **x_vertices, double **y_vertices)
 

Function Documentation

◆ convert_to_rad()

static void convert_to_rad ( int ncid,
int varid,
double * array,
size_t count )
static

Definition at line 242 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_offsets()

static size_t * generate_offsets ( size_t N,
int * counts )
static

Definition at line 948 of file read_icon_grid.c.

Here is the caller graph for this function:

◆ generate_simple_core_mask()

static int * generate_simple_core_mask ( size_t N)
static

Definition at line 942 of file read_icon_grid.c.

Here is the caller graph for this function:

◆ get_icon_cell_mask()

static int * get_icon_cell_mask ( int ncid,
size_t nbr_cells )
static

Definition at line 1756 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_icon_connect()

static void get_icon_connect ( int ncid,
size_t nbr_cells,
int ** vertex_of_cell,
size_t * nv )
static

Definition at line 1794 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ partition_idx_from_element_idx()

static int partition_idx_from_element_idx ( unsigned element_idx,
unsigned num_elements,
int num_partitions )
inlinestatic

Definition at line 234 of file read_icon_grid.c.

Here is the caller graph for this function:

◆ yac_delete_icon_grid_data()

void yac_delete_icon_grid_data ( int ** cell_mask,
int ** global_cell_id,
int ** cell_core_mask,
int ** num_vertices_per_cell,
int ** global_corner_id,
int ** corner_core_mask,
int ** cell_to_vertex,
double ** x_cells,
double ** y_cells,
double ** x_vertices,
double ** y_vertices )

destroys remaining icon grid data

Parameters
[out]cell_maskmask for cells
[out]global_cell_idglobal cell IDs
[out]cell_core_maskcell core mask
[out]num_vertices_per_cellnumber of vertices per cell
[out]global_corner_idglobal corner IDs
[out]corner_core_maskcorner core mask
[out]cell_to_vertexvertex indices for each cell
[out]x_cellslongitudes of cell center
[out]y_cellslatitudes of cell center
[out]x_verticeslongitudes of vertices
[out]y_verticeslatitudes of vertices

Definition at line 1827 of file read_icon_grid.c.

◆ yac_read_icon_basic_grid()

struct yac_basic_grid * yac_read_icon_basic_grid ( char const * filename,
char const * gridname )

Reads in an icon grid netcdf file and generates a yac_basic_grid from it.

Parameters
[in]filenamename of the icon grid netcdf file
[in]gridnamename of the grid
Returns
yac_basic_grid structure that contains the icon grid

Definition at line 1746 of file read_icon_grid.c.

Here is the call graph for this function:

◆ yac_read_icon_basic_grid_data()

struct yac_basic_grid_data yac_read_icon_basic_grid_data ( char const * filename)

Reads in an icon grid netcdf file and generates a yac_basic_grid_data from it.

Parameters
[in]filenamename of the icon grid netcdf file
Returns
yac_basic_grid_data that contains the icon grid

Definition at line 1710 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_basic_grid_data_parallel()

struct yac_basic_grid_data yac_read_icon_basic_grid_data_parallel ( const char * filename,
MPI_Comm comm )

Reads in an icon grid netcdf file in parallel and returns a yac_basic_grid_data built from it.

Parameters
[in]filenamename of the icon grid netcdf file
[in]commMPI communicator containing all proceses that will get a part of the grid
Returns
yac_basic_grid_data structure containing part of the icon grid.
Remarks
The data of each process contains no halo cells.
See also
Configuration of parallel IO in YAC

Definition at line 1559 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_basic_grid_parallel()

struct yac_basic_grid * yac_read_icon_basic_grid_parallel ( char const * filename,
char const * gridname,
MPI_Comm comm )

Reads in an icon grid netcdf file in parallel and returns a yac_basic_grid built from it.

Parameters
[in]filenamename of the icon grid netcdf file
[in]gridnamename of grid
[in]commMPI communicator containing all proceses that will get a part of the grid
Returns
yac_basic_grid structure containing part of the icon grid.
Remarks
The data of each process contains no halo cells.
See also
Configuration of parallel IO in YAC

Definition at line 1693 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_basic_grid_parallel_2()

void yac_read_icon_basic_grid_parallel_2 ( char const * filename,
char const * gridname,
MPI_Comm comm,
struct yac_basic_grid ** grid,
size_t * cell_coordinate_idx,
int ** cell_mask )

Reads in an icon grid netcdf file in parallel and returns a yac_basic_grid built from it.

Parameters
[in]filenamename of the icon grid netcdf file
[in]gridnamename of grid
[in]commMPI communicator containing all proceses that will get a part of the grid
[out]gridyac_basic_grid structure containing part of the icon grid.
[out]cell_coordinate_idxpoints index at which the cell centers are registerd in the grid
[out]cell_maskmask for local cells (variable cell_sea_land_mask in icon grid file)
Remarks
If (cell_coordinate_idx == NULL) no cell center coordinates will be read.
If (cell_mask == NULL) no cell mask information will be read.
The data of each process contains no halo cells.
See also
Configuration of parallel IO in YAC

Definition at line 1619 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_basic_grid_parallel_f2c()

struct yac_basic_grid * yac_read_icon_basic_grid_parallel_f2c ( char const * filename,
char const * gridname,
MPI_Fint comm )

Definition at line 1702 of file read_icon_grid.c.

Here is the call graph for this function:

◆ yac_read_icon_grid_information()

void yac_read_icon_grid_information ( const char * filename,
int * num_vertices,
int * num_cells,
int ** num_vertices_per_cell,
int ** cell_to_vertex,
double ** x_vertices,
double ** y_vertices,
double ** x_cells,
double ** y_cells,
int ** cell_mask )

Reads in an icon grid netcdf file and return the grid information in a format that is supported by the YAC user interface.

Parameters
[in]filenamename of the icon grid netcdf file
[out]num_verticesnumber of vertices in the grid
[out]num_cellsnumber of cells in the grid
[out]num_vertices_per_cellnumber of vertices per cell
[out]cell_to_vertexvertex indices for each cell
[out]x_verticeslongitudes of vertices
[out]y_verticeslatitudes of vertices
[out]x_cellslongitudes of cell center
[out]y_cellslatitudes of cell center
[out]cell_maskmask for cells

Definition at line 181 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_grid_information_parallel()

void yac_read_icon_grid_information_parallel ( const char * filename,
MPI_Comm comm,
int * num_vertices,
int * num_cells,
int ** num_vertices_per_cell,
int ** cell_to_vertex,
int ** global_cell_ids,
int ** cell_owner,
int ** global_vertex_ids,
int ** vertex_owner,
double ** x_vertices,
double ** y_vertices,
double ** x_cells,
double ** y_cells,
int ** cell_mask )

Reads in an icon grid netcdf file and returns the grid information in a format that is supported by the YAC user interface. The reading is done in parallel and a basic domain decomposition is applied.

Parameters
[in]filenamename of the icon grid netcdf file
[in]commMPI communicator containing all proceses that will get a part of the grid
[out]num_verticesnumber of vertices in the local part of the grid
[out]num_cellsnumber of cells in the local part of the grid
[out]num_vertices_per_cellnumber of vertices per cell
[out]cell_to_vertexvertex indices for each cell
[out]global_cell_idsglobal ids of local cells (core and halo cells)
[out]cell_ownerowner of each cell (locally owned cells are marked with -1)
[out]global_vertex_idsglobal ids of local vertices (core and halo vertices)
[out]vertex_ownerowner of each vertex (locally owned vertices are marked with -1)
[out]x_verticeslongitudes of vertices
[out]y_verticeslatitudes of vertices
[out]x_cellslongitudes of cell center
[out]y_cellslatitudes of cell center
[out]cell_maskmask for cells (variable cell_sea_land_mask in icon grid file)
Remarks
The data of each process contains one layer of halo cells.
If (x_cells == NULL) && (y_cells == NULL) no cell center coordinates will be read.
If (cell_mask == NULL) no cell mask information will be read.
See also
Configuration of parallel IO in YAC

Definition at line 248 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_grid_information_parallel_2()

void yac_read_icon_grid_information_parallel_2 ( const char * filename,
MPI_Comm comm,
double ** x_vertices,
double ** y_vertices,
yac_int ** cell_ids,
yac_int ** vertex_ids,
yac_int ** edge_ids,
size_t * num_cells,
size_t * num_vertices,
size_t * num_edges,
int ** num_vertices_per_cell,
int ** num_cells_per_vertex,
size_t ** cell_to_vertex,
size_t ** cell_to_edge,
size_t ** vertex_to_cell,
size_t ** edge_to_vertex,
enum yac_edge_type ** edge_type,
double ** x_cells,
double ** y_cells,
int ** cell_mask )

Reads in an icon grid netcdf file and returns the grid information in a format that allows the user to set up a yac_basic_grid_data structure. The reading is done in parallel and a basic domain decomposition is applied.

Parameters
[in]filenamename of the icon grid netcdf file
[in]commMPI communicator containing all proceses that will get a part of the grid
[out]x_verticeslongitudes of vertices
[out]y_verticeslatitudes of vertices
[out]cell_idsglobal ids of local cells
[out]vertex_idsglobal ids of local vertices
[out]edge_idsglobal ids of local edges
[out]num_cellsnumber of cells in the local part of the grid
[out]num_verticesnumber of vertices in the local part of the grid
[out]num_edgesnumber of edges in the local part of the grid
[out]num_vertices_per_cellnumber of vertices per cell
[out]num_cells_per_vertexnumber of cells per vertex
[out]cell_to_vertexlocal vertex indices for each local cell
[out]cell_to_edgelocal edge indices for each local cell
[out]vertex_to_celllocal cell indices for each local vertex
[out]edge_to_vertexlocal vertex indices for each local edge
[out]edge_typetype of each local edge
[out]x_cellslongitudes of local cell centers
[out]y_cellslatitudes of local cell centers
[out]cell_maskmask for local cells (variable cell_sea_land_mask in icon grid file)
Remarks
The data of each process contains no halo cells.
If (x_cells == NULL) && (y_cells == NULL) no cell center coordinates will be read.
If (cell_mask == NULL) no cell mask information will be read.
See also
Configuration of parallel IO in YAC

Definition at line 958 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_read_icon_grid_information_parallel_f2c()

void yac_read_icon_grid_information_parallel_f2c ( const char * filename,
MPI_Fint comm,
int * nbr_vertices,
int * nbr_cells,
int ** num_vertices_per_cell,
int ** cell_to_vertex,
int ** global_cell_ids,
int ** cell_owner,
int ** global_vertex_ids,
int ** vertex_owner,
double ** x_vertices,
double ** y_vertices,
double ** x_cells,
double ** y_cells,
int ** cell_msk )

Definition at line 928 of file read_icon_grid.c.

Here is the call graph for this function:

◆ yac_read_part_icon_grid_information()

void yac_read_part_icon_grid_information ( const char * filename,
int * num_vertices,
int * num_cells,
int ** num_vertices_per_cell,
int ** cell_to_vertex,
double ** x_vertices,
double ** y_vertices,
double ** x_cells,
double ** y_cells,
int ** global_cell_id,
int ** cell_mask,
int ** cell_core_mask,
int ** global_corner_id,
int ** corner_core_mask,
int rank,
int size )

Reads in an icon grid netcdf file and return the grid information in a format that is supported by the YAC user interface.

Parameters
[in]filenamename of the icon grid netcdf file
[out]num_verticesnumber of vertices in the grid
[out]num_cellsnumber of cells in the grid
[out]num_vertices_per_cellnumber of vertices per cell
[out]cell_to_vertexvertex indices for each cell
[out]x_verticeslongitudes of vertices
[out]y_verticeslatitudes of vertices
[out]x_cellslongitudes of cell center
[out]y_cellslatitudes of cell center
[out]global_cell_idglobal cell IDs
[out]cell_maskmask for cells
[out]cell_core_maskcell core mask
[out]global_corner_idglobal corner IDs
[out]corner_core_maskcorner core mask
[out]ranklocal MPI rank
[out]sizenumber of MPI ranks
Remarks
The process reads in the fields of the whole grid and then extracts parts of it based on the "rank" and "size" parameter.

Definition at line 28 of file read_icon_grid.c.

Here is the call graph for this function:
Here is the caller graph for this function: