Actual source code: ex1.c

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

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

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



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

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

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