Commit 1db3041a authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

correction

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: 2472
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 46f78121
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fortranshape.h,v 1.6 2006-03-28 16:03:02 tforb Exp $
* $Id: fortranshape.h,v 1.7 2007-12-10 16:42:43 tforb Exp $
* \author Thomas Forbriger
* \date 23/12/2002
*
......@@ -33,6 +33,10 @@
* - now offers a casted pointer
* - FortranArray now takes container type as template
* argument
* - 10/12/2007 V1.2 (thof)
* - we need to use the types of the representation
* class to distinguish correctly for const
* correctness
*
* ============================================================================
*/
......@@ -41,9 +45,9 @@
#ifndef AFF_FORTRANSHAPE_H_VERSION
#define AFF_FORTRANSHAPE_H_VERSION \
"AFF_FORTRANSHAPE_H V1.1"
"AFF_FORTRANSHAPE_H V1.2"
#define AFF_FORTRANSHAPE_H_CVSID \
"$Id: fortranshape.h,v 1.6 2006-03-28 16:03:02 tforb Exp $"
"$Id: fortranshape.h,v 1.7 2007-12-10 16:42:43 tforb Exp $"
#include<aff/array.h>
#include<aff/lib/checkedcast.h>
......@@ -111,12 +115,16 @@ class FortranArray: private aff::util::FortranShape {
typedef typename Tarray::Tshape Tshape;
//! representation class
typedef typename Tarray::Trepresentation Trepresentation;
//! pointer to value used in representation class
typedef typename Trepresentation::Tpointer Treppointer;
//! base class
typedef aff::util::FortranShape Tbase;
//! pointer to array base in memory
typedef typename Tarray::Tpointer Tpointer;
//! pointer to array base in memory
//! value type in array class
typedef typename Tarray::Tvalue Tvalue;
//! value type in representation class
typedef typename Trepresentation::Tvalue Trepvalue;
//! create
FortranArray(Tarray array, const bool& BaseOne=true):
Tbase(array.shape(), BaseOne)
......@@ -131,7 +139,7 @@ class FortranArray: private aff::util::FortranShape {
Tbase::dimlast;
//@}
//! return pointer to first element in Fortran layout
Tpointer pointer() const { return(Mpointer); }
Treppointer pointer() const { return(Mpointer); }
/*! \brief return type-casted pointer to first element in Fortran layout
*
* The cast checks for const-correctness and type-size. But you have to
......@@ -141,10 +149,10 @@ class FortranArray: private aff::util::FortranShape {
*/
template<class TT>
TT* castedpointer() const
{ return(SizeCheckedCast<Tvalue,TT>::cast(Mpointer)); }
{ return(SizeCheckedCast<Trepvalue,TT>::cast(Mpointer)); }
private:
//! pointer to memory
Tpointer Mpointer;
Treppointer Mpointer;
}; // class FortranArray
} // namespace aff
......
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.15 2007-12-08 17:04:47 tforb Exp $
# $Id: Makefile,v 1.16 2007-12-10 16:42:44 tforb Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -89,4 +89,25 @@ f2ctest: f77test.o f77procs.f2c.o f77interface.o
f77test: f77test.o f77procs.o f77interface.o
$(CXX) -o $@ $^ $(LDFLAGS) -laff -lg2c -lm
#======================================================================
# test illegal conditions
illegal:
-$(MAKE) reprtest FLAGS=-DILLEGAL1
-$(MAKE) seriestest FLAGS=-DILLEGAL1
-$(MAKE) shapetest FLAGS=-DILLEGAL1
-$(MAKE) simplearraytest FLAGS=-DILLEGAL1
-$(MAKE) simplearraytest FLAGS=-DILLEGAL2
-$(MAKE) arraytest FLAGS=-DILLEGAL1
-$(MAKE) arraytest FLAGS=-DILLEGAL2
-$(MAKE) arraytest FLAGS=-DILLEGAL3
-$(MAKE) arraytest FLAGS=-DILLEGAL4
-$(MAKE) arraytest FLAGS=-DILLEGAL5
-$(MAKE) arraytest FLAGS=-DILLEGAL6
-$(MAKE) arraytest FLAGS=-DILLEGAL7
-$(MAKE) f77test FLAGS=-DILLEGAL1
-$(MAKE) f77test FLAGS=-DILLEGAL2
-$(MAKE) f77test FLAGS=-DILLEGAL3
-$(MAKE) f77test FLAGS=-DILLEGAL4
-$(MAKE) f77test FLAGS=-DILLEGAL5
# ----- END OF Makefile -----
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: f77test.cc,v 1.13 2007-12-08 17:04:47 tforb Exp $
* $Id: f77test.cc,v 1.14 2007-12-10 16:42:44 tforb Exp $
* \author Thomas Forbriger
* \date 22/12/2002
*
......@@ -65,7 +65,7 @@
#define AFF_F77TEST_CC_VERSION \
"AFF_F77TEST_CC V1.2"
#define AFF_F77TEST_CC_CVSID \
"$Id: f77test.cc,v 1.13 2007-12-08 17:04:47 tforb Exp $"
"$Id: f77test.cc,v 1.14 2007-12-10 16:42:44 tforb Exp $"
#include <aff/array.h>
#include <aff/fortranshape.h>
......@@ -181,11 +181,9 @@ int main()
CODE(typedef std::complex<int> Ticvalue);
CODE(typedef std::complex<float> Tcvalue);
CODE(Array<Ticvalue> v1(1));
// CODE(ConstArray<Ticvalue> v2(v1));
CODE(Array<Ticvalue> v2(v1));
CODE(ConstArray<Ticvalue> v2(v1));
CODE(FortranArray<Array<Ticvalue> > fv1(v1));
// CODE(FortranArray<ConstArray<Ticvalue> > fv2(v2));
CODE(FortranArray<Array<Ticvalue> > fv2(v2));
CODE(FortranArray<ConstArray<Ticvalue> > fv2(v2));
CODE(v1(1)=Ticvalue(3,7));
CODE(cout << v1(1) << ", " << v2(1) << endl);
CODE(Ticvalue *icp=fv1.castedpointer<Ticvalue>());
......@@ -205,11 +203,9 @@ int main()
section("Test illegal usage (only if activated through macro-definition):",
' ');
CODE(Array<int> iv1(1));
// CODE(ConstArray<int> iv2(iv1));
CODE(Array<int> iv2(iv1));
CODE(ConstArray<int> iv2(iv1));
CODE(FortranArray<Array<int> > fiv1(iv1));
// CODE(FortranArray<ConstArray<int> > fiv2(iv2));
CODE(FortranArray<Array<int> > fiv2(iv2));
CODE(FortranArray<ConstArray<int> > fiv2(iv2));
CODE(iv1(1)=50);
CODE(cout << iv1(1) << ", " << iv2(1) << endl);
CODE(int *iv1p=fiv1.pointer());
......
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