AFF --- A container for numbers (array) by Friederich and Forbriger.
f77interface.cc
Go to the documentation of this file.
1 
41 #define AFF_F77INTERFACE_CC_VERSION \
42  "AFF_F77INTERFACE_CC V1.2"
43 
44 // include assertions
45 #include<aff/lib/error.h>
46 // include FortranArray stuff
47 #include<aff/fortranshape.h>
48 #include<aff/subarray.h>
49 #include<aff/shaper.h>
50 #include<aff/lib/checkedcast.h>
51 
52 /*----------------------------------------------------------------------*/
53 
54 // include interface prototypes
55 #include"f77proto.h"
56 
57 /*----------------------------------------------------------------------*/
58 
59 // get common block
60 #include"f77common_com.P"
61 
62 /*----------------------------------------------------------------------*/
63 
64 // f2c declarations
65 #include "f2c.h"
66 
67 #ifdef __cplusplus
68  extern "C" {
69 #endif
70 
71 // include prototypes of Fortran subroutines
72 #include"f77procs.P"
73 
75 int MAIN__()
76 {
77  AFF_abort("should never be called!");
78 }
79 
80 #ifdef __cplusplus
81  }
82 #endif
83 
84 /*======================================================================*/
85 
86 namespace f77interface {
87 
89 int fill(const aff::Array<int>& a)
90 {
92  integer* pa=fa.castedpointer<integer>();
93  integer n1=fa.last(0);
94  integer n2=fa.last(1);
95  integer n3=fa.last(2);
96  integer l1=fa.dimlast(0);
97  integer l2=fa.dimlast(1);
98  integer l3=fa.dimlast(2);
99  return(fill_(pa, &l1, &n1, &l2, &n2, &l3, &n3));
100 }
101 
102 /*----------------------------------------------------------------------*/
103 
106  const aff::Array<float>& v2)
107 {
108  aff::FortranArray<aff::Array<float> > fv1(v1),fv2(v2);
109  real* p1=fv1.castedpointer<real>();
110  real* p2=fv2.castedpointer<real>();
111  integer n1=fv1.last(0);
112  integer n2=fv2.last(0);
113  return(fillarray_(p1, p2, &n1, &n2));
114 }
115 
116 /*----------------------------------------------------------------------*/
117 
120 {
121  typedef Tcarray::Tvalue Tcvalue;
122  // prepare array that is large enough
123  integer maxa,maxb;
124  comdim_(&maxa, &maxb);
125  Tcarray result(maxa);
126  // prepare Fortran view
127  aff::FortranArray<Tcarray> fa(result);
128  complex* p=fa.castedpointer<complex>();
129  integer size;
130  sums_(p, &maxa, &size);
131  return(aff::subarray(result)(size));
132 }
133 
134 /*----------------------------------------------------------------------*/
135 
138 {
139  typedef Tzarray::Tvalue Tzvalue;
141  integer maxa,maxb;
142  comdim_(&maxa, &maxb);
143  Tzvalue* p=Tcast::cast(f77common_.array);
144  // create a shape
145  aff::Strided shape(aff::Shaper(1,f77common_.na,maxa)(1,f77common_.nb,maxb));
146  // create a representation
147  aff::SharedHeap<Tzvalue> repr(p, shape.memory_size());
148  // create array and return
149  return Tzarray(shape, repr);
150 }
151 
152 } // namespace f77interface
153 
154 /* ----- END OF f77interface.cc ----- */
utility for compile-time checked cast
Definition: checkedcast.h:84
Shape for a rectangular array layout.
Definition: strided.h:117
const Tsubscript & dimlast(const Tdim &i) const
last index as dimensioned in dimension i
Definition: fortranshape.h:79
prototypes for Fortran interface (prototypes)
aff::util::Subarray< C > subarray(const C &c)
Wrapper function to select correct type.
Definition: subarray.h:163
size checked pointer cast (prototypes)
A template class to share heap memory for different array projections.
Definition: sharedheap.h:252
external class to create subarrays (prototypes)
exceptions and error handling macros (prototypes)
int fillarray(const aff::Array< float > &v1, const aff::Array< float > &v2)
fill common block through Fortran subroutine
aff::Array< std::complex< double > > Tzarray
Definition: f77proto.h:59
#define AFF_abort(M)
Abort and give a message.
Definition: error.h:170
Tsize memory_size() const
total size of mapped memory range
Definition: strided.h:183
Full multi-dimensional array functionality.This is the full array class template. It adds no addition...
Definition: array.h:151
Tzarray viewcommon()
create view from common
const Tsubscript & last(const Tdim &i) const
last index in dimension i
Definition: fortranshape.h:77
Class to provide Fortran interface values.
Definition: fortranshape.h:107
T Tvalue
Element type.
Definition: array.h:403
int MAIN__()
essential definitions to satisfy linker
Definition: f77interface.cc:75
Shaper class for Fortran layout.
Definition: shaper.h:66
int fill(const aff::Array< int > &a)
interface function to Fortran77 subroutine fill
Definition: f77interface.cc:89
Tcarray sums()
read from common block through Fortran subroutine
rectangular Fortran array layout (prototypes)
This namespace collects all test functions for interfacing Fortran 77.
Definition: f77interface.cc:86
TT * castedpointer() const
return type-casted pointer to first element in Fortran layout
Definition: fortranshape.h:148
prepare information to pass to Fortran subroutines (prototypes)