Coupled dummy atmosphere in C.
#include <mpi.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define NBR_CELLS 2
#define NBR_VERTICES 4
#define YAC_RAD (0.01745329251994329576923690768489)
#define STR_USAGE "Usage: %s -c configFilename\n"
#define YAC_ASSERT_ARGS(exp, msg) \
{ \
if(!((exp))) { \
fprintf(stderr, "ERROR: %s\n" STR_USAGE, msg, argv[0]); \
exit(EXIT_FAILURE); \
} \
}
int argc, char ** argv, char const ** configFilename);
int main (int argc, char *argv[]) {
const char *
fieldName[] = {
"surface_downward_eastward_stress",
"surface_downward_northward_stress",
"surface_fresh_water_flux",
"surface_temperature",
"total_heat_flux",
"atmosphere_sea_ice_bundle",
"sea_surface_temperature",
"eastward_sea_water_velocity",
"northward_sea_water_velocity",
"ocean_sea_ice_bundle",
"atmos_out1",
"atmos_out2",
"atmos_out3",
"atmos_out4"};
int field_collection_size[] = {
2,
2,
3,
1,
4,
4,
1,
1,
1,
5,
1,
1,
1,
1};
char * comp_name = "dummy_atmosphere";
char * grid_name = "dummy_atmosphere_grid";
MPI_Comm local_comm;
MPI_Init (0, NULL);
char const * configFilename = "toy_dummy.yaml";
MPI_Comm_rank ( local_comm, &rank );
MPI_Comm_size ( local_comm, &size );
printf (" %s rank %d : local size %d \n", comp_name, rank, size );
nbr_vertices,
nbr_cells,
for ( i = 0;
i < nbr_cells; ++
i ) {
}
nbr_cells,
for ( i = 0;
i < nbr_cells; ++
i )
1,field_collection_size[i],
printf (
"Field ID %d: model step %s \n",
field_id[i], timestep_string);
}
{
double *point_set_data[5];
double **collection_data[5];
for (int j = 0; j < 5; ++j) {
point_set_data[j] =
buffer + j * nbr_cells;
collection_data[j] = &(point_set_data[j]);
}
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 10.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[1*nbr_cells+i] = 10.2;
printf ( "atmosphere CPL TAUX 1 %f \n"
"atmosphere CPL TAUX 2 %f \n",
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 20.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[1*nbr_cells+i] = 20.2;
printf ( "atmosphere CPL TAUY 1 %f \n"
"atmosphere CPL TAUY 2 %f \n",
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 30.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[1*nbr_cells+i] = 30.2;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[2*nbr_cells+i] = 30.3;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 40.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 50.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[1*nbr_cells+i] = 50.2;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[2*nbr_cells+i] = 50.3;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[3*nbr_cells+i] = 50.4;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[0*nbr_cells+i] = 60.1;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[1*nbr_cells+i] = 60.2;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[2*nbr_cells+i] = 60.3;
for ( i = 0;
i < nbr_cells; ++
i )
buffer[3*nbr_cells+i] = 60.4;
}
{
double *collection_data[5];
for (int j = 0; j < 5; ++j) {
collection_data[j] =
buffer + j * nbr_cells;
}
if (
info > 0 ) printf (
"atmosphere CPL SST %f \n",
buffer[0] );
if (
info > 0 ) printf (
"atmosphere CPL OCEANU %f \n",
buffer[0] );
if (
info > 0 ) printf (
"atmosphere CPL OCEANV %f \n",
buffer[0] );
printf (
"atmosphere CPL ice 1 %f \n",
buffer[0*nbr_cells+0] );
printf (
"atmosphere CPL ice 2 %f \n",
buffer[1*nbr_cells+0] );
printf (
"atmosphere CPL ice 3 %f \n",
buffer[2*nbr_cells+0] );
printf (
"atmosphere CPL ice 4 %f \n",
buffer[3*nbr_cells+0] );
printf (
"atmosphere CPL ice 5 %f \n",
buffer[4*nbr_cells+0] );
}
}
MPI_Finalize ();
return 0;
}
int argc, char ** argv, char const ** configFilename) {
int opt;
while ((opt = getopt(argc, argv, "c:")) != -1) {
switch (opt) {
default:
case 'c':
*configFilename = optarg;
break;
}
}
}
int nbr_vertices_per_cell[NBR_CELLS]
static void parse_arguments(int argc, char **argv, enum experiment_type *experiment)
#define YAC_ASSERT_ARGS(exp, msg)
void yac_cset_global_index(int const *global_index, int location, int grid_id)
int const YAC_LOCATION_CELL
const char * yac_cget_timestep_from_field_id(int field_id)
void yac_cfinalize()
Finalises YAC.
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
void yac_cget(int const field_id, int collection_size, double **recv_field, int *info, int *ierr)
int const YAC_TIME_UNIT_SECOND
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
void yac_cdef_points_unstruct(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
char * yac_cget_version(void)
void yac_cput(int const field_id, int const collection_size, double ***const send_field, int *info, int *ierr)
void yac_cread_config_yaml(const char *yaml_filename)
void yac_cset_core_mask(int const *is_core, int location, int grid_id)
void yac_cset_mask(int const *is_valid, int points_id)
void yac_cdef_comp(char const *comp_name, int *comp_id)
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)