Actual source code: ex1.c

  1: /*$Id: ex1.c,v 1.6 2000/09/22 18:54:00 balay Exp $*/

  3: #include <stdio.h>
  4: #include "petscf90.h"

  6: #ifdef PETSC_HAVE_FORTRAN_CAPS
  7: #define fortran_routine_ FORTRAN_ROUTINE
  8: #define c_routine_ C_ROUTINE
  9: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE)
 10: #define fortran_routine_ fortran_routine
 11: #define c_routine_ c_routine
 12: #endif

 14: typedef struct {
 15:   int a;
 16:   F90Array1d ptr;
 17:   int c;
 18: } abc;


 21: EXTERN_C_BEGIN

 23: extern void fortran_routine_(abc *);
 24: void c_routine_(abc *x)
 25: {
 26:   double     *data;

 28:   F90Array1dAccess(&(x->ptr),(void **)&data);
 29:   printf("From C: %d %5.2e %d\n",x->a,data[0],x->c);
 30:   fflush(stdout);
 31:   x->a = 2;

 33:   data[0] = 22.0;
 34:   x->c = 222;
 35:   fortran_routine_(x);
 36: }

 38: EXTERN_C_END