Actual source code: ex1.c

  2: #include <stdio.h>
  3: #include "../src/sys/f90/f90impl.h"

  5: #if defined(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: #if defined(PETSC_HAVE_FORTRAN_UNDERSCORE_UNDERSCORE)
 14: #define fortran_routine_ fortran_routine__
 15: #define c_routine_ c_routine__
 16: #endif

 18: typedef struct {
 19:   int a;
 20:   F90Array1d ptr;
 21:   int c;
 22: } abc;



 28: void PETSC_STDCALL c_routine_(abc *x)
 29: {
 30:   double     *data;

 32:   F90Array1dAccess(&(x->ptr),PETSC_SCALAR,(void **)&data);
 33:   printf("From C: %d %5.2e %d\n",x->a,data[0],x->c);
 34:   fflush(stdout);
 35:   x->a = 2;

 37:   data[0] = 22.0;
 38:   x->c = 222;
 39:   fortran_routine_(x);
 40: }