/* This is part of the netCDF package. Copyright 2006 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is an example program which writes some 4D pressure and temperatures. This example demonstrates the netCDF C++ API. This is part of the netCDF tutorial: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial Full documentation of the netCDF C++ API can be found at: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-cxx $Id: pres_temp_4D_wr.cpp,v 1.11 2007/01/19 12:52:13 ed Exp $ */ #include <iostream> #include <netcdfcpp.h> using namespace std; // We are writing 4D data, a 2 x 6 x 12 lvl-lat-lon grid, with 2 // timesteps of data. static const int NLVL = 2; static const int NLAT = 6; static const int NLON = 12; static const int NREC = 2; // These are used to construct some example data. static const float SAMPLE_PRESSURE = 900.0; static const float SAMPLE_TEMP = 9.0; static const float START_LAT = 25.0; static const float START_LON = -125.0; // Return this code to the OS in case of failure. static const int NC_ERR = 2; int main() { // These arrays will store the latitude and longitude values. float lats[NLAT],lons[NLON]; // These arrays will hold the data we will write out. We will // only need enough space to hold one timestep of data; one record. float pres_out[NLVL][NLAT][NLON]; float temp_out[NLVL][NLAT][NLON]; int i = 0; // Create some pretend data. If this wasn't an example program, we // would have some real data to write for example, model output. for (int lat = 0; lat < NLAT; lat++) lats[lat] = START_LAT + 5. * lat; for (int lon = 0; lon < NLON; lon++) lons[lon] = START_LON + 5. * lon; for (int lvl = 0; lvl < NLVL; lvl++) for (int lat = 0; lat < NLAT; lat++) for (int lon = 0; lon < NLON; lon++) { pres_out[lvl][lat][lon] = SAMPLE_PRESSURE + i; temp_out[lvl][lat][lon] = SAMPLE_TEMP + i++; } // Change the error behavior of the netCDF C++ API by creating an // NcError object. Until it is destroyed, this NcError object will // ensure that the netCDF C++ API returns error codes on any // failure, prints an error message, and leaves any other error // handling to the calling program. In the case of this example, we // just exit with an NC_ERR error code. NcError err(NcError::verbose_nonfatal); // Create the file. NcFile dataFile("pres_temp_4D.nc", NcFile::Replace); // Check to see if the file was created. if(!dataFile.is_valid()) return NC_ERR; // Define the dimensions. NetCDF will hand back an ncDim object for // each. NcDim *lvlDim, *latDim, *lonDim, *recDim; if (!(lvlDim = dataFile.add_dim("level", NLVL))) return NC_ERR; if (!(latDim = dataFile.add_dim("latitude", NLAT))) return NC_ERR; if (!(lonDim = dataFile.add_dim("longitude", NLON))) return NC_ERR; // Add an unlimited dimension... if (!(recDim = dataFile.add_dim("time"))) return NC_ERR; // Define the coordinate variables. NcVar *latVar, *lonVar; if (!(latVar = dataFile.add_var("latitude", ncFloat, latDim))) return NC_ERR; if (!(lonVar = dataFile.add_var("longitude", ncFloat, lonDim))) return NC_ERR; // Define units attributes for coordinate vars. This attaches a // text attribute to each of the coordinate variables, containing // the units. if (!latVar->add_att("units", "degrees_north")) return NC_ERR; if (!lonVar->add_att("units", "degrees_east")) return NC_ERR; // Define the netCDF variables for the pressure and temperature // data. NcVar *presVar, *tempVar; if (!(presVar = dataFile.add_var("pressure", ncFloat, recDim, lvlDim, latDim, lonDim))) return NC_ERR; if (!(tempVar = dataFile.add_var("temperature", ncFloat, recDim, lvlDim, latDim, lonDim))) return NC_ERR; // Define units attributes for data variables. if (!presVar->add_att("units", "hPa")) return NC_ERR; if (!tempVar->add_att("units", "celsius")) return NC_ERR; // Write the coordinate variable data to the file. if (!latVar->put(lats, NLAT)) return NC_ERR; if (!lonVar->put(lons, NLON)) return NC_ERR; // Write the pretend data. This will write our surface pressure and // surface temperature data. The arrays only hold one timestep // worth of data. We will just rewrite the same data for each // timestep. In a real application, the data would change between // timesteps. for (int rec = 0; rec < NREC; rec++) { if (!presVar->put_rec(&pres_out[0][0][0], rec)) return NC_ERR; if (!tempVar->put_rec(&temp_out[0][0][0], rec)) return NC_ERR; } // The file is automatically closed by the destructor. This frees // up any internal netCDF resources associated with the file, and // flushes any buffers. cout << "*** SUCCESS writing example file pres_temp_4D.nc!" << endl; return 0; }
/* This is part of the netCDF package. Copyright 2006 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is an example which reads some 4D pressure and temperature values. The data file read by this program is produced by the companion program pres_temp_4D_wr.cpp. It is intended to illustrate the use of the netCDF C++ API. This program is part of the netCDF tutorial: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial Full documentation of the netCDF C++ API can be found at: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-cxx $Id: pres_temp_4D_rd.cpp,v 1.13 2007/02/14 20:59:21 ed Exp $ */ #include <iostream> #include <netcdfcpp.h> using namespace std; // We are writing 4D data, a 2 x 6 x 12 lvl-lat-lon grid, with 2 // timesteps of data. static const int NLVL = 2; static const int NLAT = 6; static const int NLON = 12; static const int NREC = 2; // These are used to construct some example data. static const float SAMPLE_PRESSURE = 900.0; static const float SAMPLE_TEMP = 9.0; static const float START_LAT = 25.0; static const float START_LON = -125.0; // Return this code to the OS in case of failure. static const int NC_ERR = 2; int main() { // These arrays will store the latitude and longitude values. float lats[NLAT], lons[NLON]; // These arrays will hold the data we will read in. We will only // need enough space to hold one timestep of data; one record. float pres_in[NLVL][NLAT][NLON]; float temp_in[NLVL][NLAT][NLON]; // Change the error behavior of the netCDF C++ API by creating an // NcError object. Until it is destroyed, this NcError object will // ensure that the netCDF C++ API returns error codes on any // failure, prints an error message, and leaves any other error // handling to the calling program. In the case of this example, we // just exit with an NC_ERR error code. NcError err(NcError::verbose_nonfatal); // Open the file. NcFile dataFile("pres_temp_4D.nc", NcFile::ReadOnly); // Check to see if the file was opened. if(!dataFile.is_valid()) return NC_ERR; // Get pointers to the latitude and longitude variables. NcVar *latVar, *lonVar; if (!(latVar = dataFile.get_var("latitude"))) return NC_ERR; if (!(lonVar = dataFile.get_var("longitude"))) return NC_ERR; // Get the lat/lon data from the file. if (!latVar->get(lats, NLAT)) return NC_ERR; if (!lonVar->get(lons, NLON)) return NC_ERR; // Check the coordinate variable data. for (int lat = 0; lat < NLAT; lat++) if (lats[lat] != START_LAT + 5. * lat) return NC_ERR; for (int lon = 0; lon < NLON; lon++) if (lons[lon] != START_LON + 5. * lon) return NC_ERR; // Get pointers to the pressure and temperature variables. NcVar *presVar, *tempVar; if (!(presVar = dataFile.get_var("pressure"))) return NC_ERR; if (!(tempVar = dataFile.get_var("temperature"))) return NC_ERR; // Read the data. Since we know the contents of the file we know // that the data arrays in this program are the correct size to // hold one timestep. for (int rec = 0; rec < NREC; rec++) { // Read the data one record at a time. if (!presVar->set_cur(rec, 0, 0, 0)) return NC_ERR; if (!tempVar->set_cur(rec, 0, 0, 0)) return NC_ERR; // Get 1 record of NLVL by NLAT by NLON values for each variable. if (!presVar->get(&pres_in[0][0][0], 1, NLVL, NLAT, NLON)) return NC_ERR; if (!tempVar->get(&temp_in[0][0][0], 1, NLVL, NLAT, NLON)) return NC_ERR; // Check the data. int i = 0; for (int lvl = 0; lvl < NLVL; lvl++) for (int lat = 0; lat < NLAT; lat++) for (int lon = 0; lon < NLON; lon++) if (pres_in[lvl][lat][lon] != SAMPLE_PRESSURE + i || temp_in[lvl][lat][lon] != SAMPLE_TEMP + i++) return NC_ERR; } // next record // The file is automatically closed by the destructor. This frees // up any internal netCDF resources associated with the file, and // flushes any buffers. cout << "*** SUCCESS reading example file pres_temp_4D.nc!" << endl; return 0; }
The netCDF-3 C and Fortran APIs each have over 100 functions, but most users need only a handful. Listed below are the essential netCDF functions for four important tasks in netCDF: creating new files, reading existing files, learning about a netCDF file of unknown structure, and reading and writing subsets of data.
In each case the functions are presented for each of the four language APIs: C, Fortran 77, Fortran 90, and C++, with hyper-links to the detailed documentation of each function.
To construct a netCDF file you need to:
create the file
define metadata
write data
close the file
Use nc_create to create a file. Then use nc_def_dim to define each shared dimension. The data variables are then specified with nc_def_var. Any attributes are added with nc_put_att. Finally, call nc_enddef to tell the library that you are done defining the metadata, and ready to start writing the data.
After all data are written to the file, call nc_close to ensure that all buffers are flushed, and any resources associated with the open file are returned to the operating system.
For a very simple example, See simple_xy in C.
For a typical sequence of calls to the C versions of these functions, see See Creating a NetCDF Dataset.
| nc_create | create a new netCDF file
|
| nc_def_dim | define a dimension
|
| nc_def_var | define a variable
|
| nc_put_att_ type | write attributes
|
| nc_enddef | leave define mode
|
| nc_put_vara_ type | write arrays of data
|
| nc_close | close a file
|
Use NF_CREATE to create a file. Then use NF_DEF_DIM to define each shared dimension. The data variables are then specified with NF_DEF_VAR. Any attributes are added with NF_PUT_ATT. Finally, call NF_ENDDEF to tell the library that you are done defining the metadata, and ready to start writing the data.
After all data are written to the file, call NF_CLOSE to ensure that all buffers are flushed, and any resources associated with the open file are returned to the operating system.
For a typical sequence of calls see Creating a NetCDF Dataset.
Fortran users take note: the netCDF Fortran 77 API consists of wrappers around the functions of the netCDF C library. There is no Fortran 77 code in netCDF except for these wrappers, and tests to ensure that the wrappers work.
The name of each Fortran function shows the outline of the C function it wraps (for example, NF_CREATE is a wrapper around nc_create).
| NF_CREATE | create a new netCDF file
|
| NF_DEF_DIM | define a dimension
|
| NF_DEF_VAR | define a variable
|
| NF_PUT_ATT_ type | write an attribute
|
| NF_ENDDEF | end define mode
|
| NF_PUT_VARA_ type | write arrays of data
|
| NF_CLOSE | close the netCDF file
|
Use NF90_CREATE to create a file. Then use NF90_DEF_DIM to define each shared dimension. The data variables are then specified with NF90_DEF_VAR. Any attributes are added with NF90_PUT_ATT. Finally, call NF90_ENDDEF to tell the library that you are done defining the metadata, and ready to start writing the data.
After all data are written to the file, call NF90_CLOSE to ensure that all buffers are flushed, and any resources associated with the open file are returned to the operating system.
For a typical sequence of calls see Creating a NetCDF Dataset.
The netCDF Fortran 90 API calls the Fortran 77 API, which in turn calls the netCDF C library.
The name of each Fortran function shows the outline of the F77 function it wraps (for example, NF90_CREATE is a wrapper around NF_CREATE). The F77 functions are, in turn, wrappers around the C functions.
| NF90_CREATE | create a netCDF file
|
| NF90_DEF_DIM | define a dimension
|
| NF90_DEF_VAR | define a variable
|
| NF90_PUT_ATT_ type | write an attribute
|
| NF90_ENDDEF | end define mode
|
| NF90_PUT_VARA_ type | write arrays of data
|
| NF90_CLOSE | close the netCDF file
|
Create an instance of the NcFile class to create a netCDF file. Use its add_dim and add_var methods to add dimensions and variables. The add_att method is available for both NcFile and NcVar.
Use the NcError class to specify error handling behavior.
For an example creating a simple file see simple_xy_wr.cpp. For a more complex example see pres_temp_4D_wr.cpp.
| Class NcFile | a C++ class to manipulate netCDF files
|
| Class NcDim | a C++ class to manipulate netCDF dimensions
|
| Class NcVar | a C++ class to manipulate netCDF variables
|
| Class NcAtt | a C++ class to manipulate netCDF attributes
|
| Class NcError | a C++ class to control netCDF error handling
|
To read a netCDF file of known structure, you need to:
open the file
read variable or attribute data
close the file
Use ncdump to learn the structure of a file (use the -h option). For more information about ncdump see NetCDF Utilities.
In C, Fortran 77, and Fortran 90, netCDF objects are identified by an integer: the ID. NetCDF functions use this ID to identify the object. It's helpful for the programmer to understand these IDs.
Open data files, dimensions, variables, and attributes are each numbered independently, and are always numbered in the order in which they were defined. (They also appear in this order in ncdump output.) Numbering starts with 0 in C, and 1 in Fortran 77/90.
For example, the first variable defined in a file will have an ID of 0 in C programs, and 1 in Fortran programs, and functions that apply to a variable will need to know the ID of the variable you mean.
(The numbering of files is an exception: file IDs are assigned by the operating system when a file is opened, and are not permanently associated with the file. IDs for netCDF dimensions and variables are persistent, but deleting an attribute changes subsequent attribute numbers.)
Although netCDF refers to everything by an integer id (varid, dimid, attnum), there are inquiry functions which, given a name, will return an ID. For example, in the C API, nc_inq_varid will take a character string (the name), and give back the ID of the variable of that name. The variable ID is then used in subsequent calls (to read the data, for example).
Other inquiry functions exist to further describe the file. (see Inquiry Functions).
For a typical sequence of calls to these C functions see Reading a NetCDF Dataset with Known Names.
| nc_open | open a netCDF file
|
| nc_get_att | read an attribute
|
| nc_get_vara_ type | read arrays of data
|
| nc_close | close the file
|
For a typical sequence of calls to these functions see Reading a NetCDF Dataset with Known Names.
| NF_OPEN | open a netCDF file
|
| NF_GET_ATT | read an attribute
|
| NF_GET_VARA_ type | read arrays of data
|
| NF_CLOSE | close the file
|
For a typical sequence of calls to these functions see Reading a NetCDF Dataset with Known Names.
| NF90_OPEN | open a netCDF file
|
| NF90_GET_ATT | read an attribute
|
| NF90_GET_VARA | read arrays of data
|
| NF90_CLOSE | close the file
|
| Class NcFile | a C++ class to manipulate netCDF files
|
| Class NcDim | a C++ class to manipulate netCDF dimensions
|
| Class NcVar | a C++ class to manipulate netCDF variables
|
| Class NcAtt | a C++ class to manipulate netCDF attributes
|
Perhaps you would like to write your software to handle more general cases, so that you don't have to adjust your source every time the grid size changes, or a variable is added to the file.
There are inquiry functions that let you find out everything you need to know about a file. These functions contain “inq” or “INQ” in their names.
Using the inquiry functions, it is possible to write code that will read and understand any netCDF file, whatever its contents. (For example, ncdump does just that.)
First use nc_inq, which will tell you how many variables and global attributes there are in the file.
Start with global attribute 0, and proceed to natts - 1, the number of global attributes minus one. The nc_inq_att function will tell you the name, type, and length of each global attribute.
Then start with dimid 0, and proceed to dimid ndims - 1, calling nc_inq_dim. This will tell you the name and length of each dimension, and whether it is unlimited.
Then start with varid 0, and proceed to varid nvars - 1, calling nc_inq_var. This will tell you the number of dimensions of this variable, and their associated IDs. It will also get the name and type of this variable, and whether there are any attributes attached. If there are attributes attached, use the nc_inq_att function to get their names, types, and lengths.
(To read an attribute, use the appropriate nc_get_att_<TYPE> function, like nc_get_att_int() to get the data from an attribute that is an array of integers.)
There are also functions that return an item's ID, given its name. To find IDs from the names, use functions nc_inq_dimid, nc_inq_attnum, and nc_inq_varid.
For a typical sequence of calls to these functions see Reading a netCDF Dataset with Unknown Names.
With any of the C inquiry functions, a NULL pointer can be used to ignore a return parameter. Consider the nc_inq function:
EXTERNL int nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
If you call this with NULL for the last three parameters, you can learn the number of dimensions without bothering about the number of variables, number of global attributes, and the ID of the unlimited dimension.
For further convenience, we provide functions like nc_inq_ndims, which only finds the number of dimensions, exactly as if you had called nc_inq, with NULLs in all parameters except ndimsp. (In fact, this is just what the nc_inq_ndims functions does).
| nc_inq | Find number of dimensions, variables, and global attributes, and the unlimited dimid.
|
| nc_inq_att | Find attribute name, type, and length.
|
| nc_inq_dim Family | Find dimension name and length.
|
| nc_inq_var | Find variable name, type, num dimensions, dim IDs, and num attributes.
|
| nc_inq_dimid | Find dimension ID from its name.
|
| nc_inq_varid | Find variable ID from its name.
|
| nc_inq_format | Find file format: classic or 64-bit offset
|
| nc_inq_libvers | Find the netCDF version. (Currently 4.1.3).
|
First use NF_INQ, which will tell you how many variables and global attributes there are in the file. Then start with varid 1, and proceed to varid nvars, calling NF_INQ_VAR.
For a typical sequence of calls to these functions see Reading a netCDF Dataset with Unknown Names.
| NF_INQ. | Find number of dimensions, variables, and global attributes, and the unlimited dimid.
|
| NF_INQ_DIM. | Find dimension name and length.
|
| NF_INQ_VARID. | Find variable ID from its name.
|
| NF_INQ_VAR. | Find variable name, type, num dimensions, dim IDs, and num attributes.
|
| NF_INQ_DIMID. | Find dimension ID from its name.
|
| NF_INQ_DIM. | Find dimension name and length.
|
| NF_INQ_ATT. | Find attribute name, type, and length.
|
| NF_INQ_FORMAT. | Find file format: classic or 64-bit offset
|
| NF_INQ_LIBVERS. | Find the netCDF version. (Currently 4.1.3).
|
First use NF90_INQ, which will tell you how many variables and global attributes there are in the file. Then start with varid 1, and proceed to varid nvars, calling NF90_INQ_VAR.
For a typical sequence of calls to these functions, see See Reading a netCDF Dataset with Unknown Names.
| NF90_INQ. | Find number of dimensions, variables, and global attributes, and the unlimited dimid.
|
| NF90_INQ_DIM. | Find dimension name and length.
|
| NF90_INQ_VARID. | Find variable ID from its name.
|
| NF90_INQ_VAR. | Find variable name, type, num dimensions, dim IDs, and num attributes.
|
| NF90_INQ_DIMID. | Find dimension ID from its name.
|
| NF90_INQ_DIM. | Find dimension name and length.
|
| NF90_INQ_ATT. | Find attribute name, type, and length.
|
| NF90_INQ_FORMAT. | Find file format: classic or 64-bit offset
|
| NF90_INQ_LIBVERS. | Find the netCDF version. (Currently 4.1.3).
|
| Class NcFile | a C++ class to manipulate netCDF files
|
| Class NcDim | a C++ class to manipulate netCDF dimensions
|
| Class NcVar | a C++ class to manipulate netCDF variables
|
| Class NcAtt | a C++ class to manipulate netCDF attributes
|
Usually users are interested in reading or writing subsets of variables in a netCDF data file. The netCDF APIs provide a variety of functions for this purpose.
In the simplest case, you will use the same type for both file and in-memory storage, but in some cases you may wish to use different types. For example, you might have a netCDF file that contains integer data, and you wish to read it into floating-point storage, converting the data as it is read. The same sort of type conversion can be done when writing the data.
To convert to a type while reading data, use the appropriate nc_get_vara_<TYPE> or NF_GET_VARA_<TYPE> function. For example, the C function nc_get_vara_float(), and the Fortran function NF_GET_VARA_REAL will read netCDF data of any numeric type into a floating-point array, automatically converting each element to the desired type.
To convert from a type while writing data, use the appropriate nc_put_vara_<TYPE> or NF_PUT_VARA_<TYPE> function. For example, the C function nc_put_vara_float(), and the Fortran function NC_PUT_VARA_REAL will write floating-point data into netCDF arrays, automatically converting each element of the array to the type of the netCDF variable.
The <TYPE> in the function name refers to the type of the in-memory data, in both cases. They type of the file data is determined when the netCDF variable is defined.
The type of the data may be automatically converted on read or write. For more information about type conversion see Type Conversion.
| Read the entire variable at once | nc_get_var_ type
|
| Write the entire variable at once | nc_put_var_ type
|
| Read just one value | nc_get_var1_ type
|
| Write just one value | nc_put_var1_ type
|
| Read an array subset | nc_get_vara_ type
|
| Write an array subset | nc_put_vara_ type
|
| Read an array with strides | nc_get_vars_ type
|
| Write an array with strides | nc_put_vars_ type
|
The type of the data may be automatically converted on read or write. For more information about type conversion see Type Conversion.
| Read the entire variable at once | NF_GET_VAR_ type
|
| Write the entire variable at once | NF_PUT_VAR_ type
|
| Read just one value | NF_GET_VAR1_ type
|
| Write just one value | NF_PUT_VAR1_ type
|
| Read an array subset | NF_GET_VARA_ type
|
| Write an array subset | NF_PUT_VARA_ type
|
| Read an array with strides | NF_GET_VARS_ type
|
| Write an array with strides | NF_PUT_VARS_ type
|
The type of the data may be automatically converted on read or write. For more information about type conversion see Type Conversion.
| Read the entire variable at once | NF90_GET_VAR_ type
|
| Write the entire variable at once | NF90_PUT_VAR_ type
|
| Read just one value | NF90_GET_VAR1_ type
|
| Write just one value | NF90_PUT_VAR1_ type
|
| Read an array subset | NF90_GET_VARA_ type
|
| Write an array subset | NF90_PUT_VARA_ type
|
| Read an array with strides | NF90_GET_VARS_ type
|
| Write an array with strides | NF90_PUT_VARS_ type
|
To read a record of data at a time, use the set_cur method of the NcVar class to set the number of the record of interest, and then use the get method to read the record.
| Class NcVar | a C++ class to manipulate netCDF variables, use the set_cur and
get methods to read records from a file.
|
NetCDF-4 includes many advanced features. These features are only available when working with files created in the netCDF format. (That is, HDF5 files, created by netCDF, or simple-model HDF5 files).
NetCDF-4 allows some interoperability with HDF5.
The HDF5 Files produced by netCDF-4 are perfectly respectable HDF5 files, and can be read by any HDF5 application.
NetCDF-4 relies on several new features of HDF5, including dimension scales. The HDF5 dimension scales feature adds a bunch of attributes to the HDF5 file to keep track of the dimension information.
It is not just wrong, but wrong-headed, to modify these attributes except with the HDF5 dimension scale API. If you do so, then you will deserve what you get, which will be a mess.
Additionally, netCDF stores some extra information for dimensions without dimension scale information. (That is, a dimension without an associated coordinate variable). So HDF5 users should not write data to a netCDF-4 file which extends any unlimited dimension.
Also there are some types allowed in HDF5, but not allowed in netCDF-4 (for example the time type). Using any such type in a netCDF-4 file will cause the file to become unreadable to netCDF-4. So don't do it.
NetCDF-4 ignores all HDF5 references. Can't make head nor tail of them. Also netCDF-4 assumes a strictly hierarchical group structure. No looping, you weirdo!
Attributes can be added (they must be one of the netCDF-4 types), modified, or even deleted, in HDF5.
Assuming a HDF5 file is written in accordance with the netCDF-4 rules (i.e. no strange types, no looping groups), and assuming that *every* dataset has a dimension scale attached to each dimension, the netCDF-4 API can be used to read and edit the file.
In HDF5 (version 1.8.0 and later), dimension scales are (generally) 1D datasets, that hold dimension data. A multi-dimensional dataset can then attach a dimension scale to any or all of its dimensions. For example, a user might have 1D dimension scales for lat and lon, and a 2D dataset which has lat attached to the first dimension, and lon to the second.
Dimension scales are vital to netCDF-4, which uses shared dimensions. If you want to read a HDF5 file with netCDF-4, it must use dimension scales, and one dimension scale must be attached to each dimension of every dataset in the file.
With classic and 64-bit offset netCDF files, each variable may use at most one unlimited dimension. With netCDF-4 format files, this restriction is lifted.
Simply define as many unlimited dimensions as you wish, and use them in a variable. When data are written to that variable, the dimensions will be expanded as needed.
NetCDF-4 files can store attributes, variables, and dimensions in hierarchical groups.
This allows the user to create a structure much like a Unix file system. In netCDF, each group gets an ncid. Opening or creating a file returns the ncid for the root group (which is named “/”). Groups can be added with the nc_def_grp function. Get the number of groups, and their ncids, with the nc_inq_grps function.
Dimensions are scoped such that they are visible to all child groups. For example, you can define a dimension in the root group, and use its dimension id when defining a variable in a sub-group.
Attributes defined as NC_GLOBAL apply to the group, not the entire file.
The degenerate case, in which only the root group is used, corresponds exactly with the classic data mode, before groups were introduced.
In netCDF-4 files it's possible to create a data type which corresponds to a C struct. These are known as “compound” types (following HDF5 nomenclature).
That is, a netCDF compound type is a data structure which contains an arbitrary collection of other data types, including other compound types.
To define a new compound type, use nc_def_compound. Then call nc_insert_compound for each type within the compound type.
Read and write arrays of compound data with the nc_get_vara and nc_put_vara functions. These functions were actually part of the netCDF-2 API, brought out of semi-retirement to handle user-defined types in netCDF-4.
Store blobs of bits in opaque types. Create an opaque type with nc_def_opaque. Read and write them with nc_get_vara/nc_put_vara.
Create a VLEN type to store variable length arrays of a known base type. Use nc_def_vlen to define a VLEN type, read and write them with nc_get_vara/nc_put_vara.
Use the NC_STRING type to store arrays of strings. Read and write them with nc_get_vara/nc_put_vara.
There are many new inquiry functions to allow a program to navigate a completely unknown netCDF file.
To find the number To find all the dimensions visible from a group, use nc_inq_dimids.
Parallel I/O allows many processes to read/write netCDF data at the same time. Used properly, it allows users to overcome I/O bottlenecks in high performance computing environments.
Parallel read-only access can be achieved netCDF files using the netCDF C/Fortran library. Each process can run a copy of the netCDF library and open and read any subsets of the data in the file. This sort of “fseek parallelism” will break down dramatically for any kind of writing.
There are two methods available to users for read/write parallel I/O netCDF-4 or the parallel netCDF package from Argonne/Northwestern. Unfortunately the two methods involve different APIs, and different binary formats.
For parallel read/write access to classic and 64-bit offset data users must use the parallel-netcdf library from Argonne/Northwestern University. This is not a Unidata software package, but was developed using the Unidata netCDF C library as a starting point. For more information see the parallel netcdf web site: http://www.mcs.anl.gov/parallel-netcdf.
For parallel read/write access to netCDF-4/HDF5 files users must use the netCDF-4 API. The Argonne/Northwestern parallel netcdf package cannot read netCDF-4/HDF5 files.
NetCDF-4 provides access to HDF5 parallel I/O features for netCDF-4/HDF5 files. NetCDF classic and 64-bit offset format may not be opened or created for use with parallel I/O. (They may be opened and created, but parallel I/O is not available.)
A few functions have been added to the netCDF C API to handle parallel I/O. These functions are also available in the Fortran 90 and Fortran 77 APIs.
You must build netCDF-4 properly to take advantage of parallel features.
For parallel I/O HDF5 must be built with –enable-parallel. Typically the CC environment variable is set to mpicc. You must build HDF5 and netCDF-4 with the same compiler and compiler options.
The netCDF configure script will detect the parallel capability of HDF5 and build the netCDF-4 parallel I/O features automatically. No configure options to the netcdf configure are required. If the Fortran APIs are desired set environmental variable FC to mpif90 (or some local variant.)
The nc_open_par and nc_create_par functions are used to create/open a netCDF file with the C API. (Or use nf_open_par/nf_create_par from Fortran 77).
For Fortran 90 users the nf90_open and nf90_create calls have been modified to permit parallel I/O files to be opened/created using optional parameters comm and info.
The parallel access associated with these functions is not a characteristic of the data file, but the way it was opened.
Parallel file access is either collective (all processors must participate) or independent (any processor may access the data without waiting for others).
All netCDF metadata writing operations are collective. That is, all creation of groups, types, variables, dimensions, or attributes.
Data reads and writes (ex. calls to nc_put_vara_int and nc_get_vara_int) may be independent (the default) or collective. To make writes to a variable collective, call the nc_var_par_access function (or nf_var_par_access for Fortran 77 users, or nf90_var_par_access for Fortran 90 users).
The example program below demonstrates simple parallel writing and reading of a netCDF file.
For this release, only a Fortran 90 language version of this example is provided. Other APIs will be demonstrated in examples in future releases.
In the simple_xy_par_wr example program an num_procs x num_procs array is written to the disk, where num_proc is the number of processors on which this program is run. Each processor writes one row of length num_proc.
In the simple_xy_par_rd program the file is read in, and each processor expects to read in a row with its own MPI rank stored. (The read program must be run on no more processors than were used to create the file.)
! This is part of the netCDF package. ! Copyright 2006 University Corporation for Atmospheric Research/Unidata. ! See COPYRIGHT file for conditions of use. ! This is a very simple example which writes a 2D array of sample ! data. To handle this in netCDF we create two shared dimensions, ! "x" and "y", and a netCDF variable, called "data". It uses ! parallel I/O to write the file from all processors at the same ! time. ! This example demonstrates the netCDF Fortran 90 API. This is part ! of the netCDF tutorial, which can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial ! Full documentation of the netCDF Fortran 90 API can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90 ! $Id: simple_xy_par_wr.f90,v 1.3 2010/06/01 15:34:49 ed Exp $ program simple_xy_par_wr use netcdf implicit none include 'mpif.h' ! This is the name of the data file we will create. character (len = *), parameter :: FILE_NAME = "simple_xy_par.nc" ! We are writing 2D data. integer, parameter :: NDIMS = 2 ! When we create netCDF files, variables and dimensions, we get back ! an ID for each one. integer :: ncid, varid, dimids(NDIMS) integer :: x_dimid, y_dimid ! These will tell where in the data file this processor should ! write. integer :: start(NDIMS), count(NDIMS) ! This is the data array we will write. It will just be filled with ! the rank of this processor. integer, allocatable :: data_out(:) ! MPI stuff: number of processors, rank of this processor, and error ! code. integer :: p, my_rank, ierr ! Loop indexes, and error handling. integer :: x, stat ! Initialize MPI, learn local rank and total number of processors. call MPI_Init(ierr) call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierr) call MPI_Comm_size(MPI_COMM_WORLD, p, ierr) ! Create some pretend data. We just need one row. allocate(data_out(p), stat = stat) if (stat .ne. 0) stop 3 do x = 1, p data_out(x) = my_rank end do ! Create the netCDF file. The NF90_NETCDF4 flag causes a ! HDF5/netCDF-4 file to be created. The comm and info parameters ! cause parallel I/O to be enabled. Use either NF90_MPIIO or ! NF90_MPIPOSIX to select between MPI/IO and MPI/POSIX. call check(nf90_create(FILE_NAME, IOR(NF90_NETCDF4, NF90_MPIIO), ncid, & comm = MPI_COMM_WORLD, info = MPI_INFO_NULL)) ! Define the dimensions. NetCDF will hand back an ID for ! each. Metadata operations must take place on all processors. call check(nf90_def_dim(ncid, "x", p, x_dimid)) call check(nf90_def_dim(ncid, "y", p, y_dimid)) ! The dimids array is used to pass the IDs of the dimensions of ! the variables. Note that in fortran arrays are stored in ! column-major format. dimids = (/ y_dimid, x_dimid /) ! Define the variable. The type of the variable in this case is ! NF90_INT (4-byte integer). call check(nf90_def_var(ncid, "data", NF90_INT, dimids, varid)) ! End define mode. This tells netCDF we are done defining ! metadata. This operation is collective and all processors will ! write their metadata to disk. call check(nf90_enddef(ncid)) ! Write the pretend data to the file. Each processor writes one row. start = (/ 1, my_rank + 1/) count = (/ p, 1 /) call check(nf90_put_var(ncid, varid, data_out, start = start, & count = count)) ! Close the file. This frees up any internal netCDF resources ! associated with the file, and flushes any buffers. call check( nf90_close(ncid) ) ! Free my local memory. deallocate(data_out) ! MPI library must be shut down. call MPI_Finalize(ierr) if (my_rank .eq. 0) print *, "*** SUCCESS writing example file ", FILE_NAME, "! " contains subroutine check(status) integer, intent ( in) :: status if(status /= nf90_noerr) then print *, trim(nf90_strerror(status)) stop 2 end if end subroutine check end program simple_xy_par_wr
! This is part of the netCDF package. ! Copyright 2008 University Corporation for Atmospheric Research/Unidata. ! See COPYRIGHT file for conditions of use. ! This is a simple example which reads a small dummy array, from a ! netCDF data file created by the companion program ! simple_xy_par_wr.f90. The data are read using parallel I/O. ! This is intended to illustrate the use of the netCDF fortran 90 ! API. This example program is part of the netCDF tutorial, which can ! be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial ! Full documentation of the netCDF Fortran 90 API can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90 ! $Id: simple_xy_par_rd.f90,v 1.2 2009/03/12 18:30:41 ed Exp $ program simple_xy_par_rd use netcdf implicit none include 'mpif.h' ! This is the name of the data file we will read. character (len = *), parameter :: FILE_NAME = "simple_xy_par.nc" ! These will tell where in the data file this processor should ! write. integer, parameter :: NDIMS = 2 integer :: start(NDIMS), count(NDIMS) ! We will read data into this array. integer, allocatable :: data_in(:) ! This will be the netCDF ID for the file and data variable. integer :: ncid, varid ! MPI stuff: number of processors, rank of this processor, and error ! code. integer :: p, my_rank, ierr ! Loop indexes, and error handling. integer :: x, y, stat ! Initialize MPI, learn local rank and total number of processors. call MPI_Init(ierr) call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierr) call MPI_Comm_size(MPI_COMM_WORLD, p, ierr) ! Allocate space to read in data. allocate(data_in(p), stat = stat) if (stat .ne. 0) stop 3 ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to ! the file. call check( nf90_open(FILE_NAME, IOR(NF90_NOWRITE, NF90_MPIIO), ncid, & comm = MPI_COMM_WORLD, info = MPI_INFO_NULL) ) ! Get the varid of the data variable, based on its name. call check( nf90_inq_varid(ncid, "data", varid) ) ! Read the data. start = (/ 1, my_rank + 1/) count = (/ p, 1 /) call check( nf90_get_var(ncid, varid, data_in, & start = start, count = count) ) ! Check the data. do x = 1, p if (data_in(x) .ne. my_rank) then print *, "data_in(", x, ") = ", data_in(x) stop "Stopped" endif end do ! Close the file, freeing all resources. call check( nf90_close(ncid) ) ! Free my local memory. deallocate(data_in) ! MPI library must be shut down. call MPI_Finalize(ierr) if (my_rank .eq. 0) print *,"*** SUCCESS reading example file ", FILE_NAME, "! " contains subroutine check(status) integer, intent ( in) :: status if(status /= nf90_noerr) then print *, trim(nf90_strerror(status)) stop 2 end if end subroutine check end program simple_xy_par_rd
NetCDF continues under active development at Unidata (see http://www.unidata.ucar.edu).
The next few releases of netCDF will include:
Any existing netCDF applications can be converted to generate netCDF-4/HDF5 files. Simply change the file creation call to include the correct mode flag.
For example, in one of the C examples which write a data file, change the nc_create call so that NC_NETCDF4 is one of the flags set on the create.
The corresponding read example will work without modification; netCDF will notice that the file is a NetCDF-4/HDF5 file, and will read it automatically, just as if it were a netCDF classic format file.
In the example in this section we show some of the advanced features of netCDF-4. More examples will be added in future releases.
This example, like the simple_xy netCDF-3 example above, is an overly simplified example which demonstrates how to use groups in a netCDF-4 file.
This example is only available in C for this version of netCDF-4. The example creates and then reads the file “simple_nc4.nc.”
The simple_xy.nc data file contains two dimensions, “x” and “y”, two groups, “grp1” and “grp2”, and two data variables, one in each group, both named: “data.” One data variable is an unsigned 64-bit integer, the other a user-defined compound type.
The example program simple_nc4_wr.c creates the example data file simple_nc4.nc. The example program simple_nc4_rd.c reads the data file.
For this release, only a C language version of this example is provided. Other APIs will be demonstrated in examples in future releases.
/* This is part of the netCDF-4 package. Copyright 2007 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is a very simple example which demonstrates some of the new features of netCDF-4.0. We create two shared dimensions, "x" and "y", in a parent group, and some netCDF variables in different subgroups. The variables will include a compound and an enum type, as well as some of the new atomic types, like the unsigned 64-bit integer. This example demonstrates the netCDF-4 C API. This is part of the netCDF tutorial, which can be found at: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial.html To understand this example program, users should have a good understanding of the netCDF-3 API. See the example program simple_xy_wr.c for a netCDF-3 example. Full documentation of the netCDF-4 C API can be found at: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c.html $Id: simple_nc4_wr.c,v 1.4 2008/06/19 13:29:18 ed Exp $ */ #include <stdlib.h> #include <stdio.h> #include <netcdf.h> /* This is the name of the data file we will create. */ #define FILE_NAME "simple_nc4.nc" /* We are writing 2D data, a 6 x 12 grid. */ #define NDIMS 2 #define NX 6 #define NY 12 /* Handle errors by printing an error message and exiting with a * non-zero status. */ #define ERRCODE 2 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} int main() { /* When we create netCDF variables, groups, dimensions, or types, * we get back an ID for each one. */ int ncid, x_dimid, y_dimid, varid1, varid2, grp1id, grp2id, typeid; int dimids[NDIMS]; /* This is the data array we will write. It will be filled with a * progression of numbers for this example. */ unsigned long long data_out[NX][NY]; /* Loop indexes, and error handling. */ int x, y, retval; /* The following struct is written as a compound type. */ struct s1 { int i1; int i2; }; struct s1 compound_data[NX][NY]; /* Create some pretend data. */ for (x = 0; x < NX; x++) for (y = 0; y < NY; y++) { data_out[x][y] = x * NY + y; compound_data[x][y].i1 = 42; compound_data[x][y].i2 = -42; } /* Create the file. The NC_NETCDF4 flag tells netCDF to * create a netCDF-4/HDF5 file.*/ if ((retval = nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid))) ERR(retval); /* Define the dimensions in the root group. Dimensions are visible * in all subgroups. */ if ((retval = nc_def_dim(ncid, "x", NX, &x_dimid))) ERR(retval); if ((retval = nc_def_dim(ncid, "y", NY, &y_dimid))) ERR(retval); /* The dimids passes the IDs of the dimensions of the variable. */ dimids[0] = x_dimid; dimids[1] = y_dimid; /* Define two groups, "grp1" and "grp2." */ if ((retval = nc_def_grp(ncid, "grp1", &grp1id))) ERR (retval); if ((retval = nc_def_grp(ncid, "grp2", &grp2id))) ERR (retval); /* Define an unsigned 64bit integer variable in grp1, using dimensions * in the root group. */ if ((retval = nc_def_var(grp1id, "data", NC_UINT64, NDIMS, dimids, &varid1))) ERR(retval); /* Write unsigned long long data to the file. For netCDF-4 files, * nc_enddef will be called automatically. */ if ((retval = nc_put_var_ulonglong(grp1id, varid1, &data_out[0][0]))) ERR(retval); /* Create a compound type. This will cause nc_reddef to be called. */ if (nc_def_compound(grp2id, sizeof(struct s1), "sample_compound_type", &typeid)) ERR(retval); if (nc_insert_compound(grp2id, typeid, "i1", offsetof(struct s1, i1), NC_INT)) ERR(retval); if (nc_insert_compound(grp2id, typeid, "i2", offsetof(struct s1, i2), NC_INT)) ERR(retval); /* Define a compound type variable in grp2, using dimensions * in the root group. */ if ((retval = nc_def_var(grp2id, "data", typeid, NDIMS, dimids, &varid2))) ERR(retval); /* Write the array of struct to the file. This will cause nc_endef * to be called. */ if ((retval = nc_put_var(grp2id, varid2, &compound_data[0][0]))) ERR(retval); /* Close the file. */ if ((retval = nc_close(ncid))) ERR(retval); printf("*** SUCCESS writing example file simple_nc4.nc!\n"); return 0; }
/* This is part of the netCDF package. Copyright 2006 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is a very simple example which demonstrates some of the new features of netCDF-4.0. This example reads a simple file created by simple_nc4_wr.c. This is intended to illustrate the use of the netCDF-4 C API. This program is part of the netCDF tutorial: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial.html Full documentation of the netCDF C API can be found at: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c.html $Id: simple_nc4_rd.c,v 1.3 2008/06/19 13:29:18 ed Exp $ */ #include <stdlib.h> #include <stdio.h> #include <netcdf.h> /* This is the name of the data file we will read. */ #define FILE_NAME "simple_nc4.nc" /* We are reading 2D data, a 6 x 12 grid. */ #define NX 6 #define NY 12 /* Handle errors by printing an error message and exiting with a * non-zero status. */ #define ERRCODE 2 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} int main() { /* There will be netCDF IDs for the file, each group, and each * variable. */ int ncid, varid1, varid2, grp1id, grp2id; unsigned long long data_in[NX][NY]; /* Loop indexes, and error handling. */ int x, y, retval; /* The following struct is written as a compound type. */ struct s1 { int i1; int i2; }; struct s1 compound_data[NX][NY]; /* Open the file. NC_NOWRITE tells netCDF we want read-only access * to the file.*/ if ((retval = nc_open(FILE_NAME, NC_NOWRITE, &ncid))) ERR(retval); /* Get the group ids of our two groups. */ if ((retval = nc_inq_ncid(ncid, "grp1", &grp1id))) ERR(retval); if ((retval = nc_inq_ncid(ncid, "grp2", &grp2id))) ERR(retval); /* Get the varid of the uint64 data variable, based on its name, in * grp1. */ if ((retval = nc_inq_varid(grp1id, "data", &varid1))) ERR(retval); /* Read the data. */ if ((retval = nc_get_var_ulonglong(grp1id, varid1, &data_in[0][0]))) ERR(retval); /* Get the varid of the compound data variable, based on its name, * in grp2. */ if ((retval = nc_inq_varid(grp2id, "data", &varid2))) ERR(retval); /* Read the data. */ if ((retval = nc_get_var(grp2id, varid2, &compound_data[0][0]))) ERR(retval); /* Check the data. */ for (x = 0; x < NX; x++) for (y = 0; y < NY; y++) { if (data_in[x][y] != x * NY + y || compound_data[x][y].i1 != 42 || compound_data[x][y].i2 != -42) return ERRCODE; } /* Close the file, freeing all resources. */ if ((retval = nc_close(ncid))) ERR(retval); printf("*** SUCCESS reading example file %s!\n", FILE_NAME); return 0; }
This example, like the simple_xy netCDF-3 example above, is an overly simplified example. It is based on the simple_xy example, but used data chunking, compression, and the fletcher32 filter.
(These are all HDF5 features. For more information see http://hdfgroup.org/HDF5/).
This example is not yet available in C++. We hope to have the C++ example in a future release of netCDF.
The example creates and then reads the file “simple_xy_nc4.nc.”
The example program simple_xy_nc4_wr.c creates the example data file simple_xy_nc4.nc. The example program simple_xy_nc4_rd.c reads the data file.
This is just like the simple_xy example, but with chunking and variable compression.
/* This is part of the netCDF package. Copyright 2007 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is a very simple example which is based on the simple_xy example, but whch uses netCDF-4 features, such as compression. Please see the simple_xy example to learn more about the netCDF-3 API. Like simple_xy_wr.c, this program writes a 2D netCDF variable (called "data") and fills it with sample data. It has two dimensions, "x" and "y". This example demonstrates the netCDF C API, and netCDF-4 extensions. This is part of the netCDF-4 tutorial, which can be found at: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-tutorial Full documentation of the netCDF C API, including netCDF-4 extensions, can be found at: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-c $Id: simple_xy_nc4_wr.c,v 1.6 2008/12/11 16:40:05 russ Exp $ */ #include <stdlib.h> #include <stdio.h> #include <netcdf.h> /* This is the name of the data file we will create. */ #define FILE_NAME "simple_xy_nc4.nc" /* We are writing 2D data, a 6 x 12 grid. */ #define NDIMS 2 #define NX 60 #define NY 120 /* Handle errors by printing an error message and exiting with a * non-zero status. */ #define ERRCODE 2 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} int main() { int ncid, x_dimid, y_dimid, varid; int dimids[NDIMS]; size_t chunks[NDIMS]; int shuffle, deflate, deflate_level; int data_out[NX][NY]; int x, y, retval; /* Set chunking, shuffle, and deflate. */ shuffle = NC_SHUFFLE; deflate = 1; deflate_level = 1; /* Create some pretend data. If this wasn't an example program, we * would have some real data to write, for example, model output. */ for (x = 0; x < NX; x++) for (y = 0; y < NY; y++) data_out[x][y] = x * NY + y; /* Create the file. The NC_NETCDF4 parameter tells netCDF to create * a file in netCDF-4/HDF5 standard. */ if ((retval = nc_create(FILE_NAME, NC_NETCDF4, &ncid))) ERR(retval); /* Define the dimensions. */ if ((retval = nc_def_dim(ncid, "x", NX, &x_dimid))) ERR(retval); if ((retval = nc_def_dim(ncid, "y", NY, &y_dimid))) ERR(retval); /* Set up variabe data. */ dimids[0] = x_dimid; dimids[1] = y_dimid; chunks[0] = NX/4; chunks[1] = NY/4; /* Define the variable. */ if ((retval = nc_def_var(ncid, "data", NC_INT, NDIMS, dimids, &varid))) ERR(retval); if ((retval = nc_def_var_chunking(ncid, varid, 0, &chunks[0]))) ERR(retval); if ((retval = nc_def_var_deflate(ncid, varid, shuffle, deflate, deflate_level))) ERR(retval); /* No need to explicitly end define mode for netCDF-4 files. Write * the pretend data to the file. */ if ((retval = nc_put_var_int(ncid, varid, &data_out[0][0]))) ERR(retval); /* Close the file. */ if ((retval = nc_close(ncid))) ERR(retval); printf("*** SUCCESS writing example file simple_xy_nc4.nc!\n"); return 0; }
/* This is part of the netCDF package. Copyright 2007 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for conditions of use. This is a very simple example which is based on the simple_xy example, but whch uses netCDF-4 features, such as compression. Please see the simple_xy example to learn more about the netCDF-3 API. Like simple_xy_rd.c, this example reads a small dummy array, which was written by simple_xy_wr.c, and is compressed. This is intended to illustrate the use of the netCDF C API. This program is part of the netCDF-4 tutorial: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-tutorial Full documentation of the netCDF-4 C API can be found at: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-c $Id: simple_xy_nc4_rd.c,v 1.2 2007/06/05 21:47:50 ed Exp $ */ #include <config.h> #include <stdlib.h> #include <stdio.h> #include <netcdf.h> /* This is the name of the data file we will read. */ #define FILE_NAME "simple_xy_nc4.nc" /* We are reading 2D data, a 6 x 12 grid. */ #define NX 60 #define NY 120 /* Handle errors by printing an error message and exiting with a * non-zero status. */ #define ERRCODE 2 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} int main() { /* This will be the netCDF ID for the file and data variable. */ int ncid, varid; int data_in[NX][NY]; /* Loop indexes, and error handling. */ int x, y, retval; /* Open the file. NC_NOWRITE tells netCDF we want read-only access * to the file.*/ if ((retval = nc_open(FILE_NAME, NC_NOWRITE, &ncid))) ERR(retval); /* Get the varid of the data variable, based on its name. */ if ((retval = nc_inq_varid(ncid, "data", &varid))) ERR(retval); /* Read the data. */ if ((retval = nc_get_var_int(ncid, varid, &data_in[0][0]))) ERR(retval); /* Check the data. */ for (x = 0; x < NX; x++) for (y = 0; y < NY; y++) if (data_in[x][y] != x * NY + y) return ERRCODE; /* Close the file, freeing all resources. */ if ((retval = nc_close(ncid))) ERR(retval); printf("*** SUCCESS reading example file %s!\n", FILE_NAME); return 0; }
This is just like the simple_xy example, but with chunking and variable compression.
C This is part of the netCDF package. C Copyright 2006 University Corporation for Atmospheric Research/Unidata. C See COPYRIGHT file for conditions of use. C This is a very simple example which writes a 2D array of C sample data. To handle this in netCDF we create two shared C dimensions, "x" and "y", and a netCDF variable, called "data". C This example demonstrates the netCDF Fortran 77 API. This is part C of the netCDF tutorial, which can be found at: C http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial C Full documentation of the netCDF Fortran 77 API can be found at: C http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77 C $Id: simple_xy_nc4_wr.f,v 1.5 2008/02/19 22:01:49 ed Exp $ program simple_xy_wr implicit none include 'netcdf.inc' character*(*) FILE_NAME parameter (FILE_NAME='simple_xy_nc4.nc') integer NDIMS parameter (NDIMS = 2) integer NX, NY parameter (NX = 60, NY = 120) integer ncid, varid, dimids(NDIMS) integer x_dimid, y_dimid integer data_out(NY, NX) integer x, y, retval integer chunks(2) integer contiguous, shuffle, deflate, deflate_level C Create some pretend data. If this wasn't an example program, we C would have some real data to write, for example, model output. do x = 1, NX do y = 1, NY data_out(y, x) = (x - 1) * NY + (y - 1) end do end do C Create the netCDF file. The nf_netcdf4 tells netCDF to C create a netCDF-4/HDF5 file. retval = nf_create(FILE_NAME, NF_NETCDF4, ncid) if (retval .ne. nf_noerr) call handle_err(retval) C Define the dimensions. retval = nf_def_dim(ncid, "x", NX, x_dimid) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_def_dim(ncid, "y", NY, y_dimid) if (retval .ne. nf_noerr) call handle_err(retval) C The dimids array is used to pass the IDs of the dimensions of C the variables. Note that in fortran arrays are stored in C column-major format. dimids(2) = x_dimid dimids(1) = y_dimid C Define the variable. retval = nf_def_var(ncid, "data", NF_INT, NDIMS, dimids, varid) if (retval .ne. nf_noerr) call handle_err(retval) C Set up chunking and compression. contiguous = 0 chunks(1) = NY chunks(2) = NX shuffle = 1 deflate = 1 deflate_level = 4 retval = nf_def_var_chunking(ncid, varid, contiguous, chunks) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_def_var_deflate(ncid, varid, shuffle, deflate, & deflate_level) if (retval .ne. nf_noerr) call handle_err(retval) C Write the pretend data to the file. retval = nf_put_var_int(ncid, varid, data_out) if (retval .ne. nf_noerr) call handle_err(retval) C Close the file. retval = nf_close(ncid) if (retval .ne. nf_noerr) call handle_err(retval) print *,'*** SUCCESS writing example file simple_xy_nc4.nc!' end subroutine handle_err(errcode) implicit none include 'netcdf.inc' integer errcode print *, 'Error: ', nf_strerror(errcode) stop 2 end
C This is part of the netCDF package. C Copyright 2006 University Corporation for Atmospheric Research/Unidata. C See COPYRIGHT file for conditions of use. C This is a simple example which reads a small dummy array, from a C netCDF data file created by the companion program simple_xy_wr.f. C This is intended to illustrate the use of the netCDF fortran 77 C API. This example program is part of the netCDF tutorial, which can C be found at: C http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial C Full documentation of the netCDF Fortran 77 API can be found at: C http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77 C $Id: simple_xy_nc4_rd.f,v 1.1 2007/05/04 13:33:20 ed Exp $ program simple_xy_rd implicit none include 'netcdf.inc' C This is the name of the data file we will read. character*(*) FILE_NAME parameter (FILE_NAME='simple_xy_nc4.nc') C We are reading 2D data, a 12 x 6 grid. integer NX, NY parameter (NX = 60, NY = 120) integer data_in(NY, NX) C This will be the netCDF ID for the file and data variable. integer ncid, varid C Loop indexes, and error handling. integer x, y, retval C Open the file. NF_NOWRITE tells netCDF we want read-only access to C the file. retval = nf_open(FILE_NAME, NF_NOWRITE, ncid) if (retval .ne. nf_noerr) call handle_err(retval) C Get the varid of the data variable, based on its name. retval = nf_inq_varid(ncid, 'data', varid) if (retval .ne. nf_noerr) call handle_err(retval) C Read the data. retval = nf_get_var_int(ncid, varid, data_in) if (retval .ne. nf_noerr) call handle_err(retval) C Check the data. do x = 1, NX do y = 1, NY if (data_in(y, x) .ne. (x - 1) * NY + (y - 1)) then print *, 'data_in(', y, ', ', x, ') = ', data_in(y, x) stop 2 end if end do end do C Close the file, freeing all resources. retval = nf_close(ncid) if (retval .ne. nf_noerr) call handle_err(retval) print *,'*** SUCCESS reading example file ', FILE_NAME, '!' end subroutine handle_err(errcode) implicit none include 'netcdf.inc' integer errcode print *, 'Error: ', nf_strerror(errcode) stop 2 end
This is just like the simple_xy example, but with chunking and variable compression.
! This is part of the netCDF package. Copyright 2006 University ! Corporation for Atmospheric Research/Unidata. See COPYRIGHT ! file for conditions of use. ! This is a very simple example which writes a 2D array of sample ! data. To handle this in netCDF we create two shared dimensions, ! "x" and "y", and a netCDF variable, called "data". ! This example demonstrates the netCDF Fortran 90 API. This is ! part of the netCDF tutorial, which can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial ! Full documentation of the netCDF Fortran 90 API can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90 ! $Id: simple_xy_nc4_wr.f90,v 1.6 2010/04/06 19:32:09 ed Exp $ program simple_xy_wr use netcdf implicit none character (len = *), parameter :: FILE_NAME = "simple_xy_nc4.nc" integer, parameter :: NDIMS = 2 integer, parameter :: NX = 6, NY = 12 integer :: ncid, varid, dimids(NDIMS) integer :: x_dimid, y_dimid integer :: data_out(NY, NX) integer :: chunks(2) integer :: deflate_level integer :: x, y ! Create some pretend data. If this wasn't an example program, we ! would have some real data to write, for example, model output. do x = 1, NX do y = 1, NY data_out(y, x) = (x - 1) * NY + (y - 1) end do end do ! Always check the return code of every netCDF function call. In ! this example program, wrapping netCDF calls with "call check()" ! makes sure that any return which is not equal to nf90_noerr (0) ! will print a netCDF error message and exit. ! Create the netCDF file. The nf90_clobber parameter tells netCDF to ! overwrite this file, if it already exists. call check( nf90_create(FILE_NAME, nf90_hdf5, ncid) ) ! Define the dimensions. NetCDF will hand back an ID for each. call check( nf90_def_dim(ncid, "x", NX, x_dimid) ) call check( nf90_def_dim(ncid, "y", NY, y_dimid) ) ! The dimids array is used to pass the IDs of the dimensions of ! the variables. Note that in fortran arrays are stored in ! column-major format. dimids = (/ y_dimid, x_dimid /) ! Define the variable. The type of the variable in this case is ! NF90_INT (4-byte integer). Optional parameters chunking, shuffle, ! and deflate_level are used. chunks(1) = NY chunks(2) = NX deflate_level = 1 call check( nf90_def_var(ncid, "data", NF90_INT, dimids, varid, & chunksizes = chunks, shuffle = .TRUE., deflate_level = deflate_level) ) ! End define mode. This tells netCDF we are done defining metadata. call check( nf90_enddef(ncid) ) ! Write the pretend data to the file. Although netCDF supports ! reading and writing subsets of data, in this case we write all the ! data in one operation. call check( nf90_put_var(ncid, varid, data_out) ) ! Close the file. This frees up any internal netCDF resources ! associated with the file, and flushes any buffers. call check( nf90_close(ncid) ) print *, '*** SUCCESS writing example file ', FILE_NAME, '!' contains subroutine check(status) integer, intent ( in) :: status if(status /= nf90_noerr) then print *, trim(nf90_strerror(status)) stop 2 end if end subroutine check end program simple_xy_wr
! This is part of the netCDF package. ! Copyright 2006 University Corporation for Atmospheric Research/Unidata. ! See COPYRIGHT file for conditions of use. ! This is a simple example which reads a small dummy array, from a ! netCDF data file created by the companion program simple_xy_wr.f90. ! This is intended to illustrate the use of the netCDF fortran 77 ! API. This example program is part of the netCDF tutorial, which can ! be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial ! Full documentation of the netCDF Fortran 90 API can be found at: ! http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90 ! $Id: simple_xy_nc4_rd.f90,v 1.3 2009/02/25 12:23:45 ed Exp $ program simple_xy_rd use netcdf implicit none ! This is the name of the data file and variable. character (len = *), parameter :: FILE_NAME = "simple_xy_nc4.nc" character (len = *), parameter :: VAR_NAME = "data" ! We are reading 2D data, a 12 x 6 grid. integer, parameter :: NX = 6, NY = 12, MAX_DIMS = 2 integer :: data_in(NY, NX) ! This will be the netCDF ID for the file and data variable. integer :: ncid, varid ! Information we will read about the variable. character (len = nf90_max_name) :: name integer :: xtype, ndims, dimids(MAX_DIMS), natts integer :: chunksizes(MAX_DIMS), deflate_level, endianness logical :: contiguous, shuffle, fletcher32 ! Loop indexes, and error handling. integer :: x, y ! Open the file. NF90_NOWRITE tells netCDF we want read-only access ! to the file. call check( nf90_open(FILE_NAME, NF90_NOWRITE, ncid) ) ! Get the varid of the data variable, based on its name. call check( nf90_inq_varid(ncid, VAR_NAME, varid) ) ! Learn about the variable. This uses all optional parameters. call check( nf90_inquire_variable(ncid, varid, name, xtype, ndims, & dimids, natts, contiguous = contiguous, chunksizes = chunksizes, & deflate_level = deflate_level, shuffle = shuffle, & fletcher32 = fletcher32, endianness = endianness) ) ! Make sure we got the correct answers. These depend on what was set ! when creating the file in simple_xy_nc4_wr.f90. Endianness will be ! whatever is native for the machine that's building this example. if (name .ne. VAR_NAME .or. xtype .ne. NF90_INT .or. ndims .ne. 2 .or. & natts .ne. 0 .or. contiguous .or. .not. shuffle .or. & deflate_level .ne. 1 .or. fletcher32) stop 3 ! Read the data. call check( nf90_get_var(ncid, varid, data_in) ) ! Check the data. do x = 1, NX do y = 1, NY if (data_in(y, x) /= (x - 1) * NY + (y - 1)) then print *, "data_in(", y, ", ", x, ") = ", data_in(y, x) stop "Stopped" end if end do end do ! Close the file, freeing all resources. call check( nf90_close(ncid) ) print *,"*** SUCCESS reading example file ", FILE_NAME, "! " contains subroutine check(status) integer, intent ( in) :: status if(status /= nf90_noerr) then print *, trim(nf90_strerror(status)) stop 2 end if end subroutine check end program simple_xy_rd
nc_close
: Creation in Cnc_create
: Creation in Cnc_def_dim
: Creation in Cnc_def_var
: Creation in Cnc_enddef
: Creation in Cnc_get_att
: Reading in Cnc_get_var1
: Subsetting in Cnc_get_vara
: Reading in Cnc_get_varm
: Subsetting in Cnc_get_vars
: Subsetting in Cnc_open
: Reading in Cnc_put_att
: Creation in Cnc_put_var1
: Subsetting in Cnc_put_vara
: Creation in Cnc_put_varm
: Subsetting in Cnc_put_vars
: Subsetting in CNcFile
: Reading in C++NF90_CLOSE
: Creation in F90NF90_CREATE
: Creation in F90NF90_DEF_DIM
: Creation in F90NF90_DEF_VAR
: Creation in F90NF90_ENDDEF
: Creation in F90NF90_GET_ATT
: Reading in F90NF90_GET_VAR1
: Subsetting in F90NF90_GET_VARA
: Reading in F90NF90_GET_VARM
: Subsetting in F90NF90_GET_VARS
: Subsetting in F90NF90_OPEN
: Reading in F90NF90_PUT_ATT_ type
: Creation in F90NF90_PUT_VAR1
: Subsetting in F90NF90_PUT_VARA
: Creation in F90NF90_PUT_VARM
: Subsetting in F90NF90_PUT_VARS
: Subsetting in F90NF_CLOSE
: Creation in F77NF_CREATE
: Creation in F77NF_DEF_DIM
: Creation in F77NF_DEF_VAR
: Creation in F77NF_ENDDEF
: Creation in F77NF_GET_ATT
: Reading in F77NF_GET_VAR1
: Subsetting in F77NF_GET_VARA
: Reading in F77NF_GET_VARM
: Subsetting in F77NF_GET_VARS
: Subsetting in F77NF_OPEN
: Reading in F77NF_PUT_ATT_ type
: Creation in F77NF_PUT_VAR1
: Subsetting in F77NF_PUT_VARA
: Creation in F77NF_PUT_VARM
: Subsetting in F77NF_PUT_VARS
: Subsetting in F77


<
Person
>
Developer
<
Name
>
Aditya Paruchuri
</
Name
>
<
Phone
>
(803) 804-6725
</
Phone
>
<
Education
>
<
College
from
=
"Aug 2016"
to
=
"May 2020"
>
Duke University
<
Degree
>
B.S. Computer Science
</
Degree
>
<
Minor
>
History
</
Minor
>
</
College
>
</
Education
>
<
Experience
>
<
Work
from
=
"May 2017"
to
=
"Aug 2017"
>
Allscripts
</
Work
>
<
Work
from
=
"Aug 2015"
to
=
"Current"
>
Fridayd
</
Work
>
</
Experience
>
<
Projects
>
<
Project
>
The Global Redirect
</
Project
>
<
Project
>
Know Your Openings
</
Project
>
</
Projects
>
</
Person
>


A collection of dynamically generated utility classes for offsetting positioned elements.
Class names follow the Emmet abbreviation
syntax, with colons (':') replaced by two dashes (--
) to follow BEM naming
conventions.
Available classes
.u-t--<amount>
: top
.u-end--<amount>
: horizontal end (right in ltr
, right in ltr
)
.u-r--<amount>
: right
.u-b--<amount>
: bottom
.u-start--<amount>
: horizontal start (left in ltr
, left in ltr
)
.u-l--<amount>
: left
Where <amount>
can be either a unitless number representing a number of
typographic rhythm units as defined in
$jigsass-sizes
a percentage, or a length specified in pixels.
JigSass Offset also supports negative offsets, using min-<number>
modifiers
(e.g., h-t--min-4
), as well as auto ofsets (e.g., h-b--auto
).
Installation
Using npm:
npm i -S jigsass-utils-offset
Usage
Import JigSass Utils Offset into your main scss file near its very end, together with all
other utilities (utilities should always be the last to be imported).
@import 'path/to/jigsass-utils-offset/scss/index';
Like all other JigSass Utils, JigSass Offset does not automatically generate any CSS
when imported. You would need to explicitly indicate that each individual offset
class should actually be generated in each component or object it is used in
(clarification: This will include style declarations inside .foo
and .bar
):
// _c.foo.scss
.foo {
@include jigsass-util(u-t, $modifier: 6px); // <-- top: 6px
...
}
// _c.bar.scss
.bar {
@include jigsass-util(u-b, $modifier: 12px); // <-- bottom: 12px
@include jigsass-util(u-b, $modifier: 0, $from: large); // <-- bottom: 0 from large bp and on.
...
}
Doing so helps us a great deal with portability, as no matter where we import component or object
partials, the correct utility classes will be generated. Think of it as a poor man's dependency
management.
Developer communication is also assisted by including "dependencies" wherever they are required,
as anyone going through a partial, can easily understand how it should be marked up with just a
glance.
As far as bloat goes, just don't worry about it - the actual styles will only be generated once,
at the location in the cascade where the Jigsass Offset partial was imported into the main file.
JigSass Offset classes are responsive-enabled, using JigSass MQ
and the breakpoints defined in the $jigsass-breakpoints variable.
Based on the breakpoint arguments passed to jigsass-util
when including a Offset class,
responsive modifiers are generated according to the following logic:
.u-t--<modifier>[-[-from-<breakpoint-name>][-until-<breakpoint-name>][-misc-<breakpoint-name>]]
So, assuming the medium
, large
and landscape
breakpoints are defined in $jigsass-breakpoints
as 600px
, 1024px
and (orientation: landscape)
respectively,
@include jigsass-util(u-t, $modifier: 2);
will generate the .u-t--2
class, which is not limited to any media-query.
@include jigsass-util(u-b, $modifier: min-4, $until: medium);
will generate the .u-b--min-4--until-medium
class, which will be in effect at
(max-width: 37.49em)
and will override styles in the default class until that point.
@include jigsass-util(u-l, $modifier: 20%, $from: large, $misc: landscape);
will generate the .u-l--20%--from-large-when-landscape
class, which will go into
effect at (min-width: 64em) and (orientation: landscape)
and will override styles in the default
class under these conditions.
License: MIT


Add box
Add ball
Start physics!
Reload
Let's have some physics fun
Please create the shapes as described in the challenge text on the right.


|
OPAE C API
-..
FPGA API
|
Functions for reading and clearing errors in resources. More...
#include <opae/types.h>
Go to the source code of this file.
Functions | |
| fpga_result | fpgaReadError (fpga_token token, uint32_t error_num, uint64_t *value) |
| fpga_result | fpgaClearError (fpga_token token, uint32_t error_num) |
| fpga_result | fpgaClearAllErrors (fpga_token token) |
| fpga_result | fpgaGetErrorInfo (fpga_token token, uint32_t error_num, struct fpga_error_info *error_info) |
Functions for reading and clearing errors in resources.
Many FPGA resources have the ability to track the occurrence of errors. This file provides functions to retrieve information about errors within resources.
Definition in file error.h.
| fpga_result fpgaReadError | ( | fpga_token | token, |
| uint32_t | error_num, | ||
| uint64_t * | value | ||
| ) |
Read error value
This function will read the value of error register error_num
of the resource referenced by token
into the memory location pointed to by value
.
| [in] | token | Token to accelerator resource to query |
| [in] | error_num | Number of error register to read |
| [out] | value | Pointer to memory to store error value into (64 bit) |
| fpga_result fpgaClearError | ( | fpga_token | token, |
| uint32_t | error_num | ||
| ) |
Clear error register
This function will clear the error register error_num
of the resource referenced by token
.
| [in] | token | Token to accelerator resource to query |
| [in] | error_num | Number of error register to clear |
| fpga_result fpgaClearAllErrors | ( | fpga_token | token | ) |
Clear all error registers of a particular resource
This function will clear all error registers of the resource referenced by token
, observing the necessary order of clearing errors, if any.
| [in] | token | Token to accelerator resource to query |
| fpga_result fpgaGetErrorInfo | ( | fpga_token | token, |
| uint32_t | error_num, | ||
| struct fpga_error_info * | error_info | ||
| ) |
Get information about a particular error register
This function will populate a fpga_error_info
struct with information about error number error_num
of the resource referenced by token
.
| [in] | token | Token to accelerator resource to query |
| [in] | error_num | Error register to retrieve information about |
| [out] | error_info | Pointer to memory to store information into |


The content filter plugin allows admins to configure various actions based on message content. These actions include notifying the admin of content matches, notifying the sender that a message was rejected or masking the content with alternative content.
Copy the contentfilter.jar into the plugins directory of your Jive Messenger installation. The plugin will then be automatically deployed. To upgrade to a new version, copy the new contentfilter.jar file over the existing file.
By default, after the plugin has been deployed all of its features are disabled. This plugin is configured via the "Content Filter" sidebar item located under the "System" tab in the Jive Messenger Admin Console.
The default comma separated patterns are "fox,dog". This will perform a case sensitive match on all words containing these strings. e.g. "fox", "firefox", "foxy", "dog", "hotdog", "dogdays" but not "Fox", "firefoX". These simple patterns can be enhanced with more complex regular expressions as required e.g.:
If you choose to filter your users presence status and there is a content match then:
Want to know more about regular expressions in Java? This official tutorial is useful.
The default mask is "***", you can change it to anything you like including smilies!
After the plugin has been configured, nothing else needs to be done to use it.
If the plugin behaviour is not as expected you can enable server debug logging. This will allow the plugin to start logging. Server debug logging should only be enabled temporarily, as it will generate a lot of additional logging that will both slow your server down and consume a lot of disk space.


| DOSE: T+ 0:00 |
100 mg |
oral |
AMT |
(powder / crystals) |
| T+ 1:00 |
1 repeated |
smoked |
Cannabis |
|
I was over at my friend B's house, and no one was going to be there until 5:00 PM. It was 7AM when we pulled out the somewhat fresh AMT. Since it was not completely fresh, I ate 100 mg, when I had previously done 80 when it wasn't as old. What follows are my experiences, separate 'dreams' that have their own world, their own distinct thoughts and feelings.
We divided up the AMT, me with my 100 mg, and my friend with about 110. We had our doses on some tin foil, and a glass of water to quickly dissolve the bad taste. My friend almost gagged when he ate his, and quickly drank his water. It did have an aweful taste, worse than any other drug i think i've ever done, but for me it wasn't intolerable. It's incredibly bitter, with a kind of soapy taste. I washed it down and started the waiting game.
The first thing I waited for was the nausea. At about 730, my stomach became very sick, and i finally puked all over the sink. This is the worst part of AMT, but once it's over, I'm in for a good ride. I guess it just wants to get rid of everything else in my body so it can work its 'magic'.
After about 45 minutes to an hour is when i started feeling its effects. The very first thing I feel is a kind of high feeling, like cannabis, very peaceful, like I'm not really waiting for anything to happen, just there. I remember feeling the coldness of the house, but at the same time i felt warm and comfortable. As we wandered around the house i noticed my eyes seeing light and dark much more distinctly, and then i started seeing trails. I moved over to a door where there were vertical blinds. The air moving around the house had gotten the blinds swaying in a sort of wave motion.
I remember how incredibly peaceful it was just standing there watching this simple thing. Anyway, after about an hour, we went downstairs, before the full effects were felt, and lit up a bowl or two of cannabis. This is when the rollercoaster really took off. I remember taking my friends advice, and tried my best not to go to sleep on a psychadelic drug. Luckily i was able to keep my eyes open for about a full 18-20 hrs. So there i was, after smoking, unable to even move. My friend put on aphex twin, rhubarb and lichen, i think some other songs. As I listened to this mellow, flowing tune my friend and I split up as it was impossible to communicate right then. What follows is the first real trip i've had.
The notes flowed up and down, and i just looked up at the ceiling. Everything i looked at had it's own personality, its own existence or world. The ceiling moved in swirls, and i could feel what i was seeing. At this point i sat up and the stuff really kicked in. I put my head in my hands and just started rubbing my head. The sensation it gave was unbelievable. It felt like my head was the only thing that existed, and whatever i looked at was where i was traveling, like a ghost wandering through eternity. Whatever was right in front of me was the focus, and peripheral vision was just a blur rushing past me. During this portion of the trip, the Radiohead song 'Everything in its right place' started playing. For the first time, this song made so much sense. and it was so simple. Everything was in its right place. And for a time, all i could see were two colors (this is part of the song also if you are familiar with it).
The next incredible visual I had was in the living room. Here i sat, staring at the TV and windows (TV off). I remember the room was sort of divided into two shades. the top half was lighter because of the light from the windows and the bottom was dark. After a minute or two, the two colors were distinctly divided, and they were moving in waves. Then they settled and formed a yin-yang. This started spinning slowly and i sat and had some very religious thoughts. I'm not budhist, but that symbol has special meaning for me now.
It's awesome how much sense I could make from the words of songs like 'everything in its right place' and 'comfortably numb'. At AMT's peak, everything did move in waves, and when my friend was talking, i could hear a word of it, though I remember his lips moving.
Friend B's dad was due home any minute now (7PM) and so as the trip was done, we made our way to the car. From this point on, we were rolling, just that comfortable high feeling. Sense of time was completely destroyed, as it felt like the whole day lasted an hour or so. We went to a movie, which felt like about 10 minutes. I also remember the long conversations my friend and i had while just rolling. We could talk about one thing forever.
[Erowid Note: Driving while intoxicated or tripping is dangerous and irresponsible because it endangers other people. Don't do it!]
Here's my personal feelings on drugs, take from it what you will.  But I've had some of the best experiences with them. No one is really sure what the long term effects, if any, of drugs like AMT is, but truly, i really don't care. We're all gonna die at some point, not meaning i don't want to live of course. Tripping certainly is a life changing experience. That sounds like some sort of psychological bull, but i'll try to explain. Yeah, I get new insights and new feelings on life, but I keep it in perspective. It is after all just a synthetic substance put into my body. I enjoy the effects, and remember the thoughts I had while on it, but I don't let it drag me down. I just try and keep the normal life and the drug life separate. I think thats the safest way. And of course, I smoke hash as much as possible.
Well, i guess thats about all i can come up with at 2:40 in the morning. Peace
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Survey Form
Let us know how we can improve freeCodeCamp
Name
Email
Number
Which option best describes your current role?
challenges
Full Time Job
Full Time Learner
Prefer not to Say
Other
* How likely is that you would recommend freeCodeCamp to a friend?
Definitely
Maybe
Not Sure
What do you like the most in FCC
Student
Projects
Community
Open source
Things that should be improved in the future (Check all that apply):
Front End Projects
Back End Projects
Data Visualization
Challenges
Open Source Community
Gitter help rooms
Videos
City Meetups
Wiki
Forum
Additional Resources
Any Comments or Suggestions?
Submit


Objects
A JavaScript object is a flexible data type that stores multiple values. Each value is identified by a unique property name within the object. The syntax for declaring an object is similar to CSS.
var person = { firstName: "John", lastName: "Smith", age: 33 };
An object property can be another object.
var person = { firstName: "John", lastName: "Smith", age: 33, address: { street: "12345 College Blvd", city: "Overland Park", state: "KS", zip: "66210" } };
Object properties are accessed using a dot or bracket notation.
person.firstName; person['firstName']; person.lastName; person['lastName']; person.address.state; person.address['state']; person['address'].state; person['address']['state'];
How would you create an object that represents a product in a catalog?


Maks' Portfolio Assignment
Code Fellows Calendar
Latest Group Project
Github Account
fixedBack image 1 text placeholder
Here's your lucky number today, click it to multiply your luck:


{%extends 'base.html'%} {%block content%}
“Great photography is about depth of feeling, not depth of field.”
{{ image.location.location_name | title }}


module Signal
Many operating systems allow signals to be sent to running processes. Some signals have a defined effect on the process, while others may be trapped at the code level and acted upon. For example, your process may trap the USR1 signal and use it to toggle debugging, and may use TERM to initiate a controlled shutdown.
pid = fork do Signal.trap("USR1") do $debug = !$debug puts "Debug now: #$debug" end Signal.trap("TERM") do puts "Terminating..." shutdown() end # . . . do some work . . . end Process.detach(pid) # Controlling program: Process.kill("USR1", pid) # ... Process.kill("USR1", pid) # ... Process.kill("TERM", pid)
produces:
Debug now: true Debug now: false Terminating...
The list of available signal names and their interpretation is system dependent. Signal delivery semantics may also vary between systems; in particular signal delivery may not always be reliable.
Public Class Methods
Returns a list of signal names mapped to the corresponding underlying signal numbers.
Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
static VALUE sig_list(void) { VALUE h = rb_hash_new(); const struct signals *sigs; for (sigs = siglist; sigs->signm; sigs++) { rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo)); } return h; }
Convert signal number to signal name. Returns nil
if the signo
is an invalid signal number.
Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0)
produces:
INT
static VALUE sig_signame(VALUE recv, VALUE signo) { const char *signame = signo2signm(NUM2INT(signo)); if (!signame) return Qnil; return rb_str_new_cstr(signame); }
Specifies the handling of signals. The first parameter is a signal name (a string such as “SIGALRM'', “SIGUSR1'', and so on) or a signal number. The characters “SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string “IGNORE'' or “SIG_IGN'', the signal will be ignored. If the command is “DEFAULT'' or “SIG_DFL'', the Ruby's default handler will be invoked. If the command is “EXIT'', the script will be terminated by the signal. If the command is “SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name “EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal.
Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait
produces:
Terminating: 27461 Child died Terminating: 27460
static VALUE sig_trap(int argc, VALUE *argv) { int sig; sighandler_t func; VALUE cmd; rb_check_arity(argc, 1, 2); sig = trap_signm(argv[0]); if (reserved_signal_p(sig)) { const char *name = signo2signm(sig); if (name) rb_raise(rb_eArgError, "can't trap reserved signal: SIG%s", name); else rb_raise(rb_eArgError, "can't trap reserved signal: %d", sig); } if (argc == 1) { cmd = rb_block_proc(); func = sighandler; } else { cmd = argv[1]; func = trap_handler(&cmd, sig); } if (OBJ_TAINTED(cmd)) { rb_raise(rb_eSecurityError, "Insecure: tainted signal trap"); } return trap(sig, func, cmd); }


Intro
Transcript By: Bryan Bishop
Category: Conference
Intro
Video: https://youtu.be/CyieujRFk3g
Whalepanda
Hello? Ladies and gentlemen, please take your seats and we’re going to start now. Good afternoon everyone. I’m a self-proclaimed VP of operations and swag for this crypto conference. I’m also a friend of the Magical Crypto Friends. I’m very happy to see the turnout for this conference. I see people who are clearly passionate based on the way they dress. Thank you all for coming. I am going to ask a question. What’s your favorite thing about this conference so far? Nothing about ICOs. I like that answer. I like your shirt also. My shirt says “Satoshi is Black” ((applause)). “He’s a woman, too”. Looks like we’re ready now. Without further adue, here are the crypto friends to come on stage.
Introduction
This is the real Riccardo. Remotely. “Hello people”.
WP: Welcome everyone to the first and last Magical Crypto Conference in New York. I will start with some practical information. If you take pictures, we encourage it, but please ask permission if other people are in it. Also tag us, it’s MCC2019. Use the right hashtag.
CL: We have a a harassment policy. Don’t shill ICOs to other people. It’s not worth it. If you have issues, we have purple kraken sponsor t-shirts that say “FRIEND” on it.
SM: It’s the “Magical Crypto Friends friend” t-shirt. It’s the most awkward we could make it. We also have wifi. The ssid is “Infinite Fleet” and the password is “tether2themoon”. That was your idea. We had wifi for 500 people. I think we’re over 500 people. If there are issues, we will deal with it. Tweet at me, and then we’ll see.
CL: You shouldn’t use wifi anyway, because spooks.
 If you lose your badge, then you won’t be able to get in tomorrow. You’ll have to buy a new ticket. Outside there are two food trucks. Tomorrow there will be three. IT’s free for speakers and VIPs.
SM: If you see a VIP person, please let them cut in front of you in line. We’re serious. And in the bathroom. Everyone should have their swag bag. Every bag has a random doll or coin. I think the coins are in sequence. We have a booth in the back corner, staffed by Cindy and a few different people. They are selling Magical Crypto Friends t-shirts and some other gear. We ask that if you don’t want a doll, then don’t try to come to our booth and try to exchange it for a different one. You’re welcome to use our magical crypto DEX where you can p2p trade with other people.
CL: After the conference, we have a sponsored party. It’s at 630 at One Oak. Since tomorrow starts at 10am, please feel free to party as long as it takes. Come back refreshed tomorrow.
WP: If you lose your badge, then just buy a new ticket.
SM: For the speakers, you get miced up over there. Please be on time. If you go over the time limit, one of our magical crypto friends friend will tackle you on stage. So don’t go over time.
WP: We will record a live MCF show at 530pm. Everything is live, except for one talk which will not be livestreamed where the speaker has asked to not livehand. The MCF episode will be about an hour and it will have Q&A. All the other talks do not have Q&A.
CL: You can take the stairs in the back next to the bull to get to the second floor with the other talks. There are 300 seats there. So how cool is the bull? Now we know why the price is going up. It’s the MCC bullrun.
SM: We also have a special contest to announce. Allen, are you there? Can you share the pictures of the lambos? We’re giving away six lambos. There are four colored lambos, one color for each of us. These will be given out for random attendees, and two others for a contest.
WP: Whoever can take the best most original picture of the cutouts. Or whoever can take the coolest picture of the bull. Don’t mess with the bull. It’s at your own risk. It’s a MCC lambo, if you take that with the picture, we will decide which is the best one tomorrow and you will get a free lambo.
SM: We will draw it in a coffee break.
CL: These lambos are sponsored by our gold sponsors. They don’t know it yet. Surprise.
WP: Pulling this out was quite an underatken. Thank you to our gold sponsors, bitstamp and others. Thank you to the secondary sponsors, and the bronze sponsors.
SM: This includes Litecoin Foundation, slushpool, bitfury, and Blockstream….
CL: Trail of Bits too. Thanks a lot.
WP: For btc.se, they organized the party this evening. Thanks mex and for the coffee cups. Intoro for the lanyards. Kraken for the t-shirts. Pixelmatic for wifi.
SM: Scan the back of your card, there’s bitcoin there.
CL: Make sure your badges are forward or else nobody will know who you are.
SM: We will air the first ever live animated MCF short. Should we cut the lights?


| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | package org.apache.commons.math3.analysis.function; | |
| 19 | ||
| 20 | import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction; | |
| 21 | import org.apache.commons.math3.analysis.differentiation.DerivativeStructure; | |
| 22 | import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction; | |
| 23 | ||
| 24 | /** | |
| 25 | * Identity function. | |
| 26 | * | |
| 27 | * @since 3.0 | |
| 28 | * @version $Id$ | |
| 29 | */ | |
| 30 | public class Identity implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction { | |
| 31 | /** {@inheritDoc} */ | |
| 32 | public double value(double x) { | |
| 33 |
1
1. value : replaced return of double value with -(x + 1) for org/apache/commons/math3/analysis/function/Identity::value → KILLED |
return x; |
| 34 | } | |
| 35 | ||
| 36 | /** {@inheritDoc} | |
| 37 | * @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)} | |
| 38 | */ | |
| 39 | @Deprecated | |
| 40 | public DifferentiableUnivariateFunction derivative() { | |
| 41 |
1
1. derivative : mutated return of Object value for org/apache/commons/math3/analysis/function/Identity::derivative to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Constant(1); |
| 42 | } | |
| 43 | ||
| 44 | /** {@inheritDoc} | |
| 45 | * @since 3.1 | |
| 46 | */ | |
| 47 | public DerivativeStructure value(final DerivativeStructure t) { | |
| 48 |
1
1. value : mutated return of Object value for org/apache/commons/math3/analysis/function/Identity::value to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return t; |
| 49 | } | |
| 50 | ||
| 51 | } | |
Mutations | ||
| 33 |
1.1 |
|
| 41 |
1.1 |
|
| 48 |
1.1 |


"You don't need a crown to be a slut just be a women and that is enough"
The word 'slut' emits thousand feelings at once and unfortunately used as a tool to suppress the women in every sense. Everywhere around I have witnessed these words thrown on the women by the so called men.  Hence, a second is enough to outrage the modesty of a woman. Being a slut is not just a confinement of words, but a mirror of feelings, emotions to the world about how a girl feels when she faces the cruel world. It is a story from her eyes, the eyes which holds the unbearable pain, the pain which last until she dies.
Being a slut will not just be confined to book but will be taken ahead as a cause to open some vicious eyes and to heal up some wounds of beloved women.
Join the cause to make world a better place for women
From the upcoming novel
"Being a Slut"
From the upcoming novel
"Being a Slut"
A
fascinating novel written by
Paras Mehra
Amazing Novel, A must read for everyone
Kanika Sharma
(Professional)
An eyeopener for everyone.
A great book in deed
Kriti Goel
(Working in MNC)
I loved the poetry in the book.
Incomparable
Agam Gupta
(Businessman)
Share your thoughts to the author
<EMAIL_ADDRESS>"Book is available nationally and internationally"
Amazon.in
(In India)
Flipkart.com
(In India)
Amazon.com
(Internationally)