Commit 43d01568 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

started blitz binary I/O

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1121
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent a4485e7f
/*! \file blitzfortranio.h
* \brief provide Fortran I/O for raw Blitz++ arrays (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: blitzfortranio.h,v 1.1 2002-11-28 14:51:08 forbrig Exp $
* \author Thomas Forbriger
* \date 28/11/2002
*
* provide Fortran I/O for raw Blitz++ arrays (prototypes)
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* REVISIONS and CHANGES
* - 28/11/2002 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_BLITZFORTRANIO_H_VERSION
#define TF_BLITZFORTRANIO_H_VERSION \
"TF_BLITZFORTRANIO_H V1.0 "
#define TF_BLITZFORTRANIO_H_CVSID \
"$Id: blitzfortranio.h,v 1.1 2002-11-28 14:51:08 forbrig Exp $"
#include<blitz/array.h>
#include<tfxx/fortranio.h>
#include<tfxx/ioswap.h>
namespace tfxx {
namespace fortranio {
/*! \brief magic numbers for blitz array I/O
* \ingroup group_fortranio
*
* \deprecated
* Thi struct is a quick hack and may be replaced by another algorithm in the
* future. Magic number character sequences will, however, remain.
* \todo
* use a more clever technique than spezialisation for all types and ranks
*/
template<class T, int N>
struct blitz_magic {
}; // blitz_magic
//! partial specializations
template<> struct blitz_magic<float, 1> { static const magic[]="ZZf1"; }
template<> struct blitz_magic<float, 2> { static const magic[]="ZZf2"; }
template<> struct blitz_magic<float, 3> { static const magic[]="ZZf3"; }
template<> struct blitz_magic<float, 4> { static const magic[]="ZZf4"; }
template<> struct blitz_magic<float, 5> { static const magic[]="ZZf5"; }
template<> struct blitz_magic<double, 1> { static const magic[]="ZZd1"; }
template<> struct blitz_magic<double, 2> { static const magic[]="ZZd2"; }
template<> struct blitz_magic<double, 3> { static const magic[]="ZZd3"; }
template<> struct blitz_magic<double, 4> { static const magic[]="ZZd4"; }
template<> struct blitz_magic<double, 5> { static const magic[]="ZZd5"; }
template<> struct blitz_magic<int, 1> { static const magic[]="ZZi1"; }
template<> struct blitz_magic<int, 2> { static const magic[]="ZZi2"; }
template<> struct blitz_magic<int, 3> { static const magic[]="ZZi3"; }
template<> struct blitz_magic<int, 4> { static const magic[]="ZZi4"; }
template<> struct blitz_magic<int, 5> { static const magic[]="ZZi5"; }
#ifdef TF_COMPLEX_ARRAY
#include<complex>
template<> struct blitz_magic<std::complex<float>, 1>
{ static const magic[]="ZZc1"; }
template<> struct blitz_magic<std::complex<float>, 2>
{ static const magic[]="ZZc2"; }
template<> struct blitz_magic<std::complex<float>, 3>
{ static const magic[]="ZZc3"; }
template<> struct blitz_magic<std::complex<float>, 4>
{ static const magic[]="ZZc4"; }
template<> struct blitz_magic<std::complex<float>, 5>
{ static const magic[]="ZZc5"; }
template<> struct blitz_magic<std::complex<double>, 1>
{ static const magic[]="ZZz1"; }
template<> struct blitz_magic<std::complex<double>, 2>
{ static const magic[]="ZZz2"; }
template<> struct blitz_magic<std::complex<double>, 3>
{ static const magic[]="ZZz3"; }
template<> struct blitz_magic<std::complex<double>, 4>
{ static const magic[]="ZZz4"; }
template<> struct blitz_magic<std::complex<double>, 5>
{ static const magic[]="ZZz5"; }
#endif
/*----------------------------------------------------------------------*/
/*! \brief Output operator template for class FortranBinOutput and blitz
* \ingroup group_fortranio
*
* \anchor anchor_blitzfortranio_output
* The compiler will consider namespace tfxx::fortranio due to the involved
* FortranBinOutput object.
* \todo
* still far from finished
*/
template<class T, int N>
tfxx::fortranio::FortranBinOutput&
operator << (tfxx::fortranio::FortranBinOutput& fo,
const blitz::Array<T, N>& a)
{
fo.put(N);
fo.put(value);
return(fo);
}
/*----------------------------------------------------------------------*/
/*! \brief Input operator template for class FortranBinInput and blitz
* \ingroup group_fortranio
*
* \anchor anchor_blitzfortranio_input
* The compiler will consider namespace tfxx::fortranio due to the involved
* FortranBinInput object.
* \todo
* still far from finished
*/
template<class T, int N>
tfxx::fortranio::FortranBinInput&
operator >> (tfxx::fortranio::FortranBinInput& fi,
blitz::Array<T, N>& a)
{
int n;
fi.get(n)
fi.get(value);
return(fi);
}
} // namespace fortranio
} // namespace tfxx
#endif // TF_BLITZFORTRANIO_H_VERSION (includeguard)
/* ----- END OF blitzfortranio.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fortranio.h,v 1.13 2002-11-28 14:07:31 forbrig Exp $
* $Id: fortranio.h,v 1.14 2002-11-28 14:51:08 forbrig Exp $
* \author Thomas Forbriger
* \date 13/01/2002
*
......@@ -28,7 +28,7 @@
#define TF_FORTRANIO_H_VERSION \
"TF_ V1.0 "
#define TF_FORTRANIO_H_CVSID \
"$Id: fortranio.h,v 1.13 2002-11-28 14:07:31 forbrig Exp $"
"$Id: fortranio.h,v 1.14 2002-11-28 14:51:08 forbrig Exp $"
#include<tfxx/misc.h>
#include<fstream>
......@@ -244,10 +244,11 @@ template<typename T>
/*! \brief Output operator template for class FortranBinOutput
* \ingroup group_fortranio
*
* It is quite save to present this operator in the global namespace. This is
* just function overloading. The compiler will decide which operator we need
* be the FortranBinOutput object involved. An this way using the operator
* function is most convenient.
* The compiler will consider namespace tfxx::fortranio due to the involved
* FortranBinOutput object.
* There is
* \ref anchor_blitzfortranio_output "another output operator template"
* to write raw Blitz++ arrays.
*
* \anchor fortranio_opout
*/
......@@ -262,10 +263,11 @@ template<typename T>
/*! \brief Input operator template for class FortranBinInput
* \ingroup group_fortranio
*
* It is quite save to present this operator in the global namespace. This is
* just function overloading. The compiler will decide which operator we need
* be the FortranBinInput object involved. An this way using the operator
* function is most convenient.
* The compiler will consider namespace tfxx::fortranio due to the involved
* FortranBinInput object.
* There is
* \ref anchor_blitzfortranio_input "another input operator template"
* to read raw Blitz++ arrays.
*
* \anchor fortranio_opin
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment