netCDFPerl(1)
π netCDFPerl π
okay so bestie, welcome to netCDFPerl β a perl extension for netCDF dataset access, straight out of the UNIDATA UTILITIES manual. no cap, this one is niche but it slays. π¦
β¨ NAME β¨
netCDFPerl β a perl extension for netCDF dataset access. yes that's it, that's the whole name section, she's concise. π
πΈ SYNOPSIS πΈ
use netCDF;
NetCDF::create("foo.nc", NetCDF::CLOBBER);
...
literally just use netCDF; and you're in, babes. that ... is doing a lot of heavy lifting and honestly, same. π
π«Ά DESCRIPTION π«Ά
netCDFPerl is a Perl 5 extension-module interface to the services provided by the netCDF version 2 API, netcdf2(3). it's giving "let me call C from Perl and make it cute." π
So here's the vibe: every function in the netCDF version 2 library can be reached from a Perl 5 script by swapping the nc prefix of the regular netCDF version 2 C function names with NetCDF::. for example, the C function nccreate() shows up to a perl script as NetCDF::create. iconic behavior fr fr. β¨
Each perl function matches its C counterpart as closely as possible and necessary:
- the number, order, and semantics of the arguments are identical. one lil note tho β you do not have to specify the number of elements in an array, because perl arrays carry that information themselves. she's self-aware, we love that. π
- the behavior is the same in terms of the netCDF dataset.
- a value of
-1is returned to indicate an error. yes bestie,-1, that's your red flag. π©
Scalar argument types are mapped in an obvious way:
The individual elements of an array argument are similarly mapped.
Array arguments themselves are passed by reference for both input and output. for example, this Perl 5 code will write and then read a hyperslab of values:
@start = (0, 0, 0);
@count = (1, 2, 3);
@out = (1, 2, 3, 4, 5, 6);
NetCDF::varput($ncid, $varid, @start, @count, @out);
NetCDF::varget($ncid, $varid, @start, @count, @in);
(the above assumes that $ncid and $varid have been appropriately set, so likeβ¦ set them, bestie.) after this code runs, the array @in will have the same values as the array @out. π
β οΈ heads up: the previous contents, if any, of an array used for input are destroyed (e.g. @in in the above example). she's gone. π
To define a scalar variable with NetCDF::vardef(), use an empty dimension-ID array, like this:
NetCDF::vardef($ncid, "scalar_variable", NetCDF::FLOAT, \());
The interface doesn't support null arguments. you cannot use a void pointer to indicate that no value is requested for a particular argument β all arguments must be present. no skipping, no ghosting, everyone shows up to the function call. π
For technical reasons, output variables must be initialized, i.e. any variable argument that is to have its value set by a function must already have a value. for example, if the first occurrence of the variable $attval is in the following:
NetCDF::attget($ncid, NetCDF::GLOBAL, "history", \$attval);
then a core dump will probably result. π the solution is to initialize the variable before using it:
$attval="";
NetCDF::attget($ncid, NetCDF::GLOBAL, "history", \$attval);
Two additional functions are provided for error handling:
NetCDF::opts(i)determines the handling of errors by setting thencoptsvariable toi. it returns the previous value. πNetCDF::err()returns the value of the error code variable,ncerr.
In addition to the above functions, most C macro constants that are defined in the netCDF header file netcdf.h are also available to a perl script by dropping any NC_ substring and using the NetCDF:: prefix, e.g. NetCDF::LONG. the way they just chopped the prefix off and said "you're welcome"? obsessed. π
π SEE ALSO π
perl(1)netcdf2(3)
and that's the whole page, babe. π
Printed: 126-10-12 β $Date: 1999/07/21 16:38:27 $ β from the netCDFPerl(1) era, which is lowkey giving vintage but she still ate. πΈ periodt. π
π¦ where this page comes from
- fedora 43: netcdf-perl 1.2.4-56.fc43 Β· BSD-3-Clause
- fedora 44: netcdf-perl 1.2.4-58.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms