Commit e3cfcfbc authored by Ben Boeckel's avatar Ben Boeckel

vtknetcdf: remove the old vtknetcdfcpp import

parent 30642d18
if(NOT VTK_USE_SYSTEM_NETCDF)
vtk_module_third_party(NetCDF
LIBRARIES vtkNetCDF vtkNetCDF_cxx
LIBRARIES vtkNetCDF
INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/vtknetcdf/include
${CMAKE_CURRENT_BINARY_DIR}/vtknetcdf
COMPONENTS C CXX
COMPONENTS C
)
else()
vtk_module_third_party(NetCDF
LIBRARIES vtkNetCDF netcdf
COMPONENTS C CXX
COMPONENTS C
)
endif()
#Configure the top cpp header to switch between system and internal
#netcdf just like vtk_module_third_party does for the c header.
configure_file(vtk_netcdfcpp.h.in vtk_netcdfcpp.h)
#Install the top cpp header too.
if (NOT VTK_INSTALL_NO_DEVELOPMENT)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vtk_netcdfcpp.h
DESTINATION ${VTK_INSTALL_INCLUDE_DIR}
COMPONENT Development)
endif()
# Remove old netcdfc++ header files if they exist.
if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/vtk_netcdfcpp.h")
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/vtk_netcdfcpp.h")
endif ()
/*=========================================================================
Program: Visualization Toolkit
Module: vtk_netcdf.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef vtk_netcdfcpp_h
#define vtk_netcdfcpp_h
/* Use the netcdfcpp library configured for VTK. */
#cmakedefine VTK_USE_SYSTEM_NETCDF
#ifdef VTK_USE_SYSTEM_NETCDF
# include <netcdfcpp.h>
#else
# include <vtknetcdf/cxx/netcdfcpp.h>
#endif
#endif
......@@ -224,10 +224,6 @@ ENDIF()
TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
SET(WORDS_BIGENDIAN ${CMAKE_WORDS_BIGENDIAN})
OPTION(NETCDF_ENABLE_CXX "Build netcdf C++ API" ON)
mark_as_advanced(NETCDF_ENABLE_CXX)
SET(CXX NETCDF_ENABLE_CXX)
# NetCDF4 needs HDF5 HL support. VTK's usage of HDF5 will always require
# the presence of HL libraries so we no longer need to explicitly check
# for them
......@@ -273,18 +269,13 @@ IF (NETCDF_DISABLE_COMPILER_WARNINGS)
IF (MSVC)
STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
STRING (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " "
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
# Borland uses -w- to suppress warnings.
ELSEIF (BORLAND)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
SET (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -w-")
ELSE ()
# Most compilers use -w to suppress warnings.
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
SET (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -w")
ENDIF ()
ENDIF ()
......@@ -313,10 +304,6 @@ IF (USE_NETCDF4)
ADD_SUBDIRECTORY(libsrc4)
ENDIF ()
IF (NETCDF_ENABLE_CXX)
ADD_SUBDIRECTORY(cxx)
ENDIF ()
IF(APPLE)
SET_SOURCE_FILES_PROPERTIES(
v2i.c
......@@ -336,9 +323,6 @@ if (UNIX)
target_link_libraries(vtkNetCDF m)
endif()
VTK_ADD_LIBRARY(vtkNetCDF_cxx ${netcdf_cxx_SOURCES})
TARGET_LINK_LIBRARIES(vtkNetCDF_cxx LINK_PUBLIC vtkNetCDF)
#-----------------------------------------------------------------------------
#package the result
#-----------------------------------------------------------------------------
......@@ -347,9 +331,6 @@ IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
INSTALL(FILES
${VTKNETCDF_SOURCE_DIR}/include/netcdf.h
${VTKNETCDF_SOURCE_DIR}/include/vtk_netcdf_mangle.h
${VTKNETCDF_SOURCE_DIR}/cxx/netcdf.hh
${VTKNETCDF_SOURCE_DIR}/cxx/netcdfcpp.h
${VTKNETCDF_SOURCE_DIR}/cxx/ncvalues.h
${VTKNETCDF_BINARY_DIR}/vtk_netcdf_config.h
DESTINATION ${VTK_INSTALL_INCLUDE_DIR}/vtknetcdf/include
COMPONENT Development)
......
#netcdf cxx
project(netcdf_cxx)
SET(SOURCES
netcdf.cpp
ncvalues.cpp
)
foreach(file ${SOURCES})
set(path_SOURCES ${path_SOURCES} ${PROJECT_SOURCE_DIR}/${file})
endforeach()
set(netcdf_cxx_SOURCES ${path_SOURCES} PARENT_SCOPE)
netcdfcpp.h the C++ interface
netcdf.cpp the implementation of the interface, on top of the current
C library interface
nctst.cpp a test program for the interface that creates a netCDF file
and then dumps out its contents in ASCII form to stdout.
This example may also be helpful in understanding how the
interface is intended to be used.
example.c example of C code needed to create a small netCDF file
example.cpp analogous example of C++ code needed to do the same thing
Makefile makefile for building nctst
ncvalues.cpp interface for auxilliary classes of typed arrays needed by
netCDF interface; fairly simple
ncvalues.cpp implementation of auxilliary classes of typed arrays needed by
netCDF interface
README this file
This diff is collapsed.
/*********************************************************************
* Copyright 1992, University Corporation for Atmospheric Research
* See netcdf/README file for copying and redistribution conditions.
*
* Purpose: implementation of classes of typed arrays for netCDF
*
* $Header: /upc/share/CVS/netcdf-3/cxx/ncvalues.cpp,v 1.12 2008/03/05 16:45:32 russ Exp $
*********************************************************************/
#include <config.h>
#include <iostream>
#include <string>
#include <cstring>
#include "ncvalues.h"
// pragma GCC diagnostic is available since gcc>=4.2
#if defined(__GNUG__) && (__GNUC__>4) || (__GNUC__==4 && __GNUC_MINOR__>=2)
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
NcValues::NcValues( void ) : the_type(ncNoType), the_number(0)
{}
NcValues::NcValues(NcType type, long num)
: the_type(type), the_number(num)
{}
NcValues::~NcValues( void )
{}
long NcValues::num( void )
{
return the_number;
}
std::ostream& operator<< (std::ostream& os, const NcValues& vals)
{
return vals.print(os);
}
implement(NcValues,ncbyte)
implement(NcValues,char)
implement(NcValues,short)
implement(NcValues,int)
implement(NcValues,nclong)
implement(NcValues,long)
implement(NcValues,float)
implement(NcValues,double)
Ncbytes_for_one_implement(ncbyte)
Ncbytes_for_one_implement(char)
Ncbytes_for_one_implement(short)
Ncbytes_for_one_implement(int)
Ncbytes_for_one_implement(nclong)
Ncbytes_for_one_implement(long)
Ncbytes_for_one_implement(float)
Ncbytes_for_one_implement(double)
as_ncbyte_implement(short)
as_ncbyte_implement(int)
as_ncbyte_implement(nclong)
as_ncbyte_implement(long)
as_ncbyte_implement(float)
as_ncbyte_implement(double)
inline ncbyte NcValues_char::as_ncbyte( long n ) const
{
return the_values[n];
}
inline ncbyte NcValues_ncbyte::as_ncbyte( long n ) const
{
return the_values[n];
}
as_char_implement(short)
as_char_implement(int)
as_char_implement(nclong)
as_char_implement(long)
as_char_implement(float)
as_char_implement(double)
inline char NcValues_ncbyte::as_char( long n ) const
{
return the_values[n] > CHAR_MAX ? ncBad_char : (char) the_values[n];
}
inline char NcValues_char::as_char( long n ) const
{
return the_values[n];
}
as_short_implement(int)
as_short_implement(nclong)
as_short_implement(long)
as_short_implement(float)
as_short_implement(double)
inline short NcValues_ncbyte::as_short( long n ) const
{
return the_values[n];
}
inline short NcValues_char::as_short( long n ) const
{
return the_values[n];
}
inline short NcValues_short::as_short( long n ) const
{
return the_values[n];
}
as_int_implement(float)
as_int_implement(double)
inline int NcValues_ncbyte::as_int( long n ) const
{
return the_values[n];
}
inline int NcValues_char::as_int( long n ) const
{
return the_values[n];
}
inline int NcValues_short::as_int( long n ) const
{
return the_values[n];
}
inline int NcValues_int::as_int( long n ) const
{
return the_values[n];
}
inline int NcValues_nclong::as_int( long n ) const
{
return the_values[n];
}
inline int NcValues_long::as_int( long n ) const
{
return the_values[n];
}
as_nclong_implement(float)
as_nclong_implement(double)
inline nclong NcValues_ncbyte::as_nclong( long n ) const
{
return the_values[n];
}
inline nclong NcValues_char::as_nclong( long n ) const
{
return the_values[n];
}
inline nclong NcValues_short::as_nclong( long n ) const
{
return the_values[n];
}
inline nclong NcValues_int::as_nclong( long n ) const
{
return the_values[n];
}
inline nclong NcValues_nclong::as_nclong( long n ) const
{
return the_values[n];
}
inline nclong NcValues_long::as_nclong( long n ) const
{
return the_values[n];
}
as_long_implement(float)
as_long_implement(double)
inline long NcValues_ncbyte::as_long( long n ) const
{
return the_values[n];
}
inline long NcValues_char::as_long( long n ) const
{
return the_values[n];
}
inline long NcValues_short::as_long( long n ) const
{
return the_values[n];
}
inline long NcValues_int::as_long( long n ) const
{
return the_values[n];
}
inline long NcValues_nclong::as_long( long n ) const
{
return the_values[n];
}
inline long NcValues_long::as_long( long n ) const
{
return the_values[n];
}
as_float_implement(ncbyte)
as_float_implement(char)
as_float_implement(short)
as_float_implement(int)
as_float_implement(nclong)
as_float_implement(long)
as_float_implement(float)
as_float_implement(double)
as_double_implement(ncbyte)
as_double_implement(char)
as_double_implement(short)
as_double_implement(int)
as_double_implement(nclong)
as_double_implement(long)
as_double_implement(float)
as_double_implement(double)
as_string_implement(short)
as_string_implement(int)
as_string_implement(nclong)
as_string_implement(long)
as_string_implement(float)
as_string_implement(double)
inline char* NcValues_ncbyte::as_string( long n ) const
{
char* s = new char[the_number + 1];
s[the_number] = '\0';
strncpy(s, (const char*)the_values + n, (int)the_number);
return s;
}
inline char* NcValues_char::as_string( long n ) const
{
char* s = new char[the_number + 1];
s[the_number] = '\0';
strncpy(s, (const char*)the_values + n, (int)the_number);
return s;
}
std::ostream& NcValues_short::print(std::ostream& os) const
{
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
return os;
}
std::ostream& NcValues_int::print(std::ostream& os) const
{
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
return os;
}
std::ostream& NcValues_nclong::print(std::ostream& os) const
{
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
return os;
}
std::ostream& NcValues_long::print(std::ostream& os) const
{
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
return os;
}
std::ostream& NcValues_ncbyte::print(std::ostream& os) const
{
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
return os;
}
std::ostream& NcValues_char::print(std::ostream& os) const
{
os << '"';
long len = the_number;
while (the_values[--len] == '\0') // don't output trailing null bytes
;
for(int i = 0; i <= len; i++)
os << the_values[i] ;
os << '"';
return os;
}
std::ostream& NcValues_float::print(std::ostream& os) const
{
std::streamsize save=os.precision();
os.precision(7);
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1] ;
os.precision(save);
return os;
}
std::ostream& NcValues_double::print(std::ostream& os) const
{
std::streamsize save=os.precision();
os.precision(15);
for(int i = 0; i < the_number - 1; i++)
os << the_values[i] << ", ";
if (the_number > 0)
os << the_values[the_number-1];
os.precision(save);
return os;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
netcdf ref_nctst {
dimensions:
lat = 4 ;
lon = 3 ;
frtime = UNLIMITED ; // (2 currently)
timelen = 20 ;
variables:
float P(frtime, lat, lon) ;
P:long_name = "pressure at maximum wind" ;
P:units = "hectopascals" ;
P:valid_range = 0.f, 1500.f ;
P:_FillValue = -9999.f ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
int frtime(frtime) ;
frtime:long_name = "forecast time" ;
frtime:units = "hours" ;
char reftime(timelen) ;
reftime:long_name = "reference time" ;
reftime:units = "text_time" ;
int scalarv ;
scalarv:scalar_att = 1 ;
// global attributes:
:history = "created by Unidata LDM from NPS broadcast" ;
:title = "NMC Global Product Set: Pressure at Maximum Wind" ;
data:
P =
950, 951, 952,
953, 954, 955,
956, 957, 958,
959, 960, 961,
962, 963, 964,
965, 966, 967,
968, 969, 970,
971, 972, 973 ;
lat = -90, -87.5, -85, -82.5 ;
lon = -180, -175, -170 ;
frtime = 12, 18 ;
reftime = "1992-3-21 12:00" ;
scalarv = _ ;
}
netcdf ref_nctst {
dimensions:
lat = 4 ;
lon = 3 ;
frtime = UNLIMITED ; // (2 currently)
timelen = 20 ;
variables:
float P(frtime, lat, lon) ;
P:long_name = "pressure at maximum wind" ;
P:units = "hectopascals" ;
P:valid_range = 0.f, 1500.f ;
P:_FillValue = -9999.f ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
int frtime(frtime) ;
frtime:long_name = "forecast time" ;
frtime:units = "hours" ;
char reftime(timelen) ;
reftime:long_name = "reference time" ;
reftime:units = "text_time" ;
int scalarv ;
scalarv:scalar_att = 1 ;
// global attributes:
:history = "created by Unidata LDM from NPS broadcast" ;
:title = "NMC Global Product Set: Pressure at Maximum Wind" ;
data:
P =
950, 951, 952,
953, 954, 955,
956, 957, 958,
959, 960, 961,
962, 963, 964,
965, 966, 967,
968, 969, 970,
971, 972, 973 ;
lat = -90, -87.5, -85, -82.5 ;
lon = -180, -175, -170 ;
frtime = 12, 18 ;
reftime = "1992-3-21 12:00" ;
scalarv = _ ;
}
netcdf ref_nctst {
dimensions:
lat = 4 ;
lon = 3 ;
frtime = UNLIMITED ; // (2 currently)
timelen = 20 ;
variables:
float P(frtime, lat, lon) ;
P:long_name = "pressure at maximum wind" ;
P:units = "hectopascals" ;
P:valid_range = 0.f, 1500.f ;
P:_FillValue = -9999.f ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
int frtime(frtime) ;
frtime:long_name = "forecast time" ;
frtime:units = "hours" ;
char reftime(timelen) ;
reftime:long_name = "reference time" ;
reftime:units = "text_time" ;
int scalarv ;
scalarv:scalar_att = 1 ;
// global attributes:
:history = "created by Unidata LDM from NPS broadcast" ;
:title = "NMC Global Product Set: Pressure at Maximum Wind" ;
data:
P =
950, 951, 952,
953, 954, 955,
956, 957, 958,
959, 960, 961,
962, 963, 964,
965, 966, 967,
968, 969, 970,
971, 972, 973 ;
lat = -90, -87.5, -85, -82.5 ;
lon = -180, -175, -170 ;
frtime = 12, 18 ;
reftime = "1992-3-21 12:00" ;
scalarv = _ ;
}
netcdf ref_nctst {
dimensions:
lat = 4 ;
lon = 3 ;
frtime = UNLIMITED ; // (2 currently)
timelen = 20 ;
variables:
float P(frtime, lat, lon) ;
P:long_name = "pressure at maximum wind" ;
P:units = "hectopascals" ;
P:valid_range = 0.f, 1500.f ;
P:_FillValue = -9999.f ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
int frtime(frtime) ;
frtime:long_name = "forecast time" ;
frtime:units = "hours" ;
char reftime(timelen) ;
reftime:long_name = "reference time" ;
reftime:units = "text_time" ;
int scalarv ;
scalarv:scalar_att = 1 ;
// global attributes:
:history = "created by Unidata LDM from NPS broadcast" ;
:title = "NMC Global Product Set: Pressure at Maximum Wind" ;
data:
P =
950, 951, 952,
953, 954, 955,
956, 957, 958,
959, 960, 961,
962, 963, 964,
965, 966, 967,
968, 969, 970,
971, 972, 973 ;
lat = -90, -87.5, -85, -82.5 ;
lon = -180, -175, -170 ;
frtime = 12, 18 ;
reftime = "1992-3-21 12:00" ;
scalarv = _ ;
}
#!/bin/sh
# This shell script runs some netCDF C++ API tests for netcdf-4 and
# netcdf-4 classic formats.
# $Id: run_nc4_tests.sh,v 1.1 2006/05/08 02:00:27 ed Exp $