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

proceeding with Fortran interface

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: 1234
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f97f5e87
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README,v 1.12 2002-12-23 11:44:03 forbrig Exp $
* $Id: README,v 1.13 2002-12-23 14:32:04 forbrig Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -50,7 +50,7 @@ namespace aff {
\since December 2002
\date December 2002
\version V1.0
$Id: README,v 1.12 2002-12-23 11:44:03 forbrig Exp $
$Id: README,v 1.13 2002-12-23 14:32:04 forbrig Exp $
Contents of this page:
- \ref sec_main_aims
......@@ -137,6 +137,9 @@ $Id: README,v 1.12 2002-12-23 11:44:03 forbrig Exp $
subarrays from aff::Array objects.
-# aff::Slice presented in aff/slice.h to conveniently create
slices from aff::Array objects.
-# aff::FortranArray and its associate aff::util::FortranShape are presented
in aff/fortranshape.h. They calculate a Fortran 77 array
layout (leading dimensions) from a given AFF array.
-# aff::dump and its associates, presented in aff/dump.h. They are used to
dump shape or contents of containers and are thus useful when
debugging your code. See also "\ref group_helpers".
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fortranshape.h,v 1.1 2002-12-23 13:54:58 forbrig Exp $
* $Id: fortranshape.h,v 1.2 2002-12-23 14:32:04 forbrig Exp $
* \author Thomas Forbriger
* \date 23/12/2002
*
......@@ -23,7 +23,7 @@
#define AFF_FORTRANSHAPE_H_VERSION \
"AFF_FORTRANSHAPE_H V1.0 "
#define AFF_FORTRANSHAPE_H_CVSID \
"$Id: fortranshape.h,v 1.1 2002-12-23 13:54:58 forbrig Exp $"
"$Id: fortranshape.h,v 1.2 2002-12-23 14:32:04 forbrig Exp $"
#include<aff/array.h>
......@@ -57,6 +57,12 @@ namespace util {
const Tsubscript& dimlast(const Tdim& i) const { return(Mdimlast[i]); }
//! offset to access representation
const Tsubscript& offset() const { return(Moffset); }
//! full first vector
const TIndexVec& first() const { return(Mfirst); }
//! full last vector
const TIndexVec& last() const { return(Mlast); }
//! full dimlast vector
const TIndexVec& dimlast() const { return(Mdimlast); }
private:
//! first index
TIndexVec Mfirst;
......
/*! \file libaff/lib/README
* \brief about the concept of memory representations
* \brief Some more specific or more advanced topics
*
* ----------------------------------------------------------------------------
*
* $Id: README,v 1.6 2002-12-23 11:44:03 forbrig Exp $
* $Id: README,v 1.7 2002-12-23 14:32:04 forbrig Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* about the concept of memory representations
* Some more specific or more advanced topics
*
* This file contains documentation for
* - namespace aff::utl
* - namespace aff::util
* - \ref page_representation
* - \ref page_fortran
*
* REVISIONS and CHANGES
* - 08/12/2002 V1.0 copied from libcontxx
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: strided.cc,v 1.4 2002-12-18 18:43:44 uid1201 Exp $
* $Id: strided.cc,v 1.5 2002-12-23 14:32:04 forbrig Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -39,7 +39,7 @@
#define AFF_STRIDED_CC_VERSION \
"AFF_STRIDED_DEF_H V1.6"
#define AFF_STRIDED_CC_CVSID \
"$Id: strided.cc,v 1.4 2002-12-18 18:43:44 uid1201 Exp $"
"$Id: strided.cc,v 1.5 2002-12-23 14:32:04 forbrig Exp $"
#include<aff/lib/strided.h>
#include<aff/lib/error.h>
......@@ -156,7 +156,7 @@ namespace aff {
AFF_assert((i<Mmax_dimen),
"ERROR (Strided::shrink): illegal dimension");
AFF_assert(((Mfirst[i]<=first)&&(first<=last)&&(last<=Mlast[i])),
"ERROR (Strided::shrink): index range erres");
"ERROR (Strided::shrink): index range error");
// take the long way home
TIndexVec newfirst(Mfirst);
newfirst[i]=first;
......
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.6 2002-12-23 11:44:04 forbrig Exp $
# $Id: Makefile,v 1.7 2002-12-23 14:32:05 forbrig Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -40,6 +40,8 @@ clean: ;
STANDARDTEST=arraytest subscriptortest shapetest simplearraytest reprtest \
seriestest helpertest
BINARYTEST=binarraytest
F77TEST=f77test
EXECUTABLES=$(STANDARDTEST) $(BINARYTEST) $(F77TEST)
$(addsuffix .o,$(STANDARDTEST) $(BINARYTEST)): %.o: %.cc
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) $(FLAGS)
......@@ -47,7 +49,7 @@ $(addsuffix .o,$(STANDARDTEST) $(BINARYTEST)): %.o: %.cc
$(STANDARDTEST): %: %.o; $(CXX) -o $@ $< $(LDFLAGS) -laff
$(BINARYTEST): %: %.o; $(CXX) -o $@ $< $(LDFLAGS) -laff
$(addsuffix .run,$(STANDARDTEST)): %.run: %; $< $(ARG); rm -fv $< $<.o
$(addsuffix .run,$(EXECUTABLES)): %.run: %; $< $(ARG); rm -fv $< $<.o
#======================================================================
#
......@@ -62,4 +64,8 @@ F2C=f2c
%.P: %.f
$(F2C) -C++ -f -P $<
-/bin/mv -v $(patsubst %.f,%.c,$<) $(patsubst %.f,%.code,$<)
f77test: f77test.o
$(CXX) -o $@ $< $(LDFLAGS) -laff
# ----- END OF Makefile -----
c this is <f77procs.f>
c ----------------------------------------------------------------------------
c ($Id: f77procs.f,v 1.1 2002-12-23 11:44:04 forbrig Exp $)
c ($Id: f77procs.f,v 1.2 2002-12-23 14:32:05 forbrig Exp $)
c
c Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
c
......@@ -81,4 +81,24 @@ c
return
end
c
c----------------------------------------------------------------------
c
subroutine fill(a, ld1, n1, ld2, n2, ld3, n3)
c
integer ld1,n1,ld2,n2,ld3,n3
integer a(ld1,ld2,ld3)
c
integer i,j,k
c
do i=1,n1
do j=1,n2
do k=1,n3
a(i,j,k)=i+10*j+100*k
enddo
enddo
enddo
c
return
end
c
c ----- END OF f77procs.f -----
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: f77test.cc,v 1.1 2002-12-23 11:44:04 forbrig Exp $
* $Id: f77test.cc,v 1.2 2002-12-23 14:32:05 forbrig Exp $
* \author Thomas Forbriger
* \date 22/12/2002
*
......@@ -16,15 +16,78 @@
*
* ============================================================================
*/
#define TF_F77TEST_CC_VERSION \
"TF_F77TEST_CC V1.0 "
#define TF_F77TEST_CC_CVSID \
"$Id: f77test.cc,v 1.1 2002-12-23 11:44:04 forbrig Exp $"
#include <f77test.h>
/*! \example tests/f77test.cc
*
* Passing arrays to Fortran 77 code and retrieving array structures
* from Fortran 77 common blocks.
*
* \sa tests/f77test.cc
*/
#define AFF_F77TEST_CC_VERSION \
"AFF_F77TEST_CC V1.0 "
#define AFF_F77TEST_CC_CVSID \
"$Id: f77test.cc,v 1.2 2002-12-23 14:32:05 forbrig Exp $"
#include <aff/array.h>
#include <aff/fortranshape.h>
#include <aff/dump.h>
#include <aff/shaper.h>
using std::cout;
using std::endl;
using namespace aff;
namespace tf {
/*----------------------------------------------------------------------*/
//! print headline
void section(const char* s, const char l='-')
{
cout << endl << s << endl;
const char* p=s;
while (*p) { cout << l; ++p; }
cout << endl;
}
/*======================================================================*/
//! test array interface to Fortran 77
int main()
{
cout << AFF_F77TEST_CC_VERSION << endl;
cout << AFF_F77TEST_CC_CVSID << endl;
// First we test the shape class that should support passing arrays to
// Fortran 77 functions
section("FortranShape:", '=');
{
section("Full Layout");
// we create a test array with known Fortran layout
CODE(Strided strided(Shaper(1,10,20)(1,5,10)(1,30)(20)));
// dump this shape
DUMP(strided);
// create Fortran shape from this (should be identical to known)
CODE(aff::util::FortranShape fs1(strided));
// and dump this
DUMP(fs1.first());
DUMP(fs1.last());
DUMP(fs1.dimlast());
cout << "fs1.offset(): " << fs1.offset() << endl;
section("Sliced Subshape");
// now take shape of a subarray
CODE(Strided subshape(strided));
CODE(subshape.shrink(0,2).shrink(1,3,5).shrink(3,10,20));
CODE(subshape.collapse(2,15));
// create Fortran shape from this
CODE(aff::util::FortranShape fs2(subshape));
// and dump this
DUMP(fs2.first());
DUMP(fs2.last());
DUMP(fs2.dimlast());
cout << "fs2.offset(): " << fs2.offset() << endl;
}
} // main
/* ----- END OF f77test.cc ----- */
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