Commit c1ed3066 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

examples: change style of comments

parent b5049715
#include <stdio.h>
#include "cdi.h"
int nlon = 12; /* Number of longitudes */
int nlat = 6; /* Number of latitudes */
int nlev = 5; /* Number of levels */
int nts = 3; /* Number of time steps */
int nlon = 12; // Number of longitudes
int nlat = 6; // Number of latitudes
int nlev = 5; // Number of levels
int nts = 3; // Number of time steps
int main(void)
{
......@@ -14,7 +14,7 @@ int main(void)
double var2[nlon*nlat*nlev];
/* Open the input dataset */
// Open the input dataset
streamID1 = streamOpenRead("example.nc");
if ( streamID1 < 0 )
{
......@@ -22,17 +22,17 @@ int main(void)
return(1);
}
/* Get the variable list of the dataset */
// Get the variable list of the dataset
vlistID1 = streamInqVlist(streamID1);
/* Set the variable IDs */
// Set the variable IDs
varID1 = 0;
varID2 = 1;
/* Get the Time axis from the variable list */
// Get the Time axis from the variable list
taxisID = vlistInqTaxis(vlistID1);
/* Open the output dataset (GRIB fromat) */
// Open the output dataset (GRIB fromat)
streamID2 = streamOpenWrite("example.grb", FILETYPE_GRB);
if ( streamID2 < 0 )
{
......@@ -44,29 +44,29 @@ int main(void)
streamDefVlist(streamID2, vlistID2);
/* Loop over the number of time steps */
// Loop over the number of time steps
for ( tsID = 0; tsID < nts; tsID++ )
{
/* Inquire the input time step */
// Inquire the input time step
streamInqTimestep(streamID1, tsID);
/* Get the verification date and time */
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
/* Define the output time step */
// Define the output time step
streamDefTimestep(streamID2, tsID);
/* Read var1 and var2 */
// Read var1 and var2
streamReadVar(streamID1, varID1, var1, &nmiss);
streamReadVar(streamID1, varID2, var2, &nmiss);
/* Write var1 and var2 */
// Write var1 and var2
streamWriteVar(streamID2, varID1, var1, nmiss);
streamWriteVar(streamID2, varID2, var2, nmiss);
}
/* Close the streams */
// Close the streams
streamClose(streamID1);
streamClose(streamID2);
......
#include <stdio.h>
#include "cdi.h"
int nlon = 12; /* Number of longitudes */
int nlat = 6; /* Number of latitudes */
int nlev = 5; /* Number of levels */
int nts = 3; /* Number of time steps */
int nlon = 12; // Number of longitudes
int nlat = 6; // Number of latitudes
int nlev = 5; // Number of levels
int nts = 3; // Number of time steps
int main(void)
{
......@@ -14,7 +14,7 @@ int main(void)
double var2[nlon*nlat*nlev];
/* Open the dataset */
// Open the dataset
streamID = streamOpenRead("example.nc");
if ( streamID < 0 )
{
......@@ -22,32 +22,32 @@ int main(void)
return(1);
}
/* Get the variable list of the dataset */
// Get the variable list of the dataset
vlistID = streamInqVlist(streamID);
/* Set the variable IDs */
// Set the variable IDs
varID1 = 0;
varID2 = 1;
/* Get the Time axis from the variable list */
// Get the Time axis from the variable list
taxisID = vlistInqTaxis(vlistID);
/* Loop over the number of time steps */
// Loop over the number of time steps
for ( tsID = 0; tsID < nts; tsID++ )
{
/* Inquire the time step */
// Inquire the time step
streamInqTimestep(streamID, tsID);
/* Get the verification date and time */
// Get the verification date and time
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
/* Read var1 and var2*/
// Read var1 and var2
streamReadVar(streamID, varID1, var1, &nmiss);
streamReadVar(streamID, varID2, var2, &nmiss);
}
/* Close the input stream */
// Close the input stream
streamClose(streamID);
return 0;
......
#include <stdio.h>
#include "cdi.h"
#define nlon 12 /* Number of longitudes */
#define nlat 6 /* Number of latitudes */
#define nlev 5 /* Number of levels */
#define nts 3 /* Number of time steps */
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
#define nlev 5 // Number of levels
#define nts 3 // Number of time steps
int main(void)
{
......@@ -18,38 +18,38 @@ int main(void)
double var2[nlon*nlat*nlev];
/* Create a regular lon/lat grid */
// Create a regular lon/lat grid
gridID = gridCreate(GRID_LONLAT, nlon*nlat);
gridDefXsize(gridID, nlon);
gridDefYsize(gridID, nlat);
gridDefXvals(gridID, lons);
gridDefYvals(gridID, lats);
/* Create a surface level Z-axis */
// Create a surface level Z-axis
zaxisID1 = zaxisCreate(ZAXIS_SURFACE, 1);
/* Create a pressure level Z-axis */
// Create a pressure level Z-axis
zaxisID2 = zaxisCreate(ZAXIS_PRESSURE, nlev);
zaxisDefLevels(zaxisID2, levs);
/* Create a variable list */
// Create a variable list
vlistID = vlistCreate();
/* Define the variables */
// Define the variables
varID1 = vlistDefVar(vlistID, gridID, zaxisID1, TIME_VARIABLE);
varID2 = vlistDefVar(vlistID, gridID, zaxisID2, TIME_VARIABLE);
/* Define the variable names */
// Define the variable names
vlistDefVarName(vlistID, varID1, "varname1");
vlistDefVarName(vlistID, varID2, "varname2");
/* Create a Time axis */
// Create a Time axis
taxisID = taxisCreate(TAXIS_ABSOLUTE);
/* Assign the Time axis to the variable list */
// Assign the Time axis to the variable list
vlistDefTaxis(vlistID, taxisID);
/* Create a dataset in netCDF fromat */
// Create a dataset in netCDF fromat
streamID = streamOpenWrite("example.nc", FILETYPE_NC);
if ( streamID < 0 )
{
......@@ -57,32 +57,32 @@ int main(void)
return(1);
}
/* Assign the variable list to the dataset */
// Assign the variable list to the dataset
streamDefVlist(streamID, vlistID);
/* Loop over the number of time steps */
// Loop over the number of time steps
for ( tsID = 0; tsID < nts; tsID++ )
{
/* Set the verification date to 1985-01-01 + tsID */
// Set the verification date to 1985-01-01 + tsID
taxisDefVdate(taxisID, 19850101+tsID);
/* Set the verification time to 12:00:00 */
// Set the verification time to 12:00:00
taxisDefVtime(taxisID, 120000);
/* Define the time step */
// Define the time step
streamDefTimestep(streamID, tsID);
/* Init var1 and var2 */
// Init var1 and var2
for ( i = 0; i < nlon*nlat; i++ ) var1[i] = 1.1;
for ( i = 0; i < nlon*nlat*nlev; i++ ) var2[i] = 2.2;
/* Write var1 and var2 */
// Write var1 and var2
streamWriteVar(streamID, varID1, var1, nmiss);
streamWriteVar(streamID, varID2, var2, nmiss);
}
/* Close the output stream */
// Close the output stream
streamClose(streamID);
/* Destroy the objects */
// Destroy the objects
vlistDestroy(vlistID);
taxisDestroy(taxisID);
zaxisDestroy(zaxisID1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment