Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roccom_f.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: roccom_f.C,v 1.50 2008/12/06 08:43:25 mtcampbe Exp $
24 
42 /* Author: Xiangmin Jiao */
43 
44 #include <iostream>
45 #include <cstdlib>
46 #include <cstring>
47 #include "roccom.h"
48 #include "mapptr.h"
49 #include "roccom_assertion.h"
50 
51 USE_COM_NAME_SPACE
52 
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 
55 using std::string;
56 
57 //================================================================
58 //============== Functions for initialization and finalization ==
59 //================================================================
60 
61 extern "C" void COM_F_FUNC2(com_init,COM_INIT)()
62 { Roccom_base::init( NULL, NULL); }
63 
64 extern "C" void COM_F_FUNC2(com_finalize,COM_FINALIZE)()
66 
67 extern "C" int COM_F_FUNC2(com_initialized,COM_INITIALIZED)()
68 { return Roccom_base::initialized(); }
69 
70 // Allows Fortran to call the abort function in the C stardard
71 // or MPI_Abort if MPI was initialized.
72 extern "C" void COM_F_FUNC2( com_abort, COM_ABORT) ( const int &ierr)
73 { Roccom_base::abort( ierr); }
74 
75 extern "C" void COM_F_FUNC2(com_set_default_communicator,
76  COM_SET_DEFAULT_COMMUNICATOR)( const int &comm)
78 
79 extern "C" int COM_F_FUNC2(com_get_default_communicator,
80  COM_GET_DEFAULT_COMMUNICATOR)()
82 
83 //================================================================
84 //================== Load and unload modules =====================
85 //================================================================
86 
87 extern "C" void COM_F_FUNC2(com_load_module, COM_LOAD_MODULE)
88  ( const char *libname, const char *winname,
89  int l1, int l2)
90 {
91  COM_get_roccom()->load_module( std::string( libname, l1),
92  std::string( winname, l2));
93 }
94 
95 extern "C" void COM_F_FUNC2( com_unload_module_1, COM_UNLOAD_MODULE_1)
96  ( const char *libname, int l1)
97 {
98  COM_get_roccom()->unload_module( std::string( libname, l1), "");
99 }
100 
101 extern "C" void COM_F_FUNC2( com_unload_module_2, COM_UNLOAD_MODULE_2)
102  ( const char *libname, const char *winname, int l1, int l2)
103 {
104  COM_get_roccom()->unload_module( std::string( libname, l1),
105  std::string( winname, l2));
106 }
107 
108 //================================================================
109 //============== Functions for window management =================
110 //================================================================
111 // Create a window with the given name.
112 #define CHKLEN(x) COM_assertion( x>=0 && x<MAX_NAMELEN)
113 
115 public:
117 };
118 
119 extern "C" int COM_F_FUNC2( com_chkptr_c, COM_CHKPTR_C)
120  ( const int &stage, const char *str1, void *ptr1,
121  const char *str2, void *ptr2,
122  int len1, int len2, int len3, int len4);
123 
124 inline int get_f90ptr_treat() {
126 
127  if ( rcom->_f90ptr_treat<0)
128  rcom->_f90ptr_treat = COM_F_FUNC2( com_chkptr_c, COM_CHKPTR_C)
129  ( 0, 0, 0, 0, 0, 0, 0, 0, 0);
130 
131  return rcom->_f90ptr_treat;
132 }
133 
134 extern "C" void COM_F_FUNC2(com_new_window_null,COM_NEW_WINDOW_NULL)
135  ( const char *w_str, int w_len)
136 { CHKLEN(w_len); COM_get_roccom()->new_window( string( w_str, w_len), MPI_COMM_NULL); }
137 
138 extern "C" void COM_F_FUNC2(com_new_window_mpi,COM_NEW_WINDOW_MPI)
139  ( const char *w_str, const int &c, int w_len) {
140  CHKLEN(w_len);
141  COM_get_roccom()->new_window
142  ( string( w_str, w_len), COMMPI_Comm_f2c(c, MPI_Comm()));
143 }
144 
145 // Delete a window with the given name
146 extern "C" void COM_F_FUNC2(com_delete_window,COM_DELETE_WINDOW)
147  ( const char *str, int len)
148 { CHKLEN(len); COM_get_roccom()->delete_window( string( str, len)); }
149 
150 extern "C" void COM_F_FUNC2(com_window_init_done_1arg, COM_WINDOW_INIT_DONE_1ARG)
151  ( const char *w_str, int w_len)
152 { CHKLEN(w_len); COM_get_roccom()->window_init_done( string(w_str,w_len)); }
153 
154 extern "C" void COM_F_FUNC2(com_window_init_done_2arg, COM_WINDOW_INIT_DONE_2ARG)
155  ( const char *w_str, int *c, int w_len)
156 { CHKLEN(w_len); COM_get_roccom()->window_init_done( string(w_str,w_len), *c); }
157 
158 extern "C" void COM_F_FUNC2(com_delete_pane,COM_DELETE_PANE)
159  ( const char *w_str, const int &pid, int w_len)
160 { CHKLEN(w_len); COM_get_roccom()->delete_pane( string(w_str,w_len), pid); }
161 
162 extern "C" void COM_F_FUNC2(com_new_attribute,COM_NEW_ATTRIBUTE)
163  ( const char *wa_str, const char &loc, const int &type,
164  const int &size, const char *u_str,
165  int wa_len, int l_len, int u_len)
166 {
167  CHKLEN((int)wa_len); CHKLEN((int)l_len); CHKLEN((int)u_len);
168  COM_get_roccom()->new_attribute( string( wa_str,(int)wa_len), loc, type,
169  size, string( u_str,(int)u_len));
170 }
171 
172 extern "C" void COM_F_FUNC2(com_delete_attribute,COM_DELETE_ATTRIBUTE)
173  ( const char *wa_str, int wa_len)
174 {
175  CHKLEN(wa_len);
176  COM_get_roccom()->delete_attribute( string( wa_str,wa_len));
177 }
178 
179 extern "C" void COM_F_FUNC2(com_set_size1, COM_SET_SIZE1)
180  ( const char *wa_str, const int &pane_id, const int &size, int len)
181 {
182  CHKLEN( len);
183  COM_get_roccom()->set_size( std::string(wa_str,len), pane_id, size);
184 }
185 
186 extern "C" void COM_F_FUNC2(com_set_size2, COM_SET_SIZE2)
187  ( const char *wa_str, const int &pane_id,
188  const int &size, const int &ng, int len)
189 {
190  CHKLEN( len);
191  COM_get_roccom()->set_size( std::string(wa_str,len), pane_id, size, ng);
192 }
193 
194 // Register an attribute name.
195 extern "C" void COM_F_FUNC2( com_map_cptr, COM_MAP_CPTR)
196  ( void *x, void **p)
197 { if ( x==(void*)p) *p=NULL; else *p = x; }
198 
199 // Register an attribute name.
200 extern "C" void COM_F_FUNC2( com_map_cptr_chr, COM_MAP_CPTR_CHR)
201  ( void *x, void **p, void *, void*)
202 { if ( x==(void*)p) *p=NULL; else *p = x; }
203 
204 // Register an attribute name.
205 extern "C" void COM_F_FUNC2( com_map_cptr_int, COM_MAP_CPTR_INT)
206  ( void *x, void **p)
207 { if ( x==(void*)p) *p=NULL; else *p = x; }
208 
209 // Register an attribute name.
210 extern "C" void COM_F_FUNC2( com_map_cptr_flt, COM_MAP_CPTR_FLT)
211  ( void *x, void **p)
212 { if ( x==(void*)p) *p=NULL; else *p = x; }
213 
214 // Register an attribute name.
215 extern "C" void COM_F_FUNC2( com_map_cptr_dbl, COM_MAP_CPTR_DBL)
216  ( void *x, void **p)
217 { if ( x==(void*)p) *p=NULL; else *p = x; }
218 
219 extern "C" void COM_F_FUNC2( com_set_array_null, COM_SET_ARRAY_NULL)
220  ( const char *wa_str, const int &pane_id, int len)
221 { COM_get_roccom()->set_array( std::string(wa_str,len),
222  pane_id, NULL); }
223 
224 extern "C" void COM_F_FUNC2( com_set_array_const_null, COM_SET_ARRAY_CONST_NULL)
225  ( const char *wa_str, const int &pane_id, int len)
226 { COM_get_roccom()->set_array( std::string(wa_str,len),
227  pane_id, NULL); }
228 
229 extern "C" void COM_F_FUNC2( com_set_external, COM_SET_EXTERNAL)
230  ( const char *wa_str, const int &pane_id, void *p, int len)
231 { COM_get_roccom()->set_array( std::string(wa_str,len),
232  pane_id, p); }
233 
234 extern "C" void COM_F_FUNC2( com_set_external_const, COM_SET_EXTERNAL_CONST)
235  ( const char *wa_str, const int &pane_id, void *p, int len)
236 { COM_get_roccom()->set_array( std::string(wa_str,len),
237  pane_id, p, true); }
238 
239 // Allows Fortran to execute a shell command as C does.
240 extern "C" int COM_F_FUNC2( com_call_system, COM_CALL_SYSTEM)
241  ( const char *com, int len)
242 { std::string command(com, len); return system( command.c_str()); }
243 
244 // Allows Fortran to call the exit function in the C standard.
245 extern "C" void COM_F_FUNC2( com_call_exit, COM_CALL_EXIT)
246  ( const int &ierr)
247 { exit(ierr); }
248 
249 // Allows Fortran to call the atexit function in the C standard.
250 extern "C" void COM_F_FUNC2( com_call_atexit, COM_CALL_ATEXIT)
251  ( Func_ptr func)
252 { atexit(func); }
253 
254 template <int dim, COM_Type type>
255 void *
256 com_get_address_f( void *addr, int l=0) {
257  Func_ptr f;
258 
259  if ( dim==0) {
260  if (type==COM_INTEGER)
261  f = COM_F_FUNC2(com_getptr_int0d,COM_GETPTR_INT0D);
262  else if ( type==COM_REAL)
263  f = COM_F_FUNC2(com_getptr_flt0d,COM_GETPTR_FLT0D);
264  else if ( type==COM_DOUBLE)
265  f = COM_F_FUNC2(com_getptr_dbl0d,COM_GETPTR_DBL0D);
266  else
267  COM_assertion(false);
268  }
269  else if ( dim==1) {
270  if (type==COM_INTEGER)
271  f = COM_F_FUNC2(com_getptr_int1d,COM_GETPTR_INT1D);
272  else if ( type==COM_REAL)
273  f = COM_F_FUNC2(com_getptr_flt1d,COM_GETPTR_FLT1D);
274  else if ( type==COM_DOUBLE)
275  f = COM_F_FUNC2(com_getptr_dbl1d,COM_GETPTR_DBL1D);
276  else
277  COM_assertion(false);
278  }
279  else if (dim==2) {
280  if (type==COM_INTEGER)
281  f = COM_F_FUNC2(com_getptr_int2d,COM_GETPTR_INT2D);
282  else if ( type==COM_REAL)
283  f = COM_F_FUNC2(com_getptr_flt2d,COM_GETPTR_FLT2D);
284  else if ( type==COM_DOUBLE)
285  f = COM_F_FUNC2(com_getptr_dbl2d,COM_GETPTR_DBL2D);
286  else
287  COM_assertion(false);
288  }
289  else if (dim==3) {
290  if (type==COM_INTEGER)
291  f = COM_F_FUNC2(com_getptr_int3d,COM_GETPTR_INT3D);
292  else if ( type==COM_REAL)
293  f = COM_F_FUNC2(com_getptr_flt3d,COM_GETPTR_FLT3D);
294  else if ( type==COM_DOUBLE)
295  f = COM_F_FUNC2(com_getptr_dbl3d,COM_GETPTR_DBL3D);
296  else
297  COM_assertion(false);
298  }
299  else
300  COM_assertion(false);
301 
302  void *ptr=NULL;
303  if ( l==0) {
304  typedef void(*Func)(void*,void**);
305  (*(Func)f)( addr, &ptr);
306  }
307  else {
308  typedef void(*Func)(void*,void**, int);
309  (*(Func)f)( addr, &ptr, l);
310  }
311 
312  return ptr;
313 }
314 
315 template <int dim, COM_Type type>
316 void
318  void *addr, int l=0) {
319  Func_ptr f;
320 
321  if ( dim==0) {
322  if (type==COM_INTEGER)
323  f = COM_F_FUNC2(com_mapptr_int0d,COM_MAPPTR_INT0D);
324  else if ( type==COM_REAL)
325  f = COM_F_FUNC2(com_mapptr_flt0d,COM_MAPPTR_FLT0D);
326  else if ( type==COM_DOUBLE)
327  f = COM_F_FUNC2(com_mapptr_dbl0d,COM_MAPPTR_DBL0D);
328  else
329  COM_assertion(false);
330  int tonull=(ptr.at()==NULL);
331 
332  if ( l) {
333  typedef void(*Func)(void*,int*,void*, int);
334  (*(Func)f)( addr, &tonull, ptr.at(), l);
335  }
336  else {
337  typedef void(*Func)(void*,int*,void*);
338  (*(Func)f)( addr, &tonull, ptr.at());
339  }
340  }
341  else if ( dim==1) {
342  if (type==COM_INTEGER)
343  f = COM_F_FUNC2(com_mapptr_int1d,COM_MAPPTR_INT1D);
344  else if ( type==COM_REAL)
345  f = COM_F_FUNC2(com_mapptr_flt1d,COM_MAPPTR_FLT1D);
346  else if ( type==COM_DOUBLE)
347  f = COM_F_FUNC2(com_mapptr_dbl1d,COM_MAPPTR_DBL1D);
348  else
349  COM_assertion(false);
350 
351  int tonull=(ptr.at()==NULL);
352  if ( l) {
353  typedef void(*Func)(void*,int*,void*,void*,int);
354  (*(Func)f)( addr, &tonull, ptr.at(), &ptr.n1, l);
355  }
356  else {
357  typedef void(*Func)(void*,int*,void*,void*);
358  (*(Func)f)( addr, &tonull,ptr.at(), &ptr.n1);
359  }
360  }
361  else if (dim==2) {
362  if (type==COM_INTEGER)
363  f = COM_F_FUNC2(com_mapptr_int2d,COM_MAPPTR_INT2D);
364  else if ( type==COM_REAL)
365  f = COM_F_FUNC2(com_mapptr_flt2d,COM_MAPPTR_FLT2D);
366  else if ( type==COM_DOUBLE)
367  f = COM_F_FUNC2(com_mapptr_dbl2d,COM_MAPPTR_DBL2D);
368  else
369  COM_assertion(false);
370 
371  int tonull=(ptr.at()==NULL);
372  if ( l) {
373  typedef void(*Func)(void*,int*,void*,void*,void*,int);
374  (*(Func)f)( addr, &tonull, ptr.at(), &ptr.n1, &ptr.n2, l);
375  }
376  else {
377  typedef void(*Func)(void*,int*,void*,void*,void*);
378  (*(Func)f)( addr, &tonull,ptr.at(), &ptr.n1, &ptr.n2);
379  }
380  }
381  else
382  COM_assertion(false);
383 }
384 
385 template <int dim, COM_Type type>
386 void
387 com_set_array_helper( const std::string &waname, int pane_id, void *addr,
388  int strd, int cap, int l=0) {
389  void *ptr=com_get_address_f<dim, type>( addr, l);
390 
391  COM_get_roccom()->set_array( waname, pane_id, ptr, strd, cap);
392 }
393 
394 // The following set_array*_f90 routines are called by functions
395 // defined in utilities.f90.
396 #define COM_SET_ARRAY_SCALAR( func, FUNC) \
397 extern "C" void COM_F_FUNC2( func, FUNC) \
398  ( const char *wa_str, const int &pid, void *addr, \
399  int wa_len, int) \
400 { \
401  CHKLEN(wa_len); \
402  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr); \
403 }
404 
405 COM_SET_ARRAY_SCALAR( com_set_array_chr, COM_SET_ARRAY_CHR);
406 COM_SET_ARRAY_SCALAR( com_set_array_int, COM_SET_ARRAY_INT);
407 COM_SET_ARRAY_SCALAR( com_set_array_flt, COM_SET_ARRAY_FLT);
408 COM_SET_ARRAY_SCALAR( com_set_array_dbl, COM_SET_ARRAY_DBL);
409 
410 template <int dim, COM_Type type>
411 void
412 com_set_array_f( const char *waname, int pane_id, void *addr,
413  int strd, int cap, int l1, int l2) {
414  int f90ptr_treat = get_f90ptr_treat();
415 
416  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
417  int wa_len=l2; CHKLEN(wa_len);
418  com_set_array_helper<dim,type>( string(waname, wa_len), pane_id, addr,
419  strd, cap, l1);
420  }
421  else {
422  int wa_len=l1; CHKLEN(wa_len);
423  if ( f90ptr_treat == Roccom_base::FPTR_APPEND) {
424  com_set_array_helper<dim,type>( string(waname, wa_len), pane_id, addr,
425  strd, cap, l2);
426  }
427  else {
428  com_set_array_helper<dim,type>( string(waname, wa_len), pane_id, addr,
429  strd, cap);
430  }
431  }
432 }
433 
434 // The following set_array*_f90 routines are called by functions
435 // defined in utilities.f90.
436 #define COM_SET_ARRAY_PTR( func, FUNC, dim, type) \
437 extern "C" void COM_F_FUNC2( func, FUNC) \
438  ( const char *wa_str, const int &pid, void *addr, \
439  int l1, int l2) \
440 { \
441  com_set_array_f<dim,type>( wa_str, pid, addr, 0, 0, l1, l2);\
442 }
443 
444 COM_SET_ARRAY_PTR( com_set_array_int1d, COM_SET_ARRAY_INT1D, 1, COM_INTEGER);
445 COM_SET_ARRAY_PTR( com_set_array_flt1d, COM_SET_ARRAY_FLT1D, 1, COM_REAL);
446 COM_SET_ARRAY_PTR( com_set_array_dbl1d, COM_SET_ARRAY_DBL1D, 1, COM_DOUBLE);
447 COM_SET_ARRAY_PTR( com_set_array_int2d, COM_SET_ARRAY_INT2D, 2, COM_INTEGER);
448 COM_SET_ARRAY_PTR( com_set_array_flt2d, COM_SET_ARRAY_FLT2D, 2, COM_REAL);
449 COM_SET_ARRAY_PTR( com_set_array_dbl2d, COM_SET_ARRAY_DBL2D, 2, COM_DOUBLE);
450 COM_SET_ARRAY_PTR( com_set_array_int3d, COM_SET_ARRAY_INT3D, 3, COM_INTEGER);
451 COM_SET_ARRAY_PTR( com_set_array_flt3d, COM_SET_ARRAY_FLT3D, 3, COM_REAL);
452 COM_SET_ARRAY_PTR( com_set_array_dbl3d, COM_SET_ARRAY_DBL3D, 3, COM_DOUBLE);
453 
454 #define COM_SET_ARRAY_STRD_SCALAR( func, FUNC) \
455 extern "C" void COM_F_FUNC2( func, FUNC) \
456  ( const char *wa_str, const int &pid, void *addr, const int &strd, \
457  int wa_len) \
458 { \
459  CHKLEN(wa_len); \
460  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr, strd); \
461 }
462 
463 COM_SET_ARRAY_STRD_SCALAR( com_set_array_int_strd, COM_SET_ARRAY_INT_STRD);
464 COM_SET_ARRAY_STRD_SCALAR( com_set_array_flt_strd, COM_SET_ARRAY_FLT_STRD);
465 COM_SET_ARRAY_STRD_SCALAR( com_set_array_dbl_strd, COM_SET_ARRAY_DBL_STRD);
466 
467 // The following set_array*_f90 routines are called by functions
468 // defined in utilities.f90.
469 #define COM_SET_ARRAY_STRD_PTR( func, FUNC, dim, type) \
470 extern "C" void COM_F_FUNC2( func, FUNC) \
471  ( const char *wa_str, const int &pid, void *addr, \
472  const int &strd, int l1, int l2) \
473 { \
474  com_set_array_f<dim,type>( wa_str, pid, addr, strd, 0, l1, l2);\
475 }
476 
477 COM_SET_ARRAY_STRD_PTR( com_set_array_int1d_strd, COM_SET_ARRAY_INT1D_STRD,
478  1, COM_INTEGER);
479 COM_SET_ARRAY_STRD_PTR( com_set_array_flt1d_strd, COM_SET_ARRAY_FLT1D_STRD,
480  1, COM_REAL);
481 COM_SET_ARRAY_STRD_PTR( com_set_array_dbl1d_strd, COM_SET_ARRAY_DBL1D_STRD,
482  1, COM_DOUBLE);
483 COM_SET_ARRAY_STRD_PTR( com_set_array_int2d_strd, COM_SET_ARRAY_INT2D_STRD,
484  2, COM_INTEGER);
485 COM_SET_ARRAY_STRD_PTR( com_set_array_flt2d_strd, COM_SET_ARRAY_FLT2D_STRD,
486  2, COM_REAL);
487 COM_SET_ARRAY_STRD_PTR( com_set_array_dbl2d_strd, COM_SET_ARRAY_DBL2D_STRD,
488  2, COM_DOUBLE);
489 COM_SET_ARRAY_STRD_PTR( com_set_array_int3d_strd, COM_SET_ARRAY_INT3D_STRD,
490  3, COM_INTEGER);
491 COM_SET_ARRAY_STRD_PTR( com_set_array_flt3d_strd, COM_SET_ARRAY_FLT3D_STRD,
492  3, COM_REAL);
493 COM_SET_ARRAY_STRD_PTR( com_set_array_dbl3d_strd, COM_SET_ARRAY_DBL3D_STRD,
494  3, COM_DOUBLE);
495 
496 #define COM_SET_ARRAY_DYN_SCALAR( func, FUNC) \
497 extern "C" void COM_F_FUNC2( func, FUNC) \
498  ( const char *wa_str, const int &pid, void *addr, const int &strd, \
499  const int &cap, int wa_len, int) \
500 { \
501  CHKLEN(wa_len); \
502  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr, strd, cap); \
503 }
504 
505 COM_SET_ARRAY_DYN_SCALAR( com_set_array_int_dyn, COM_SET_ARRAY_INT_DYN);
506 COM_SET_ARRAY_DYN_SCALAR( com_set_array_flt_dyn, COM_SET_ARRAY_FLT_DYN);
507 COM_SET_ARRAY_DYN_SCALAR( com_set_array_dbl_dyn, COM_SET_ARRAY_DBL_DYN);
508 
509 #define COM_SET_ARRAY_DYN_PTR( func, FUNC, dim, type) \
510 extern "C" void COM_F_FUNC2( func, FUNC) \
511  ( const char *wa_str, const int &pid, void *addr, \
512  const int &strd, const int &cap, int l1, int l2) \
513 { \
514  com_set_array_f<dim,type>( wa_str, pid, addr, strd, cap, l1, l2); \
515 }
516 
517 COM_SET_ARRAY_DYN_PTR( com_set_array_int1d_dyn, COM_SET_ARRAY_INT1D_DYN,
518  1, COM_INTEGER);
519 COM_SET_ARRAY_DYN_PTR( com_set_array_flt1d_dyn, COM_SET_ARRAY_FLT1D_DYN,
520  1, COM_REAL);
521 COM_SET_ARRAY_DYN_PTR( com_set_array_dbl1d_dyn, COM_SET_ARRAY_DBL1D_DYN,
522  1, COM_DOUBLE);
523 COM_SET_ARRAY_DYN_PTR( com_set_array_int2d_dyn, COM_SET_ARRAY_INT2D_DYN,
524  2, COM_INTEGER);
525 COM_SET_ARRAY_DYN_PTR( com_set_array_flt2d_dyn, COM_SET_ARRAY_FLT2D_DYN,
526  2, COM_REAL);
527 COM_SET_ARRAY_DYN_PTR( com_set_array_dbl2d_dyn, COM_SET_ARRAY_DBL2D_DYN,
528  2, COM_DOUBLE);
529 COM_SET_ARRAY_DYN_PTR( com_set_array_int3d_dyn, COM_SET_ARRAY_INT3D_DYN,
530  3, COM_INTEGER);
531 COM_SET_ARRAY_DYN_PTR( com_set_array_flt3d_dyn, COM_SET_ARRAY_FLT3D_DYN,
532  3, COM_REAL);
533 COM_SET_ARRAY_DYN_PTR( com_set_array_dbl3d_dyn, COM_SET_ARRAY_DBL3D_DYN,
534  3, COM_DOUBLE);
535 
536 template <int dim, COM_Type type>
537 void
538 com_set_array_const_helper(const std::string &waname, int pane_id, void *addr,
539  int strd, int cap, int l=0) {
540 
541  void *ptr=com_get_address_f<dim,type>( addr, l);
542 
543  COM_get_roccom()->set_array( waname, pane_id, ptr, strd, cap, true);
544 }
545 
546 // The following set_array_const*_f90 routines are called by functions
547 // defined in utilities.f90.
548 #define COM_SET_ARRAY_CONST_SCALAR( func, FUNC) \
549 extern "C" void COM_F_FUNC2( func, FUNC) \
550  ( const char *wa_str, const int &pid, void *addr, \
551  int wa_len, int) \
552 { \
553  CHKLEN(wa_len); \
554  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr, true); \
555 }
556 
557 COM_SET_ARRAY_CONST_SCALAR( com_set_array_const_chr, COM_SET_ARRAY_CONST_CHR);
558 COM_SET_ARRAY_CONST_SCALAR( com_set_array_const_int, COM_SET_ARRAY_CONST_INT);
559 COM_SET_ARRAY_CONST_SCALAR( com_set_array_const_flt, COM_SET_ARRAY_CONST_FLT);
560 COM_SET_ARRAY_CONST_SCALAR( com_set_array_const_dbl, COM_SET_ARRAY_CONST_DBL);
561 
562 template <int dim, COM_Type type>
563 void
564 com_set_array_const_f( const char *waname, int pane_id, void *addr,
565  int strd, int cap, int l1, int l2) {
566  int f90ptr_treat = get_f90ptr_treat();
567 
568  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
569  int wa_len=l2; CHKLEN(wa_len);
570  com_set_array_const_helper<dim,type>( string(waname, wa_len), pane_id,
571  addr, strd, cap, l1);
572  }
573  else {
574  int wa_len=l1; CHKLEN(wa_len);
575  if ( f90ptr_treat == Roccom_base::FPTR_APPEND)
576  com_set_array_const_helper<dim,type>( string(waname, wa_len), pane_id,
577  addr, strd, cap, l2);
578  else
579  com_set_array_const_helper<dim,type>( string(waname, wa_len), pane_id,
580  addr, strd, cap);
581  }
582 }
583 
584 // The following set_array_const*_f90 routines are called by functions
585 // defined in utilities.f90.
586 #define COM_SET_ARRAY_CONST_PTR( func, FUNC, dim, type) \
587 extern "C" void COM_F_FUNC2( func, FUNC) \
588  ( const char *wa_str, const int &pid, void *addr, \
589  int l1, int l2) \
590 { \
591  com_set_array_const_f<dim,type>( wa_str, pid, addr, 0, 0, l1, l2);\
592 }
593 
594 COM_SET_ARRAY_CONST_PTR( com_set_array_const_int1d,
595  COM_SET_ARRAY_CONST_INT1D, 1, COM_INTEGER);
596 COM_SET_ARRAY_CONST_PTR( com_set_array_const_flt1d,
597  COM_SET_ARRAY_CONST_FLT1D, 1, COM_REAL);
598 COM_SET_ARRAY_CONST_PTR( com_set_array_const_dbl1d,
599  COM_SET_ARRAY_CONST_DBL1D, 1, COM_DOUBLE);
600 COM_SET_ARRAY_CONST_PTR( com_set_array_const_int2d,
601  COM_SET_ARRAY_CONST_INT2D, 2, COM_INTEGER);
602 COM_SET_ARRAY_CONST_PTR( com_set_array_const_flt2d,
603  COM_SET_ARRAY_CONST_FLT2D, 2, COM_REAL);
604 COM_SET_ARRAY_CONST_PTR( com_set_array_const_dbl2d,
605  COM_SET_ARRAY_CONST_DBL2D, 2, COM_DOUBLE);
606 COM_SET_ARRAY_CONST_PTR( com_set_array_const_int3d,
607  COM_SET_ARRAY_CONST_INT3D, 3, COM_INTEGER);
608 COM_SET_ARRAY_CONST_PTR( com_set_array_const_flt3d,
609  COM_SET_ARRAY_CONST_FLT3D, 3, COM_REAL);
610 COM_SET_ARRAY_CONST_PTR( com_set_array_const_dbl3d,
611  COM_SET_ARRAY_CONST_DBL3D, 3, COM_DOUBLE);
612 
613 #define COM_SET_ARRAY_CONST_STRD_SCALAR( func, FUNC) \
614 extern "C" void COM_F_FUNC2( func, FUNC) \
615  ( const char *wa_str, const int &pid, void *addr, int &strd, \
616  int wa_len) \
617 { \
618  CHKLEN(wa_len); \
619  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr, strd, true); \
620 }
621 
622 COM_SET_ARRAY_CONST_STRD_SCALAR( com_set_array_const_int_strd,
623  COM_SET_ARRAY_CONST_INT_STRD);
624 COM_SET_ARRAY_CONST_STRD_SCALAR( com_set_array_const_flt_strd,
625  COM_SET_ARRAY_CONST_FLT_STRD);
626 COM_SET_ARRAY_CONST_STRD_SCALAR( com_set_array_const_dbl_strd,
627  COM_SET_ARRAY_CONST_DBL_STRD);
628 
629 // The following set_array_const*_f90 routines are called by functions
630 // defined in utilities.f90.
631 #define COM_SET_ARRAY_CONST_STRD_PTR( func, FUNC, dim, type) \
632 extern "C" void COM_F_FUNC2( func, FUNC) \
633  ( const char *wa_str, const int &pid, void *addr, \
634  const int &strd, int l1, int l2) \
635 { \
636  com_set_array_const_f<dim,type>( wa_str, pid, addr, strd, 0, l1, l2);\
637 }
638 
639 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_int1d_strd,
640  COM_SET_ARRAY_CONST_INT1D_STRD, 1, COM_INTEGER);
641 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_flt1d_strd,
642  COM_SET_ARRAY_CONST_FLT1D_STRD, 1, COM_REAL);
643 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_dbl1d_strd,
644  COM_SET_ARRAY_CONST_DBL1D_STRD, 1, COM_DOUBLE);
645 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_int2d_strd,
646  COM_SET_ARRAY_CONST_INT2D_STRD, 2, COM_INTEGER);
647 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_flt2d_strd,
648  COM_SET_ARRAY_CONST_FLT2D_STRD, 2, COM_REAL);
649 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_dbl2d_strd,
650  COM_SET_ARRAY_CONST_DBL2D_STRD, 2, COM_DOUBLE);
651 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_int3d_strd,
652  COM_SET_ARRAY_CONST_INT3D_STRD, 3, COM_INTEGER);
653 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_flt3d_strd,
654  COM_SET_ARRAY_CONST_FLT3D_STRD, 3, COM_REAL);
655 COM_SET_ARRAY_CONST_STRD_PTR( com_set_array_const_dbl3d_strd,
656  COM_SET_ARRAY_CONST_DBL3D_STRD, 3, COM_DOUBLE);
657 
658 #define COM_SET_ARRAY_CONST_DYN_SCALAR( func, FUNC) \
659 extern "C" void COM_F_FUNC2( func, FUNC) \
660  ( const char *wa_str, const int &pid, void *addr, const int &strd, \
661  const int &cap, int wa_len, int) \
662 { \
663  CHKLEN(wa_len); \
664  COM_get_roccom()->set_array( string(wa_str,wa_len), pid, addr, \
665  strd, cap, true); \
666 }
667 
668 COM_SET_ARRAY_CONST_DYN_SCALAR( com_set_array_const_int_dyn,
669  COM_SET_ARRAY_CONST_INT_DYN);
670 COM_SET_ARRAY_CONST_DYN_SCALAR( com_set_array_const_flt_dyn,
671  COM_SET_ARRAY_CONST_FLT_DYN);
672 COM_SET_ARRAY_CONST_DYN_SCALAR( com_set_array_const_dbl_dyn,
673  COM_SET_ARRAY_CONST_DBL_DYN);
674 
675 #define COM_SET_ARRAY_CONST_DYN_PTR( func, FUNC, dim, type) \
676 extern "C" void COM_F_FUNC2( func, FUNC) \
677  ( const char *wa_str, const int &pid, void *addr, \
678  const int &strd, const int &cap, int l1, int l2) \
679 { \
680  com_set_array_const_f<dim,type>( wa_str, pid, addr, strd, cap, l1, l2); \
681 }
682 
683 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_int1d_dyn,
684  COM_SET_ARRAY_CONST_INT1D_DYN, 1, COM_INTEGER);
685 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_flt1d_dyn,
686  COM_SET_ARRAY_CONST_FLT1D_DYN, 1, COM_REAL);
687 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_dbl1d_dyn,
688  COM_SET_ARRAY_CONST_DBL1D_DYN, 1, COM_DOUBLE);
689 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_int2d_dyn,
690  COM_SET_ARRAY_CONST_INT2D_DYN, 2, COM_INTEGER);
691 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_flt2d_dyn,
692  COM_SET_ARRAY_CONST_FLT2D_DYN, 2, COM_REAL);
693 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_dbl2d_dyn,
694  COM_SET_ARRAY_CONST_DBL2D_DYN, 2, COM_DOUBLE);
695 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_int3d_dyn,
696  COM_SET_ARRAY_CONST_INT3D_DYN, 3, COM_INTEGER);
697 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_flt3d_dyn,
698  COM_SET_ARRAY_CONST_FLT3D_DYN, 3, COM_REAL);
699 COM_SET_ARRAY_CONST_DYN_PTR( com_set_array_const_dbl3d_dyn,
700  COM_SET_ARRAY_CONST_DBL3D_DYN, 3, COM_DOUBLE);
701 
702 #define COM_SET_BOUNDS( func, FUNC) \
703 extern "C" void COM_F_FUNC2( func, FUNC) \
704  ( const char *wa_str, const int &pane_id, \
705  const void *lbound, const void *ubound, int len) \
706 { \
707  CHKLEN(len);\
708  COM_get_roccom()->set_bounds( string(wa_str,len), pane_id, lbound, ubound); \
709 }
710 
711 COM_SET_BOUNDS(com_set_bounds_int, COM_SET_BOUNDS_INT);
712 COM_SET_BOUNDS(com_set_bounds_flt, COM_SET_BOUNDS_FLT);
713 COM_SET_BOUNDS(com_set_bounds_dbl, COM_SET_BOUNDS_DBL);
714 
716 extern "C" void COM_F_FUNC2( com_alloc_array_win, COM_ALLOC_ARRAY_WIN)
717  ( const char *wa_str, int len)
718 { COM_get_roccom()->allocate_array( std::string( wa_str, len)); }
719 
720 extern "C" void COM_F_FUNC2( com_alloc_array_pane, COM_ALLOC_ARRAY_PANE)
721  ( const char *wa_str, const int &pane_id, int len)
722 { COM_get_roccom()->allocate_array( std::string( wa_str, len), pane_id); }
723 
724 template <int dim, COM_Type type, Access_mode mode>
725 void
726 com_obtain_array_helper( const std::string &waname, int pane_id, void *addr,
727  int &strd, int &cap, int offset, int l=0) {
728 
729  if ( mode != AM_RESIZE && strd<0) strd=0;
730 
731  Roccom_base::Pointer_descriptor ptr(NULL, dim);
732  if ( mode==AM_ALLOC) {
733  COM_get_roccom()->allocate_array( waname, pane_id, NULL, strd, cap);
734  COM_get_roccom()->get_array( waname, pane_id, ptr);
735  }
736  else if ( mode==AM_RESIZE) {
737  COM_get_roccom()->resize_array( waname, pane_id, NULL, strd, cap);
738  COM_get_roccom()->get_array( waname, pane_id, ptr);
739  }
740  else if ( mode == AM_COPY) {
741  if ( dim==0) ptr.ptr = addr; // If dim==0, it is not a pointer
742  else ptr.ptr = com_get_address_f<dim,type>( addr, l);
743 
744  COM_get_roccom()->copy_array( waname, pane_id, ptr.ptr,
745  strd, cap, offset);
746  }
747  else {
748  COM_get_roccom()->get_array( waname, pane_id, ptr, &strd,
749  &cap, mode==AM_GETC);
750  }
751 
752  if ( mode != AM_COPY)
753  com_set_address_f<dim, type>( ptr, addr, l);
754 }
755 
756 template <int dim, COM_Type type, Access_mode mode>
757 void
758 com_obtain_array_f( const char *waname, int pane_id, void *addr,
759  int &strd, int &cap, int offset,
760  int l1, int l2) {
761 
762  if ( dim==0 && mode==AM_COPY) { // Not a Fortran pointer
763  int wa_len=l1; CHKLEN(wa_len);
764  com_obtain_array_helper<dim,type,mode>( string(waname, wa_len), pane_id,
765  addr, strd, cap, offset);
766  }
767  else {
768  int f90ptr_treat = get_f90ptr_treat();
769 
770  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
771  int wa_len=l2; CHKLEN(wa_len);
772  com_obtain_array_helper<dim,type,mode>( string(waname, wa_len), pane_id,
773  addr, strd, cap, offset, l1);
774  }
775  else {
776  int wa_len=l1; CHKLEN(wa_len);
777  if ( f90ptr_treat == Roccom_base::FPTR_APPEND)
778  com_obtain_array_helper<dim,type,mode>( string(waname, wa_len), pane_id,
779  addr, strd, cap, offset, l2);
780  else
781  com_obtain_array_helper<dim,type,mode>( string(waname, wa_len), pane_id,
782  addr, strd, cap, offset);
783  }
784  }
785 }
786 
787 #define COM_OBTAIN_ARRAY( func, FUNC, dim, type, mode) \
788 extern "C" void COM_F_FUNC2( func, FUNC) \
789  ( const char *waname, const int &pane_id, \
790  void *addr, int l1, int l2) \
791 { \
792  int minusone=-1, zero = 0; \
793  com_obtain_array_f<dim,type,mode>( waname, pane_id, addr, \
794  minusone, zero, zero, l1, l2); \
795 }
796 
797 COM_OBTAIN_ARRAY(com_alloc_array_int, COM_ALLOC_ARRAY_INT,
798  0, COM_INTEGER,AM_ALLOC);
799 COM_OBTAIN_ARRAY(com_alloc_array_int1d, COM_ALLOC_ARRAY_INT1D,
800  1, COM_INTEGER,AM_ALLOC);
801 COM_OBTAIN_ARRAY(com_alloc_array_int2d, COM_ALLOC_ARRAY_INT2D,
802  2, COM_INTEGER,AM_ALLOC);
803 COM_OBTAIN_ARRAY(com_alloc_array_flt, COM_ALLOC_ARRAY_FLT,
804  0, COM_REAL,AM_ALLOC);
805 COM_OBTAIN_ARRAY(com_alloc_array_flt1d, COM_ALLOC_ARRAY_FLT1D,
806  1, COM_REAL,AM_ALLOC);
807 COM_OBTAIN_ARRAY(com_alloc_array_flt2d, COM_ALLOC_ARRAY_FLT2D,
808  2, COM_REAL,AM_ALLOC);
809 COM_OBTAIN_ARRAY(com_alloc_array_dbl, COM_ALLOC_ARRAY_DBL,
810  0, COM_DOUBLE,AM_ALLOC);
811 COM_OBTAIN_ARRAY(com_alloc_array_dbl1d, COM_ALLOC_ARRAY_DBL1D,
812  1, COM_DOUBLE,AM_ALLOC);
813 COM_OBTAIN_ARRAY(com_alloc_array_dbl2d, COM_ALLOC_ARRAY_DBL2D,
814  2, COM_DOUBLE,AM_ALLOC);
815 
816 extern "C" void COM_F_FUNC2( com_resize_array_win, COM_RESIZE_ARRAY_WIN)
817  ( const char *wa_str, int len)
818 { COM_get_roccom()->resize_array( std::string( wa_str, len)); }
819 
820 extern "C" void COM_F_FUNC2( com_resize_array_pane, COM_RESIZE_ARRAY_PANE)
821  ( const char *wa_str, const int &pane_id, int len)
822 { COM_get_roccom()->resize_array( std::string( wa_str, len), pane_id); }
823 
824 COM_OBTAIN_ARRAY(com_resize_array_int, COM_RESIZE_ARRAY_INT,
826 COM_OBTAIN_ARRAY(com_resize_array_int1d, COM_RESIZE_ARRAY_INT1D,
828 COM_OBTAIN_ARRAY(com_resize_array_int2d, COM_RESIZE_ARRAY_INT2D,
830 COM_OBTAIN_ARRAY(com_resize_array_flt, COM_RESIZE_ARRAY_FLT,
831  0, COM_REAL,AM_RESIZE);
832 COM_OBTAIN_ARRAY(com_resize_array_flt1d, COM_RESIZE_ARRAY_FLT1D,
833  1, COM_REAL,AM_RESIZE);
834 COM_OBTAIN_ARRAY(com_resize_array_flt2d, COM_RESIZE_ARRAY_FLT2D,
835  2, COM_REAL,AM_RESIZE);
836 COM_OBTAIN_ARRAY(com_resize_array_dbl, COM_RESIZE_ARRAY_DBL,
837  0, COM_DOUBLE,AM_RESIZE);
838 COM_OBTAIN_ARRAY(com_resize_array_dbl1d, COM_RESIZE_ARRAY_DBL1D,
839  1, COM_DOUBLE,AM_RESIZE);
840 COM_OBTAIN_ARRAY(com_resize_array_dbl2d, COM_RESIZE_ARRAY_DBL2D,
841  2, COM_DOUBLE,AM_RESIZE);
842 
843 COM_OBTAIN_ARRAY(com_get_array_int, COM_GET_ARRAY_INT,
844  0, COM_INTEGER,AM_GET);
845 COM_OBTAIN_ARRAY(com_get_array_int1d, COM_GET_ARRAY_INT1D,
846  1, COM_INTEGER,AM_GET);
847 COM_OBTAIN_ARRAY(com_get_array_int2d, COM_GET_ARRAY_INT2D,
848  2, COM_INTEGER,AM_GET);
849 COM_OBTAIN_ARRAY(com_get_array_flt, COM_GET_ARRAY_FLT,
850  0, COM_REAL,AM_GET);
851 COM_OBTAIN_ARRAY(com_get_array_flt1d, COM_GET_ARRAY_FLT1D,
852  1, COM_REAL,AM_GET);
853 COM_OBTAIN_ARRAY(com_get_array_flt2d, COM_GET_ARRAY_FLT2D,
854  2, COM_REAL,AM_GET);
855 COM_OBTAIN_ARRAY(com_get_array_dbl, COM_GET_ARRAY_DBL,
856  0, COM_DOUBLE,AM_GET);
857 COM_OBTAIN_ARRAY(com_get_array_dbl1d, COM_GET_ARRAY_DBL1D,
858  1, COM_DOUBLE,AM_GET);
859 COM_OBTAIN_ARRAY(com_get_array_dbl2d, COM_GET_ARRAY_DBL2D,
860  2, COM_DOUBLE,AM_GET);
861 
862 COM_OBTAIN_ARRAY(com_get_array_const_int, COM_GET_ARRAY_CONST_INT,
863  0, COM_INTEGER,AM_GETC);
864 COM_OBTAIN_ARRAY(com_get_array_const_int1d, COM_GET_ARRAY_CONST_INT1D,
865  1, COM_INTEGER,AM_GETC);
866 COM_OBTAIN_ARRAY(com_get_array_const_int2d, COM_GET_ARRAY_CONST_INT2D,
867  2, COM_INTEGER,AM_GETC);
868 COM_OBTAIN_ARRAY(com_get_array_const_flt, COM_GET_ARRAY_CONST_FLT,
869  0, COM_REAL,AM_GETC);
870 COM_OBTAIN_ARRAY(com_get_array_const_flt1d, COM_GET_ARRAY_CONST_FLT1D,
871  1, COM_REAL,AM_GETC);
872 COM_OBTAIN_ARRAY(com_get_array_const_flt2d, COM_GET_ARRAY_CONST_FLT2D,
873  2, COM_REAL,AM_GETC);
874 COM_OBTAIN_ARRAY(com_get_array_const_dbl, COM_GET_ARRAY_CONST_DBL,
875  0, COM_DOUBLE,AM_GETC);
876 COM_OBTAIN_ARRAY(com_get_array_const_dbl1d, COM_GET_ARRAY_CONST_DBL1D,
877  1, COM_DOUBLE,AM_GETC);
878 COM_OBTAIN_ARRAY(com_get_array_const_dbl2d, COM_GET_ARRAY_CONST_DBL2D,
879  2, COM_DOUBLE,AM_GETC);
880 
881 COM_OBTAIN_ARRAY(com_copy_array_int, COM_COPY_ARRAY_INT,
882  0, COM_INTEGER,AM_COPY);
883 COM_OBTAIN_ARRAY(com_copy_array_int1d, COM_COPY_ARRAY_INT1D,
884  1, COM_INTEGER,AM_COPY);
885 COM_OBTAIN_ARRAY(com_copy_array_int2d, COM_COPY_ARRAY_INT2D,
886  2, COM_INTEGER,AM_COPY);
887 COM_OBTAIN_ARRAY(com_copy_array_int3d, COM_COPY_ARRAY_INT3D,
888  3, COM_INTEGER,AM_COPY);
889 COM_OBTAIN_ARRAY(com_copy_array_flt, COM_COPY_ARRAY_FLT,
890  0, COM_REAL,AM_COPY);
891 COM_OBTAIN_ARRAY(com_copy_array_flt1d, COM_COPY_ARRAY_FLT1D,
892  1, COM_REAL,AM_COPY);
893 COM_OBTAIN_ARRAY(com_copy_array_flt2d, COM_COPY_ARRAY_FLT2D,
894  2, COM_REAL,AM_COPY);
895 COM_OBTAIN_ARRAY(com_copy_array_flt3d, COM_COPY_ARRAY_FLT3D,
896  3, COM_REAL,AM_COPY);
897 COM_OBTAIN_ARRAY(com_copy_array_dbl, COM_COPY_ARRAY_DBL,
898  0, COM_DOUBLE,AM_COPY);
899 COM_OBTAIN_ARRAY(com_copy_array_dbl1d, COM_COPY_ARRAY_DBL1D,
900  1, COM_DOUBLE,AM_COPY);
901 COM_OBTAIN_ARRAY(com_copy_array_dbl2d, COM_COPY_ARRAY_DBL2D,
902  2, COM_DOUBLE,AM_COPY);
903 COM_OBTAIN_ARRAY(com_copy_array_dbl3d, COM_COPY_ARRAY_DBL3D,
904  3, COM_DOUBLE,AM_COPY);
905 
906 #define COM_OBTAIN_ARRAY_STRD( func, FUNC, dim, type, mode) \
907 extern "C" void COM_F_FUNC2( func, FUNC) \
908  ( const char *waname, const int &pane_id, void *addr, \
909  int &strd, int l1, int l2) \
910 { \
911  int zero = 0; \
912  com_obtain_array_f<dim, type,mode>( waname, pane_id, addr, strd, zero, \
913  zero, l1, l2); \
914 }
915 
916 COM_OBTAIN_ARRAY_STRD(com_alloc_array_int1d_strd,COM_ALLOC_ARRAY_INT1D_STRD,
917  1, COM_INTEGER, AM_ALLOC);
918 COM_OBTAIN_ARRAY_STRD(com_alloc_array_int2d_strd,COM_ALLOC_ARRAY_INT2D_STRD,
919  2, COM_INTEGER, AM_ALLOC);
920 COM_OBTAIN_ARRAY_STRD(com_alloc_array_flt1d_strd,COM_ALLOC_ARRAY_FLT1D_STRD,
921  1, COM_REAL, AM_ALLOC);
922 COM_OBTAIN_ARRAY_STRD(com_alloc_array_flt2d_strd,COM_ALLOC_ARRAY_FLT2D_STRD,
923  2, COM_REAL, AM_ALLOC);
924 COM_OBTAIN_ARRAY_STRD(com_alloc_array_dbl1d_strd,COM_ALLOC_ARRAY_DBL1D_STRD,
925  1, COM_DOUBLE, AM_ALLOC);
926 COM_OBTAIN_ARRAY_STRD(com_alloc_array_dbl2d_strd,COM_ALLOC_ARRAY_DBL2D_STRD,
927  2, COM_DOUBLE, AM_ALLOC);
928 
929 COM_OBTAIN_ARRAY_STRD(com_resize_array_int1d_strd,COM_RESIZE_ARRAY_INT1D_STRD,
930  1, COM_INTEGER, AM_RESIZE);
931 COM_OBTAIN_ARRAY_STRD(com_resize_array_int2d_strd,COM_RESIZE_ARRAY_INT2D_STRD,
932  2, COM_INTEGER, AM_RESIZE);
933 COM_OBTAIN_ARRAY_STRD(com_resize_array_flt1d_strd,COM_RESIZE_ARRAY_FLT1D_STRD,
934  1, COM_REAL, AM_RESIZE);
935 COM_OBTAIN_ARRAY_STRD(com_resize_array_flt2d_strd,COM_RESIZE_ARRAY_FLT2D_STRD,
936  2, COM_REAL, AM_RESIZE);
937 COM_OBTAIN_ARRAY_STRD(com_resize_array_dbl1d_strd,COM_RESIZE_ARRAY_DBL1D_STRD,
938  1, COM_DOUBLE, AM_RESIZE);
939 COM_OBTAIN_ARRAY_STRD(com_resize_array_dbl2d_strd,COM_RESIZE_ARRAY_DBL2D_STRD,
940  2, COM_DOUBLE, AM_RESIZE);
941 
942 COM_OBTAIN_ARRAY_STRD(com_get_array_int1d_strd,COM_GET_ARRAY_INT1D_STRD,
943  1, COM_INTEGER, AM_GET);
944 COM_OBTAIN_ARRAY_STRD(com_get_array_int2d_strd,COM_GET_ARRAY_INT2D_STRD,
945  2, COM_INTEGER, AM_GET);
946 COM_OBTAIN_ARRAY_STRD(com_get_array_flt1d_strd,COM_GET_ARRAY_FLT1D_STRD,
947  1, COM_REAL, AM_GET);
948 COM_OBTAIN_ARRAY_STRD(com_get_array_flt2d_strd,COM_GET_ARRAY_FLT2D_STRD,
949  2, COM_REAL, AM_GET);
950 COM_OBTAIN_ARRAY_STRD(com_get_array_dbl1d_strd,COM_GET_ARRAY_DBL1D_STRD,
951  1, COM_DOUBLE, AM_GET);
952 COM_OBTAIN_ARRAY_STRD(com_get_array_dbl2d_strd,COM_GET_ARRAY_DBL2D_STRD,
953  2, COM_DOUBLE, AM_GET);
954 
955 COM_OBTAIN_ARRAY_STRD(com_get_array_const_int1d_strd,
956  COM_GET_ARRAY_CONST_INT1D_STRD, 1, COM_INTEGER, AM_GETC);
957 COM_OBTAIN_ARRAY_STRD(com_get_array_const_int2d_strd,
958  COM_GET_ARRAY_CONST_INT2D_STRD, 2, COM_INTEGER, AM_GETC);
959 COM_OBTAIN_ARRAY_STRD(com_get_array_const_flt1d_strd,
960  COM_GET_ARRAY_CONST_FLT1D_STRD, 1, COM_REAL, AM_GETC);
961 COM_OBTAIN_ARRAY_STRD(com_get_array_const_flt2d_strd,
962  COM_GET_ARRAY_CONST_FLT2D_STRD, 2, COM_REAL, AM_GETC);
963 COM_OBTAIN_ARRAY_STRD(com_get_array_const_dbl1d_strd,
964  COM_GET_ARRAY_CONST_DBL1D_STRD, 1, COM_DOUBLE, AM_GETC);
965 COM_OBTAIN_ARRAY_STRD(com_get_array_const_dbl2d_strd,
966  COM_GET_ARRAY_CONST_DBL2D_STRD, 2, COM_DOUBLE, AM_GETC);
967 
968 COM_OBTAIN_ARRAY_STRD(com_copy_array_int_strd,COM_COPY_ARRAY_INT_STRD,
969  0, COM_INTEGER, AM_COPY);
970 COM_OBTAIN_ARRAY_STRD(com_copy_array_int1d_strd,COM_COPY_ARRAY_INT1D_STRD,
971  1, COM_INTEGER, AM_COPY);
972 COM_OBTAIN_ARRAY_STRD(com_copy_array_int2d_strd,COM_COPY_ARRAY_INT2D_STRD,
973  2, COM_INTEGER, AM_COPY);
974 COM_OBTAIN_ARRAY_STRD(com_copy_array_int3d_strd,COM_COPY_ARRAY_INT3D_STRD,
975  3, COM_INTEGER, AM_COPY);
976 COM_OBTAIN_ARRAY_STRD(com_copy_array_flt_strd,COM_COPY_ARRAY_FLT_STRD,
977  0, COM_REAL, AM_COPY);
978 COM_OBTAIN_ARRAY_STRD(com_copy_array_flt1d_strd,COM_COPY_ARRAY_FLT1D_STRD,
979  1, COM_REAL, AM_COPY);
980 COM_OBTAIN_ARRAY_STRD(com_copy_array_flt2d_strd,COM_COPY_ARRAY_FLT2D_STRD,
981  2, COM_REAL, AM_COPY);
982 COM_OBTAIN_ARRAY_STRD(com_copy_array_flt3d_strd,COM_COPY_ARRAY_FLT3D_STRD,
983  3, COM_REAL, AM_COPY);
984 COM_OBTAIN_ARRAY_STRD(com_copy_array_dbl_strd,COM_COPY_ARRAY_DBL_STRD,
985  0, COM_DOUBLE, AM_COPY);
986 COM_OBTAIN_ARRAY_STRD(com_copy_array_dbl1d_strd,COM_COPY_ARRAY_DBL1D_STRD,
987  1, COM_DOUBLE, AM_COPY);
988 COM_OBTAIN_ARRAY_STRD(com_copy_array_dbl2d_strd,COM_COPY_ARRAY_DBL2D_STRD,
989  2, COM_DOUBLE, AM_COPY);
990 COM_OBTAIN_ARRAY_STRD(com_copy_array_dbl3d_strd,COM_COPY_ARRAY_DBL3D_STRD,
991  3, COM_DOUBLE, AM_COPY);
992 
993 #define COM_OBTAIN_ARRAY_DYN( func, FUNC, dim, type, mode) \
994 extern "C" void COM_F_FUNC2( func, FUNC) \
995 ( const char *waname, const int &pane_id, void *addr, \
996  int &strd, int &cap, int l1, int l2) \
997 { \
998  com_obtain_array_f<dim, type, mode>( waname, pane_id, addr, \
999  strd, cap, 0, l1, l2);\
1000 }
1001 
1002 COM_OBTAIN_ARRAY_DYN(com_alloc_array_int1d_dyn,COM_ALLOC_ARRAY_INT1D_DYN,
1003  1, COM_INTEGER, AM_ALLOC);
1004 COM_OBTAIN_ARRAY_DYN(com_alloc_array_int2d_dyn,COM_ALLOC_ARRAY_INT2D_DYN,
1005  2, COM_INTEGER, AM_ALLOC);
1006 COM_OBTAIN_ARRAY_DYN(com_alloc_array_flt1d_dyn,COM_ALLOC_ARRAY_FLT1D_DYN,
1007  1, COM_REAL, AM_ALLOC);
1008 COM_OBTAIN_ARRAY_DYN(com_alloc_array_flt2d_dyn,COM_ALLOC_ARRAY_FLT2D_DYN,
1009  2, COM_REAL, AM_ALLOC);
1010 COM_OBTAIN_ARRAY_DYN(com_alloc_array_dbl1d_dyn,COM_ALLOC_ARRAY_DBL1D_DYN,
1011  1, COM_DOUBLE, AM_ALLOC);
1012 COM_OBTAIN_ARRAY_DYN(com_alloc_array_dbl2d_dyn,COM_ALLOC_ARRAY_DBL2D_DYN,
1013  2, COM_DOUBLE, AM_ALLOC);
1014 
1015 COM_OBTAIN_ARRAY_DYN(com_resize_array_int1d_dyn,COM_RESIZE_ARRAY_INT1D_DYN,
1016  1, COM_INTEGER, AM_RESIZE);
1017 COM_OBTAIN_ARRAY_DYN(com_resize_array_int2d_dyn,COM_RESIZE_ARRAY_INT2D_DYN,
1018  2, COM_INTEGER, AM_RESIZE);
1019 COM_OBTAIN_ARRAY_DYN(com_resize_array_flt1d_dyn,COM_RESIZE_ARRAY_FLT1D_DYN,
1020  1, COM_REAL, AM_RESIZE);
1021 COM_OBTAIN_ARRAY_DYN(com_resize_array_flt2d_dyn,COM_RESIZE_ARRAY_FLT2D_DYN,
1022  2, COM_REAL, AM_RESIZE);
1023 COM_OBTAIN_ARRAY_DYN(com_resize_array_dbl1d_dyn,COM_RESIZE_ARRAY_DBL1D_DYN,
1024  1, COM_DOUBLE, AM_RESIZE);
1025 COM_OBTAIN_ARRAY_DYN(com_resize_array_dbl2d_dyn,COM_RESIZE_ARRAY_DBL2D_DYN,
1026  2, COM_DOUBLE, AM_RESIZE);
1027 
1028 COM_OBTAIN_ARRAY_DYN(com_get_array_int1d_dyn,COM_GET_ARRAY_INT1D_DYN,
1029  1, COM_INTEGER, AM_GET);
1030 COM_OBTAIN_ARRAY_DYN(com_get_array_int2d_dyn,COM_GET_ARRAY_INT2D_DYN,
1031  2, COM_INTEGER, AM_GET);
1032 COM_OBTAIN_ARRAY_DYN(com_get_array_flt1d_dyn,COM_GET_ARRAY_FLT1D_DYN,
1033  1, COM_REAL, AM_GET);
1034 COM_OBTAIN_ARRAY_DYN(com_get_array_flt2d_dyn,COM_GET_ARRAY_FLT2D_DYN,
1035  2, COM_REAL, AM_GET);
1036 COM_OBTAIN_ARRAY_DYN(com_get_array_dbl1d_dyn,COM_GET_ARRAY_DBL1D_DYN,
1037  1, COM_DOUBLE, AM_GET);
1038 COM_OBTAIN_ARRAY_DYN(com_get_array_dbl2d_dyn,COM_GET_ARRAY_DBL2D_DYN,
1039  2, COM_DOUBLE, AM_GET);
1040 
1041 COM_OBTAIN_ARRAY_DYN(com_get_array_const_int1d_dyn,
1042  COM_GET_ARRAY_CONST_INT1D_DYN, 1, COM_INTEGER, AM_GETC);
1043 COM_OBTAIN_ARRAY_DYN(com_get_array_const_int2d_dyn,
1044  COM_GET_ARRAY_CONST_INT2D_DYN, 2, COM_INTEGER, AM_GETC);
1045 COM_OBTAIN_ARRAY_DYN(com_get_array_const_flt1d_dyn,
1046  COM_GET_ARRAY_CONST_FLT1D_DYN, 1, COM_REAL, AM_GETC);
1047 COM_OBTAIN_ARRAY_DYN(com_get_array_const_flt2d_dyn,
1048  COM_GET_ARRAY_CONST_FLT2D_DYN, 2, COM_REAL, AM_GETC);
1049 COM_OBTAIN_ARRAY_DYN(com_get_array_const_dbl1d_dyn,
1050  COM_GET_ARRAY_CONST_DBL1D_DYN, 1, COM_DOUBLE, AM_GETC);
1051 COM_OBTAIN_ARRAY_DYN(com_get_array_const_dbl2d_dyn,
1052  COM_GET_ARRAY_CONST_DBL2D_DYN, 2, COM_DOUBLE, AM_GETC);
1053 
1054 COM_OBTAIN_ARRAY_DYN(com_copy_array_int_dyn,COM_COPY_ARRAY_INT_DYN,
1055  0, COM_INTEGER, AM_COPY);
1056 COM_OBTAIN_ARRAY_DYN(com_copy_array_int1d_dyn,COM_COPY_ARRAY_INT1D_DYN,
1057  1, COM_INTEGER, AM_COPY);
1058 COM_OBTAIN_ARRAY_DYN(com_copy_array_int2d_dyn,COM_COPY_ARRAY_INT2D_DYN,
1059  2, COM_INTEGER, AM_COPY);
1060 COM_OBTAIN_ARRAY_DYN(com_copy_array_int3d_dyn,COM_COPY_ARRAY_INT3D_DYN,
1061  3, COM_INTEGER, AM_COPY);
1062 COM_OBTAIN_ARRAY_DYN(com_copy_array_flt_dyn,COM_COPY_ARRAY_FLT_DYN,
1063  0, COM_REAL, AM_COPY);
1064 COM_OBTAIN_ARRAY_DYN(com_copy_array_flt1d_dyn,COM_COPY_ARRAY_FLT1D_DYN,
1065  1, COM_REAL, AM_COPY);
1066 COM_OBTAIN_ARRAY_DYN(com_copy_array_flt2d_dyn,COM_COPY_ARRAY_FLT2D_DYN,
1067  2, COM_REAL, AM_COPY);
1068 COM_OBTAIN_ARRAY_DYN(com_copy_array_flt3d_dyn,COM_COPY_ARRAY_FLT3D_DYN,
1069  3, COM_REAL, AM_COPY);
1070 COM_OBTAIN_ARRAY_DYN(com_copy_array_dbl_dyn,COM_COPY_ARRAY_DBL_DYN,
1071  0, COM_DOUBLE, AM_COPY);
1072 COM_OBTAIN_ARRAY_DYN(com_copy_array_dbl1d_dyn,COM_COPY_ARRAY_DBL1D_DYN,
1073  1, COM_DOUBLE, AM_COPY);
1074 COM_OBTAIN_ARRAY_DYN(com_copy_array_dbl2d_dyn,COM_COPY_ARRAY_DBL2D_DYN,
1075  2, COM_DOUBLE, AM_COPY);
1076 COM_OBTAIN_ARRAY_DYN(com_copy_array_dbl3d_dyn,COM_COPY_ARRAY_DBL3D_DYN,
1077  3, COM_DOUBLE, AM_COPY);
1078 
1079 #define COM_COPY_ARRAY_OFF( func, FUNC, dim, type) \
1080 extern "C" void COM_F_FUNC2( func, FUNC) \
1081 ( const char *waname, const int &pane_id, void *addr, const int &strd, \
1082  const int &cap, const int &offset, int l1, int l2) \
1083 { \
1084  com_obtain_array_f<dim, type, AM_COPY>( waname, pane_id, addr, \
1085  const_cast<int&>(strd), const_cast<int&>(cap), offset, l1, l2);\
1086 }
1087 
1088 COM_COPY_ARRAY_OFF(com_copy_array_int_off,COM_COPY_ARRAY_INT_OFF,
1089  0, COM_INTEGER);
1090 COM_COPY_ARRAY_OFF(com_copy_array_int1d_off,COM_COPY_ARRAY_INT1D_OFF,
1091  1, COM_INTEGER);
1092 COM_COPY_ARRAY_OFF(com_copy_array_int2d_off,COM_COPY_ARRAY_INT2D_OFF,
1093  2, COM_INTEGER);
1094 COM_COPY_ARRAY_OFF(com_copy_array_int3d_off,COM_COPY_ARRAY_INT3D_OFF,
1095  3, COM_INTEGER);
1096 COM_COPY_ARRAY_OFF(com_copy_array_flt_off,COM_COPY_ARRAY_FLT_OFF,
1097  0, COM_REAL);
1098 COM_COPY_ARRAY_OFF(com_copy_array_flt1d_off,COM_COPY_ARRAY_FLT1D_OFF,
1099  1, COM_REAL);
1100 COM_COPY_ARRAY_OFF(com_copy_array_flt2d_off,COM_COPY_ARRAY_FLT2D_OFF,
1101  2, COM_REAL);
1102 COM_COPY_ARRAY_OFF(com_copy_array_flt3d_off,COM_COPY_ARRAY_FLT3D_OFF,
1103  3, COM_REAL);
1104 COM_COPY_ARRAY_OFF(com_copy_array_dbl_off,COM_COPY_ARRAY_DBL_OFF,
1105  0, COM_DOUBLE);
1106 COM_COPY_ARRAY_OFF(com_copy_array_dbl1d_off,COM_COPY_ARRAY_DBL1D_OFF,
1107  1, COM_DOUBLE);
1108 COM_COPY_ARRAY_OFF(com_copy_array_dbl2d_off,COM_COPY_ARRAY_DBL2D_OFF,
1109  2, COM_DOUBLE);
1110 COM_COPY_ARRAY_OFF(com_copy_array_dbl3d_off,COM_COPY_ARRAY_DBL3D_OFF,
1111  3, COM_DOUBLE);
1112 
1113 #define COM_APPEND_ARRAY_SCALAR( func, FUNC) \
1114 extern "C" void COM_F_FUNC2( func, FUNC) \
1115  ( const char *waname, const int &pane_id, \
1116  const void *val, const int &v_strd, const int &v_size, int wa_len) \
1117 { \
1118  CHKLEN(wa_len); \
1119  COM_get_roccom()->append_array( string(waname,wa_len), pane_id, \
1120  val, v_strd, v_size); \
1121 }
1122 
1123 COM_APPEND_ARRAY_SCALAR( com_append_array_chr, COM_APPEND_ARRAY_CHR);
1124 COM_APPEND_ARRAY_SCALAR( com_append_array_int, COM_APPEND_ARRAY_INT);
1125 COM_APPEND_ARRAY_SCALAR( com_append_array_flt, COM_APPEND_ARRAY_FLT);
1126 COM_APPEND_ARRAY_SCALAR( com_append_array_dbl, COM_APPEND_ARRAY_DBL);
1127 
1128 template <int dim, COM_Type type>
1129 void
1130 com_append_array_helper( const std::string &waname, int pane_id,
1131  const void *val, int v_strd, int v_size,
1132  int l=0) {
1133 
1134  void *v_ptr=com_get_address_f<dim, type>( const_cast<void*>(val), l);
1135 
1136  COM_get_roccom()->append_array( waname, pane_id, v_ptr, v_strd, v_size);
1137 }
1138 
1139 template <int dim, COM_Type type>
1140 void
1141 com_append_array_f( const char *waname, int pane_id,
1142  const void *val, int v_strd, int v_size,
1143  int l1, int l2) {
1144  int f90ptr_treat = get_f90ptr_treat();
1145 
1146  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
1147  int wa_len=l2; CHKLEN(wa_len);
1148  com_append_array_helper<dim,type>( string(waname, wa_len), pane_id,
1149  val, v_strd, v_size, l1);
1150  }
1151  else {
1152  int wa_len=l1; CHKLEN(wa_len);
1153  if ( f90ptr_treat == Roccom_base::FPTR_APPEND)
1154  com_append_array_helper<dim,type>( string(waname, wa_len), pane_id,
1155  val, v_strd, v_size, l2);
1156  else
1157  com_append_array_helper<dim,type>( string(waname, wa_len), pane_id,
1158  val, v_strd, v_size);
1159  }
1160 }
1161 
1162 #define COM_APPEND_ARRAY( func, FUNC, dim, type) \
1163 extern "C" void COM_F_FUNC2( func, FUNC) \
1164  ( const char *waname, const int &pane_id, \
1165  const void *val, int &v_strd, int &v_size, int l1, int l2) \
1166 { \
1167  com_append_array_f<dim,type>( waname, pane_id, \
1168  val, v_strd, v_size, l1, l2); \
1169 }
1170 
1171 COM_APPEND_ARRAY( com_append_array_int1d, COM_APPEND_ARRAY_INT1D, 1, COM_INTEGER);
1172 COM_APPEND_ARRAY( com_append_array_flt1d, COM_APPEND_ARRAY_FLT1D, 1, COM_REAL);
1173 COM_APPEND_ARRAY( com_append_array_dbl1d, COM_APPEND_ARRAY_DBL1D, 1, COM_DOUBLE);
1174 COM_APPEND_ARRAY( com_append_array_int2d, COM_APPEND_ARRAY_INT2D, 2, COM_INTEGER);
1175 COM_APPEND_ARRAY( com_append_array_flt2d, COM_APPEND_ARRAY_FLT2D, 2, COM_REAL);
1176 COM_APPEND_ARRAY( com_append_array_dbl2d, COM_APPEND_ARRAY_DBL2D, 2, COM_DOUBLE);
1177 COM_APPEND_ARRAY( com_append_array_int3d, COM_APPEND_ARRAY_INT3D, 3, COM_INTEGER);
1178 COM_APPEND_ARRAY( com_append_array_flt3d, COM_APPEND_ARRAY_FLT3D, 3, COM_REAL);
1179 COM_APPEND_ARRAY( com_append_array_dbl3d, COM_APPEND_ARRAY_DBL3D, 3, COM_DOUBLE);
1180 
1181 #define COM_GET_BOUNDS( func, FUNC) \
1182 extern "C" void COM_F_FUNC2( func, FUNC) \
1183  ( const char *wa_str, const int &pane_id, \
1184  void *lbound, void *ubound, int len) \
1185 { \
1186  CHKLEN(len);\
1187  COM_get_roccom()->get_bounds( string(wa_str,len), pane_id, lbound, ubound); \
1188 }
1189 
1190 COM_GET_BOUNDS(com_get_bounds_int, COM_GET_BOUNDS_INT);
1191 COM_GET_BOUNDS(com_get_bounds_flt, COM_GET_BOUNDS_FLT);
1192 COM_GET_BOUNDS(com_get_bounds_dbl, COM_GET_BOUNDS_DBL);
1193 
1194 extern "C" int COM_F_FUNC2(com_check_bounds,COM_CHECK_BOUNDS)
1195  ( const char *wa_str, const int &pane_id, int len)
1196 {
1197  CHKLEN(len);
1198  return COM_get_roccom()->check_bounds( string(wa_str,len), pane_id);
1199 }
1200 
1201 extern "C" void COM_F_FUNC2(com_use_attr, COM_USE_ATTR)
1202  ( const char *wname, const char *attr, int w_len, int a_len)
1203 {
1204  CHKLEN(w_len); CHKLEN(a_len);
1205  COM_get_roccom()->
1206  use_attribute( string(wname, w_len), string(attr, a_len));
1207 }
1208 
1209 extern "C" void COM_F_FUNC2(com_clone_attr,COM_CLONE_ATTR)
1210  ( const char *wname, const char *attr, int w_len, int a_len)
1211 {
1212  CHKLEN(w_len); CHKLEN(a_len);
1213  COM_get_roccom()->
1214  clone_attribute( string(wname, w_len), string(attr, a_len));
1215 }
1216 
1217 extern "C" void COM_F_FUNC2(com_copy_attr,COM_COPY_ATTR)
1218  ( const char *wname, const char *attr, int w_len, int a_len)
1219 {
1220  CHKLEN(w_len); CHKLEN(a_len);
1221  COM_get_roccom()->
1222  copy_attribute( string(wname, w_len), string(attr, a_len));
1223 }
1224 
1225 extern "C" void COM_F_FUNC2(com_copy_attr_hdls,COM_COPY_ATTR_HDLS)
1226  ( const int &trg_hdl, const int &src_hdl)
1227 {
1228  COM_get_roccom()->copy_attribute( trg_hdl, src_hdl);
1229 }
1230 
1231 extern "C" void COM_F_FUNC2(com_use_attr_ghost, COM_USE_ATTR_GHOST)
1232  ( const char *wname, const char *attr, const int &with_ghost,
1233  int w_len, int a_len)
1234 {
1235  CHKLEN(w_len); CHKLEN(a_len);
1236  COM_get_roccom()->
1237  use_attribute( string(wname, w_len), string(attr, a_len), with_ghost);
1238 }
1239 
1240 extern "C" void COM_F_FUNC2(com_clone_attr_ghost, COM_CLONE_ATTR_GHOST)
1241  ( const char *wname, const char *attr, const int &with_ghost,
1242  int w_len, int a_len)
1243 {
1244  CHKLEN(w_len); CHKLEN(a_len);
1245  COM_get_roccom()->
1246  clone_attribute( string(wname, w_len), string(attr, a_len), with_ghost);
1247 }
1248 
1249 extern "C" void COM_F_FUNC2(com_copy_attr_ghost, COM_COPY_ATTR_GHOST)
1250  ( const char *wname, const char *attr, const int &with_ghost,
1251  int w_len, int a_len)
1252 {
1253  CHKLEN(w_len); CHKLEN(a_len);
1254  COM_get_roccom()->
1255  copy_attribute( string(wname, w_len), string(attr, a_len), with_ghost);
1256 }
1257 
1258 extern "C" void COM_F_FUNC2(com_copy_attr_ghost_hdls,COM_COPY_ATTR_GHOST_HDLS)
1259  ( const int &trg_hdl, const int &src_hdl, const int &with_ghost )
1260 {
1261  COM_get_roccom()->copy_attribute( trg_hdl, src_hdl, with_ghost);
1262 }
1263 
1264 extern "C" void COM_F_FUNC2(com_use_attr_sub, COM_USE_ATTR_SUB)
1265  ( const char *wname, const char *attr, const int &with_ghost,
1266  const char *ptnname, const int &val,
1267  int w_len, int a_len, int p_len)
1268 {
1269  CHKLEN(w_len); CHKLEN(a_len);
1270  COM_get_roccom()->
1271  use_attribute( string(wname, w_len), string(attr, a_len),
1272  with_ghost, string(ptnname, p_len).c_str(), val);
1273 }
1274 
1275 extern "C" void COM_F_FUNC2(com_clone_attr_sub, COM_CLONE_ATTR_sub)
1276  ( const char *wname, const char *attr, const int &with_ghost,
1277  const char *ptnname, const int &val,
1278  int w_len, int a_len, int p_len)
1279 {
1280  CHKLEN(w_len); CHKLEN(a_len);
1281  COM_get_roccom()->
1282  clone_attribute( string(wname, w_len), string(attr, a_len),
1283  with_ghost, string(ptnname, p_len).c_str(), val);
1284 }
1285 
1286 extern "C" void COM_F_FUNC2(com_copy_attr_sub, COM_COPY_ATTR_sub)
1287  ( const char *wname, const char *attr, const int &with_ghost,
1288  const char *ptnname, const int &val,
1289  int w_len, int a_len, int p_len)
1290 {
1291  CHKLEN(w_len); CHKLEN(a_len);
1292  COM_get_roccom()->
1293  copy_attribute( string(wname, w_len), string(attr, a_len),
1294  with_ghost, string(ptnname, p_len).c_str(), val);
1295 }
1296 
1297 extern "C" void COM_F_FUNC2(com_copy_attr_ghost_sub_hdls,
1298  COM_COPY_ATTR_GHOST_SUB_HDLS)
1299  ( const int &trg_hdl, const int &src_hdl, const int &with_ghost,
1300  const int &pnt_hdl, const int &val)
1301 {
1302  COM_get_roccom()->copy_attribute( trg_hdl, src_hdl, with_ghost,
1303  pnt_hdl, val);
1304 }
1305 
1306 extern "C" void COM_F_FUNC2(com_deallocate_win, COM_DEALLOCATE_WIN)
1307  ( const char *wa_str, int wa_len)
1308 {
1309  CHKLEN(wa_len);
1310  COM_get_roccom()->deallocate_array( string( wa_str, wa_len), 0);
1311 }
1312 
1313 extern "C" void COM_F_FUNC2(com_deallocate_pane, COM_DEALLOCATE_PANE)
1314  ( const char *wa_str, const int &pid, int wa_len)
1315 {
1316  CHKLEN(wa_len);
1317  COM_get_roccom()->deallocate_array(string(wa_str, wa_len), pid);
1318 }
1319 
1320 extern "C" void COM_F_FUNC2(com_get_size1, COM_GET_SIZE1)
1321  ( const char *wa_str, const int &pane_id, int *size, int len)
1322 { COM_get_roccom()->get_size( std::string(wa_str,len), pane_id, size); }
1323 
1324 extern "C" void COM_F_FUNC2(com_get_size2, COM_GET_SIZE2)
1325  ( const char *wa_str, const int &pane_id, int *size, int *ng, int len)
1326 { COM_get_roccom()->get_size( std::string(wa_str,len), pane_id, size, ng); }
1327 
1328 extern "C" void COM_F_FUNC2(com_get_attribute,COM_GET_ATTRIBUTE)
1329  ( const char *wa_str, char *loc, int *type, int *size,
1330  char *u_str, int wa_len, int l_len, int u_len)
1331 {
1332  CHKLEN(wa_len); CHKLEN(l_len); CHKLEN(u_len);
1333  std::string unit;
1334  COM_get_roccom()->get_attribute( string( wa_str,wa_len), loc, type,
1335  size, &unit);
1336 
1337  int len=unit.size(), n=std::min(len, int(u_len));
1338 
1339  int u_len_int = u_len;
1340  COM_F_FUNC2( com_copy_string, COM_COPY_STRING)
1341  ( unit.c_str(), &n, u_str, &u_len_int, n, u_len);
1342 }
1343 
1344 extern "C" void COM_F_FUNC2(com_set_function, COM_SET_FUNCTION)
1345  ( const char *wf_str, Func_ptr func, const char *intents,
1346  const COM_Type *types, int wf_len, int i_len)
1347 {
1348  CHKLEN(wf_len); CHKLEN(i_len);
1349  COM_get_roccom()->set_function( string(wf_str,wf_len), func,
1350  string(intents,i_len), types, true);
1351 }
1352 
1353 extern "C" void COM_F_FUNC2(com_set_member_function, COM_SET_MEMBER_FUNCTION)
1354  ( const char *wf_str, Func_ptr func, const char *wa_str, const char *intents,
1355  const COM_Type *types, int wf_len, int a_len, int i_len)
1356 {
1357  CHKLEN(wf_len); CHKLEN(a_len); CHKLEN(i_len);
1358  COM_get_roccom()->set_member_function( string(wf_str,wf_len), func,
1359  string(wa_str,a_len),
1360  string(intents,i_len),
1361  types, true);
1362 }
1363 
1364 extern "C" void COM_F_FUNC2(com_get_communicator,COM_GET_COMMUNICATOR)
1365  ( const char *wname, int *comm, int w_len)
1366 {
1367  CHKLEN(w_len);
1368  *comm = COMMPI_Comm_c2f(COM_get_roccom()->
1369  get_communicator( string(wname, w_len)));
1370 }
1371 
1372 extern "C" void COM_F_FUNC2(com_get_pane_ids_on_rank,COM_GET_PANE_IDS_ON_RANK)
1373  ( const char *wname, int *npanes, void *panes_ids, const int &rank,
1374  int l1, int l2)
1375 {
1376  int f90ptr_treat = get_f90ptr_treat();
1377  int w_len=(f90ptr_treat==Roccom_base::FPTR_INSERT)?l2:l1; CHKLEN(w_len);
1378 
1379  std::vector<int> vec;
1380  int *pids;
1381  COM_get_roccom()->get_panes( string(wname, w_len), vec, rank, &pids);
1382  *npanes = vec.size();
1383 
1384  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
1385  int tonull = *npanes == 0;
1386  typedef void(*Func)(void*,int*,void*,void*,int);
1387  (*(Func)COM_F_FUNC2(com_mapptr_int1d,COM_MAPPTR_INT1D))
1388  ( panes_ids, &tonull, pids, npanes, l1);
1389  }
1390  else {
1391  int tonull = *npanes == 0;
1392 
1393  if ( f90ptr_treat == Roccom_base::FPTR_APPEND) {
1394  typedef void(*Func)(void*,int*,void*,void*,int);
1395  (*(Func)COM_F_FUNC2(com_mapptr_int1d,COM_MAPPTR_INT1D))
1396  ( panes_ids, &tonull, pids, npanes, l2);
1397  }
1398  else {
1399  typedef void(*Func)(void*,int*,void*,void*);
1400  (*(Func)COM_F_FUNC2(com_mapptr_int1d,COM_MAPPTR_INT1D))
1401  ( panes_ids, &tonull, pids, npanes);
1402  }
1403  }
1404 }
1405 
1406 extern "C" void COM_F_FUNC2(com_get_pane_ids,COM_GET_PANE_IDS)
1407  ( const char *wname, int *npanes, void *panes_ids,
1408  int l1, int l2)
1409 {
1410  COM_F_FUNC2(com_get_pane_ids_on_rank,COM_GET_PANE_IDS_ON_RANK)
1411  ( wname, npanes, panes_ids, -2, l1, l2);
1412 }
1413 
1414 extern "C" void COM_F_FUNC2(com_get_npanes,COM_GET_NPANES)
1415  ( const char *wname, int *npanes, int w_len)
1416 {
1417  CHKLEN(w_len);
1418  std::vector<int> vec;
1419  COM_get_roccom()->get_panes( string(wname, w_len), vec);
1420  *npanes = vec.size();
1421 }
1422 
1423 static void mapcharptr( char *str, void *names, int f90ptr_treat,
1424  int l1, int l2) {
1425  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
1426  int len = std::strlen( str), tonull=(len==0);
1427  typedef void(*Func)(void*,int*,void*,void*, int);
1428  (*(Func)COM_F_FUNC2(com_mapptr_chr1d,COM_MAPPTR_CHR1D))
1429  ( names, &tonull, str, &len, l1);
1430  }
1431  else {
1432  int len = std::strlen( str), tonull=(len==0);
1433 
1434  if ( f90ptr_treat == Roccom_base::FPTR_APPEND) {
1435  typedef void(*Func)(void*,int*,void*,void*, int);
1436  (*(Func)COM_F_FUNC2(com_mapptr_chr1d,COM_MAPPTR_CHR1D))
1437  ( names, &tonull, str, &len, l2);
1438  }
1439  else {
1440  typedef void(*Func)(void*,int*,void*,void*);
1441  (*(Func)COM_F_FUNC2(com_mapptr_chr1d,COM_MAPPTR_CHR1D))
1442  ( names, &tonull, str, &len);
1443  }
1444  }
1445 }
1446 
1447 extern "C" void COM_F_FUNC2(com_get_attributes,COM_GET_ATTRIBUTES)
1448  ( const char *wname, int *na, void *names,
1449  int l1, int l2)
1450 {
1451  int f90ptr_treat = get_f90ptr_treat();
1452  int w_len=(f90ptr_treat==Roccom_base::FPTR_INSERT)?l2:l1; CHKLEN(w_len);
1453 
1454  std::string str;
1455  char *atts;
1456  COM_get_roccom()->get_attributes( string(wname, w_len), na, str, &atts);
1457 
1458  mapcharptr( atts, names, f90ptr_treat, l1, l2);
1459 }
1460 
1461 extern "C" void COM_F_FUNC2(com_get_connectivities,COM_GET_CONNECTIVITIES)
1462  ( const char *wname, const int &pane_id, int *nc, void *names,
1463  int l1, int l2)
1464 {
1465  int f90ptr_treat = get_f90ptr_treat();
1466 
1467  int w_len=(f90ptr_treat==Roccom_base::FPTR_INSERT)?l2:l1; CHKLEN(w_len);
1468 
1469  std::string str;
1470  char *conns;
1471  COM_get_roccom()->get_connectivities( string(wname, w_len), pane_id,
1472  nc, str, &conns);
1473 
1474  mapcharptr( conns, names, f90ptr_treat, l1, l2);
1475 }
1476 
1477 extern "C" void COM_F_FUNC2( com_get_parent, COM_GET_PARENT)
1478  ( const char *waname, const int &pane_id, void *parent,
1479  int l1, int l2)
1480 {
1481  int f90ptr_treat = get_f90ptr_treat();
1482  int w_len=(f90ptr_treat==Roccom_base::FPTR_INSERT)?l2:l1; CHKLEN(w_len);
1483 
1484  std::string str;
1485  char *name;
1486  COM_get_roccom()->get_parent( string(waname, w_len), pane_id, str, &name);
1487 
1488  mapcharptr( name, parent, f90ptr_treat, l1, l2);
1489 }
1490 
1491 extern "C" int COM_F_FUNC2( com_get_status, COM_GET_STATUS)
1492  ( const char *waname, const int &pane_id, int len)
1493 {
1494  CHKLEN(len);
1495  return COM_get_roccom()->get_status( std::string(waname,len), pane_id);
1496 }
1497 
1498 extern "C" void COM_F_FUNC2(com_free_buffer_char,COM_FREE_BUFFER_CHAR)
1499  ( void *buf, int l2)
1500 {
1501  char *ptr=NULL;
1502  typedef void(*Func)(void*,void**);
1503  (*(Func)COM_F_FUNC2(com_getptr_chr1d,COM_GETPTR_CHR1D))
1504  ( buf, &(void*&)ptr);
1505 
1506  COM_get_roccom()->free_buffer( &ptr);
1507 
1508  { // Nullify pointer
1509  int one=1, zero = 0;
1510  typedef void(*Func)(void*,int*,void*,void*);
1511 
1512  (*(Func)COM_F_FUNC2(com_mapptr_chr1d,COM_GETPTR_CHR1D))
1513  ( buf, &one, ptr, &zero);
1514  }
1515 }
1516 
1517 extern "C" void COM_F_FUNC2(com_free_buffer_int,COM_FREE_BUFFER_INT)
1518  ( void *buf, int l2)
1519 {
1520  int *ptr=NULL;
1521  typedef void(*Func)(void*,void**);
1522  (*(Func)COM_F_FUNC2(com_getptr_int1d,COM_GETPTR_INT1D))
1523  ( buf, &(void*&)ptr);
1524 
1525  COM_get_roccom()->free_buffer( &ptr);
1526 
1527  { // Nullify pointer
1528  int one=1, zero = 0;
1529  typedef void(*Func)(void*,int*,void*,void*);
1530 
1531  (*(Func)COM_F_FUNC2(com_mapptr_int1d,COM_GETPTR_INT1D))
1532  ( buf, &one, ptr, &zero);
1533  }
1534 }
1535 
1536 extern "C" int COM_F_FUNC2( com_get_window_handle, COM_GET_WINDOW_HANDLE)
1537  ( const char *wname, int len)
1538 {
1539  CHKLEN(len);
1540  return COM_get_roccom()->get_window_handle( std::string(wname,len));
1541 }
1542 
1543 extern "C" int COM_F_FUNC2(com_get_attribute_handle, COM_GET_ATTRIBUTE_HANDLE)
1544  ( const char *waname, int len)
1545 {
1546  CHKLEN(len);
1547  return COM_get_roccom()->get_attribute_handle( std::string(waname,len));
1548 }
1549 
1550 extern "C" int COM_F_FUNC2( com_get_attribute_handle_const, COM_GET_ATTRIBUTE_HANDLE_CONST)
1551  ( const char *waname, int len) {
1552 
1553  CHKLEN(len);
1554  return COM_get_roccom()->get_attribute_handle_const( std::string(waname,len));
1555 }
1556 
1557 extern "C" int COM_F_FUNC2( com_get_function_handle, COM_GET_FUNCTION_HANDLE)
1558  ( const char *wfname, int len)
1559 {
1560  CHKLEN(len);
1561  return COM_get_roccom()->get_function_handle( std::string(wfname,len));
1562 }
1563 
1564 extern "C" void COM_F_FUNC2(com_call_function, COM_CALL_FUNCTION)
1565  ( const int &wf, const int &argc, void *a1, void *a2, void *a3, void *a4,
1566  void *a5, void *a6, void *a7, void *a8, void *a9,
1567  void *aa, void *ab, void *ac, void *ad, void *ae) {
1568  void *args[] = {a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae};
1569  int lens[ Function::MAX_NUMARG];
1570  for ( int i=0; i<argc; ++i)
1571  lens[i] = (unsigned int)((char *)(args[argc+i])-(char *)(0));
1572  COM_get_roccom()->call_function(wf, argc, args, lens, false);
1573 }
1574 
1575 extern "C" void COM_F_FUNC2( com_icall_function, COM_ICALL_FUNCTION)
1576  ( const int &wf, const int &argc, void *a1, void *a2, void *a3, void *a4,
1577  void *a5, void *a6, void *a7, void *a8, void *a9,
1578  void *aa, void *ab, void *ac, void *ad, void *ae, void *af) {
1579  void *args[] = {a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae};
1580 
1581  int lens[Function::MAX_NUMARG];
1582  for ( int i=0; i<argc-1; ++i)
1583  lens[i] = (unsigned int)((char *)(args[argc+i])-(char *)(0));
1584 
1585  COM_get_roccom()->icall_function(wf, argc, args, lens, false);
1586 }
1587 
1588 extern "C" void COM_F_FUNC2(com_test, COM_TEST)
1589  ( const int &reqid, int *status)
1590 {
1591 
1592  *status = COM_get_roccom()->test( reqid);
1593  if ( *status == true)
1594  COM_F_FUNC2(com_set_true, COM_SET_TRUE)( status);
1595  else {
1596  COM_F_FUNC2(com_set_false, COM_SET_FALSE)( status);
1597  COM_assertion( *status == 0);
1598  }
1599 }
1600 
1601 extern "C" void COM_F_FUNC2(com_wait, COM_WAIT)
1602  ( const int &reqid)
1603 { COM_get_roccom()->wait( reqid); }
1604 
1605 extern "C" void COM_F_FUNC2( com_set_pointer, COM_SET_POINTER)
1606  ( const char *waname, void *ptr, Func_ptr func,
1607  int l1, int l2) {
1608 
1609  if ( get_f90ptr_treat() == Roccom_base::FPTR_INSERT) {
1610  // Note: For Portland Group F90 compiler, l1 is the end-address of
1611  // the pointer and l2 is the length of the character string.
1612  int len=l2; CHKLEN( len);
1613  COM_get_roccom()->set_f90pointer( std::string(waname,len), ptr, func, l1);
1614  }
1615  else {
1616  int len=l1; CHKLEN( len);
1617  COM_get_roccom()->set_f90pointer( std::string(waname,len), ptr, func, l2);
1618  }
1619 }
1620 
1621 extern "C" void COM_F_FUNC2(com_get_pointer, COM_GET_POINTER)
1622  ( const char *waname, void *ptr, Func_ptr func,
1623  int l1, int l2) {
1624 
1625  int f90ptr_treat = get_f90ptr_treat();
1626 
1627  if ( f90ptr_treat == Roccom_base::FPTR_INSERT) {
1628  // Note: For Portland Group F90 compiler, l1 is the end-address of
1629  // the pointer and l2 is the length of the character string.
1630  int len=l2; CHKLEN( len);
1631  COM_get_roccom()->get_f90pointer( std::string(waname,len), ptr, func, l1);
1632  }
1633  else {
1634  int len=l1; CHKLEN( len);
1635  COM_get_roccom()->get_f90pointer( std::string(waname,len), ptr, func, l2);
1636  }
1637 }
1638 
1639 extern "C" void COM_F_FUNC2( com_set_object, COM_SET_OBJECT)
1640  ( const char *waname, void *ptr, Func_ptr func,
1641  int l1, int l2) {
1642 
1643  COM_F_FUNC2( com_set_pointer, COM_SET_POINTER)( waname, ptr, func, l1, l2);
1644 }
1645 
1646 extern "C" void COM_F_FUNC2(com_get_object, COM_GET_OBJECT)
1647  ( const char *waname, void *ptr, Func_ptr func,
1648  int l1, int l2) {
1649 
1650  COM_F_FUNC2( com_get_pointer, COM_GET_POINTER)( waname, ptr, func, l1, l2);
1651 }
1652 
1653 
1654 //================================================================
1655 //============== Functions for tracing and profiling =============
1656 //================================================================
1657 
1658 extern "C" void COM_F_FUNC2(com_set_verbose,COM_SET_VERBOSE)( const int &i)
1659 { COM_get_roccom()->set_verbose( i); }
1660 
1661 extern "C" void COM_F_FUNC2(com_set_debug,COM_SET_DEBUG)( const bool &debug)
1662 { COM_get_roccom()->set_debug( debug); }
1663 
1664 extern "C" void COM_F_FUNC2( com_set_profiling_barrier, COM_SET_PROFILING_BARRIER)
1665  ( const int &hdl, const int &comm)
1666 {
1667  COM_get_roccom()->set_profiling_barrier
1668  ( hdl, COMMPI_Comm_f2c(comm, MPI_Comm()));
1669 }
1670 
1671 extern "C" void COM_F_FUNC2(com_set_profiling, COM_SET_PROFILING) ( const int &i)
1672 {
1673  COM_get_roccom()->set_profiling( i);
1674 }
1675 
1676 extern "C" void COM_F_FUNC2( com_print_profile, COM_PRINT_PROFILE)
1677  ( const char *fname, const char *header,
1678  int len, int hlen)
1679 {
1680  CHKLEN(len); CHKLEN(hlen);
1681  COM_get_roccom()->print_profile( std::string(fname,len),
1682  std::string(header,hlen));
1683 }
1684 
1685 extern "C" int COM_F_FUNC2(com_get_sizeof, COM_GET_SIZEOF)
1686  ( const COM_Type *type, int *c)
1687 { return COM_get_roccom()->get_sizeof( *type, *c); }
1688 
1689 extern "C" int COM_F_FUNC2(com_get_error_code, COM_GET_ERROR_CODE)()
1690 { return COM_get_roccom()->get_error_code(); }
1691 
1692 COM_BEGIN_NAME_SPACE
1693 
1695 typedef struct {
1696  int a[512];
1697 } Big_array;
1698 
1699 extern "C" void COM_F_FUNC2( com_settypeinfo, COM_SETTYPEINFO)(Big_array *);
1700 
1701 int get_sizeof_f90pointer() {
1702  Big_array w;
1703 
1704  COM_F_FUNC2( com_settypeinfo, COM_SETTYPEINFO)(&w);
1705 
1706  if (w.a[0] != 333331) {
1707  return -1;
1708  }
1709  else {
1710  for (int i = 0; i < 512; i++) {
1711  if (w.a[i] == 333332) {
1712  return (i-1)*sizeof(int);
1713  }
1714  }
1715  }
1716  return -1;
1717 }
1718 
1719 COM_END_NAME_SPACE
1720 
1721 extern "C" int COM_F_FUNC2( com_get_sizeof_f90pointer, COM_GET_SIZEOF_F90POINTER) ()
1722 { return get_sizeof_f90pointer(); }
1723 
1724 extern "C" void COM_F_FUNC2( com_chkptr_begin, COM_CHKPTR_BEGIN)();
1725 
1726 extern "C" void COM_F_FUNC2( com_chkptr_end, COM_CHKPTR_END)
1727  ( const char *str1, void *ptr1, const char *str2, void *ptr2,
1728  int len1, int len2, int len3, int len4);
1729 
1730 extern "C" int COM_F_FUNC2( com_chkptr_c, COM_CHKPTR_C)
1731  ( const int &stage, const char *str1, void *ptr1,
1732  const char *str2, void *ptr2,
1733  int len1, int len2, int len3, int len4) {
1734 
1735  static int insert_or_append;
1736  static int ptrinfo1, ptrinfo2;
1737 
1738  switch ( stage) {
1739  case 0: // Being called from COM_init
1740  insert_or_append = Roccom_base::FPTR_NONE;
1741  ptrinfo1 = ptrinfo2 = 0;
1742 
1743  COM_F_FUNC2( com_chkptr_begin, COM_CHKPTR_BEGIN)();
1744  break;
1745  case 1:
1746  if ( (int)len3 == 17 && (int)len4 == 33)
1747  insert_or_append = Roccom_base::FPTR_INSERT;
1748  else
1749  COM_assertion_msg( len1 == 17 && len2 == 33,
1750  "Incorrect handling of Fortran 90 pointers");
1751 
1752  if ( insert_or_append == Roccom_base::FPTR_INSERT) {
1753  ptrinfo1 = len1 - ((char*)ptr1-(char*)NULL);
1754  ptrinfo2 = len2 - ((char*)ptr2-(char*)NULL);
1755  }
1756  else {
1757  ptrinfo1 = len3 - ((char*)ptr1-(char*)NULL);
1758  ptrinfo2 = len4 - ((char*)ptr2-(char*)NULL);
1759  }
1760 
1761  COM_F_FUNC2( com_chkptr_end, COM_CHKPTR_END)
1762  ( str1, ptr1, str2, ptr2, len1, len2, len3, len4);
1763  break;
1764  case 2: { // This stage, the arguments are switched
1765  int verb = COM_get_roccom()->get_verbose();
1766  bool debug = COM_get_roccom()->get_debug();
1767  if ( insert_or_append == Roccom_base::FPTR_INSERT) {
1768  COM_assertion_msg( ptrinfo1 == len2-((char*)ptr2-(char*)NULL) &&
1769  ptrinfo2 == len1-((char*)ptr1-(char*)NULL),
1770  "Incorrect handling of Fortran 90 pointers");
1771  if (debug)
1772  std::cerr << "Roccom: Setting f90 pointer treatment to INSERT" << std::endl;
1773  }
1774  else {
1775  if ( ptrinfo1 != 0 && ptrinfo1 == len4-((char*)ptr2-(char*)NULL) &&
1776  ptrinfo2 != 0 && ptrinfo2 == len3-((char*)ptr1-(char*)NULL)) {
1777  if (debug)
1778  std::cerr << "Roccom: Setting f90 pointer treatment to APPEND. \n";
1779  insert_or_append = Roccom_base::FPTR_APPEND;
1780  }
1781  else if (debug)
1782  std::cerr << "Roccom: Setting f90 pointer treatment to NONE.\n";
1783 
1784  if ( verb && (verb|1)==0)
1785  std::cerr << "\tAt pass 1, " << "ptrinfo1 is " << ptrinfo1
1786  << " and ptrinfo2 is " << ptrinfo2
1787  << " and\n\tat pass 2, ptrinfo1 is "
1788  << len3-((char*)ptr1-(char*)NULL)
1789  << " and ptrinfo2 is "
1790  << len4-((char*)ptr2-(char*)NULL) << std::endl;
1791 
1792  break;
1793  }
1794  }
1795  default: ;
1796  }
1797  return insert_or_append;
1798 }
1799 
1800 #endif
1801 
1802 
1803 
1804 
1805 
1806 
1807 
void const int char const int long int long int len2
Definition: mapptr.h:80
#define COM_OBTAIN_ARRAY_STRD(func, FUNC, dim, type, mode)
Definition: roccom_f.C:906
static void abort(int ierr)
Definition: Roccom_base.C:205
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
#define COM_SET_ARRAY_CONST_STRD_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:631
void com_obtain_array_f(const char *waname, int pane_id, void *addr, int &strd, int &cap, int offset, int l1, int l2)
Definition: roccom_f.C:758
#define COM_SET_ARRAY_CONST_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:586
#define COM_SET_ARRAY_STRD_SCALAR(func, FUNC)
Definition: roccom_f.C:454
subroutine com_getptr_int0d(p, x)
Definition: utilities.f90:307
#define COM_assertion_msg(EX, msg)
subroutine com_getptr_dbl2d(p, x)
Definition: utilities.f90:453
#define COM_SET_ARRAY_SCALAR(func, FUNC)
Definition: roccom_f.C:396
subroutine com_settypeinfo(wrapper)
Definition: utilities.f90:481
subroutine com_getptr_flt3d(p, x)
Definition: utilities.f90:411
This file contains the prototypes for Roccom API.
T COMMPI_Comm_f2c(int c, T)
Definition: commpi.h:202
void com_obtain_array_helper(const std::string &waname, int pane_id, void *addr, int &strd, int &cap, int offset, int l=0)
Definition: roccom_f.C:726
subroutine com_getptr_int1d(p, x)
Definition: utilities.f90:327
static void init(int *argc, char ***argv)
Definition: Roccom_base.C:186
subroutine com_getptr_chr1d(p, x)
Definition: utilities.f90:293
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
#define COM_COPY_ARRAY_OFF(func, FUNC, dim, type)
Definition: roccom_f.C:1079
#define COM_SET_ARRAY_CONST_DYN_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:675
subroutine com_mapptr_flt2d(p, tonull, x, n1, n2)
Definition: utilities.f90:165
subroutine com_mapptr_int0d(p, tonull, x)
Definition: utilities.f90:58
#define COM_F_FUNC2(lowcase, uppercase)
Definition: roccom_basic.h:87
int a[512]
Some arbitrary big array.
Definition: roccom_f.C:1696
subroutine com_getptr_dbl1d(p, x)
Definition: utilities.f90:439
#define COM_APPEND_ARRAY(func, FUNC, dim, type)
Definition: roccom_f.C:1162
subroutine com_getptr_dbl0d(p, x)
Definition: utilities.f90:425
static void finalize()
Definition: Roccom_base.C:197
subroutine com_getptr_int3d(p, x)
Definition: utilities.f90:355
subroutine com_set_false(i)
Definition: utilities.f90:28
subroutine com_copy_string(str_frm, len_frm, str_to, len_to)
Definition: utilities.f90:33
int _f90ptr_treat
Treatement of F90 pointers.
Definition: Roccom_base.h:493
subroutine com_mapptr_flt0d(p, tonull, x)
Definition: utilities.f90:126
#define COM_SET_ARRAY_CONST_DYN_SCALAR(func, FUNC)
Definition: roccom_f.C:658
subroutine com_mapptr_int2d(p, tonull, x, n1, n2)
Definition: utilities.f90:91
subroutine com_getptr_flt1d(p, x)
Definition: utilities.f90:383
void com_set_array_const_helper(const std::string &waname, int pane_id, void *addr, int strd, int cap, int l=0)
Definition: roccom_f.C:538
#define COM_SET_ARRAY_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:436
void com_append_array_f(const char *waname, int pane_id, const void *val, int v_strd, int v_size, int l1, int l2)
Definition: roccom_f.C:1141
subroutine com_mapptr_chr1d(p, tonull, x, n)
Definition: utilities.f90:42
void(* Func_ptr)()
Pointer of functions.
Definition: roccom_basic.h:123
static bool initialized()
Checks whether Roccom has been initialized.
Definition: Roccom_base.h:82
void const int char const int long int len1
Definition: mapptr.h:80
void com_set_array_helper(const std::string &waname, int pane_id, void *addr, int strd, int cap, int l=0)
Definition: roccom_f.C:387
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
#define COM_SET_ARRAY_CONST_SCALAR(func, FUNC)
Definition: roccom_f.C:548
void com_set_address_f(Roccom_base::Pointer_descriptor &ptr, void *addr, int l=0)
Definition: roccom_f.C:317
#define CHKLEN(x)
Definition: roccom_f.C:112
#define COM_OBTAIN_ARRAY(func, FUNC, dim, type, mode)
Definition: roccom_f.C:787
This file contains a set of routines for error assertion.
const NT & n
subroutine com_mapptr_dbl0d(p, tonull, x)
Definition: utilities.f90:200
int COMMPI_Comm_c2f(T t)
Definition: commpi.h:190
subroutine com_set_true(i)
Definition: utilities.f90:23
#define COM_APPEND_ARRAY_SCALAR(func, FUNC)
Definition: roccom_f.C:1113
#define COM_SET_ARRAY_DYN_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:509
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
subroutine com_getptr_flt2d(p, x)
Definition: utilities.f90:397
void com_append_array_helper(const std::string &waname, int pane_id, const void *val, int v_strd, int v_size, int l=0)
Definition: roccom_f.C:1130
subroutine com_getptr_int2d(p, x)
Definition: utilities.f90:341
subroutine com_getptr_dbl3d(p, x)
Definition: utilities.f90:467
#define COM_SET_ARRAY_CONST_STRD_SCALAR(func, FUNC)
Definition: roccom_f.C:613
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine com_mapptr_flt1d(p, tonull, x, n)
Definition: utilities.f90:148
#define COM_SET_ARRAY_STRD_PTR(func, FUNC, dim, type)
Definition: roccom_f.C:469
static MPI_Comm get_default_communicator()
Get the default communicator of Roccom.
Definition: Roccom_base.h:75
This file indirectly includes the following files: iostream, map, string, vector, and roccom_basic...
Definition: Roccom_base.h:49
#define COM_SET_BOUNDS(func, FUNC)
Definition: roccom_f.C:702
void com_set_array_f(const char *waname, int pane_id, void *addr, int strd, int cap, int l1, int l2)
Definition: roccom_f.C:412
subroutine com_chkptr_end(str1, ptr1, str2, ptr2)
Definition: utilities.f90:530
subroutine com_mapptr_int1d(p, tonull, x, n)
Definition: utilities.f90:74
#define COM_OBTAIN_ARRAY_DYN(func, FUNC, dim, type, mode)
Definition: roccom_f.C:993
subroutine com_mapptr_dbl2d(p, tonull, x, n1, n2)
Definition: utilities.f90:239
Access_mode
Definition: roccom_f.C:715
Some big array to help determining the size of a Fortran 90 pointer.
Definition: roccom_f.C:1695
void * com_get_address_f(void *addr, int l=0)
Definition: roccom_f.C:256
static int rank
Definition: advectest.C:66
subroutine com_getptr_flt0d(p, x)
Definition: utilities.f90:369
static void set_default_communicator(MPI_Comm comm)
Set the default communicator of Roccom.
Definition: Roccom_base.h:71
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
subroutine com_mapptr_dbl1d(p, tonull, x, n)
Definition: utilities.f90:222
#define COM_GET_BOUNDS(func, FUNC)
Definition: roccom_f.C:1181
void com_set_array_const_f(const char *waname, int pane_id, void *addr, int strd, int cap, int l1, int l2)
Definition: roccom_f.C:564
subroutine com_chkptr_begin
Definition: utilities.f90:508
This file contains the prototypes of the Fortran 90 subroutines for mapping C routines into Fortran p...
#define COM_SET_ARRAY_DYN_SCALAR(func, FUNC)
Definition: roccom_f.C:496
static void mapcharptr(char *str, void *names, int f90ptr_treat, int l1, int l2)
Definition: roccom_f.C:1423