Date: 2025-03-28T21:10:49+00:00

Actual source code: zswarmf90.c

      1: #include <petsc/private/fortranimpl.h>
      2: #include <petscdmswarm.h>
      3: #include <petsc/private/f90impl.h>

      5: #if defined(PETSC_HAVE_FORTRAN_CAPS)
      6:   #define dmswarmgetfield_     DMSWARMGETFIELD
      7:   #define dmswarmrestorefield_ DMSWARMRESTOREFIELD
      8: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE)
      9:   #define dmswarmgetfield_     dmswarmgetfield
     10:   #define dmswarmrestorefield_ dmswarmerstorefield
     11: #endif

     13: /* Definitions of Fortran Wrapper routines */

     15: PETSC_EXTERN void dmswarmgetfield_(DM *dm, char *name, PetscInt *blocksize, PetscDataType *type, F90Array1d *ptr, int *ierr PETSC_F90_2PTR_PROTO(ptrd), PETSC_FORTRAN_CHARLEN_T lenN)
     16: {
     17:   PetscScalar *v;
     18:   PetscInt     n;
     19:   char        *fieldname;

     21:   FIXCHAR(name, lenN, fieldname);
     22:   *ierr = DMSwarmGetSize(*dm, &n);
     23:   if (*ierr) return;
     24:   *ierr = DMSwarmGetField(*dm, fieldname, blocksize, type, (void **)&v);
     25:   if (*ierr) return;
     26:   *ierr = F90Array1dCreate((void *)v, MPIU_SCALAR, 1, n, ptr PETSC_F90_2PTR_PARAM(ptrd));
     27:   FREECHAR(name, fieldname);
     28: }

     30: PETSC_EXTERN void dmswarmrestorefield_(DM *dm, char *name, PetscInt *blocksize, PetscDataType *type, F90Array1d *ptr, int *ierr PETSC_F90_2PTR_PROTO(ptrd), PETSC_FORTRAN_CHARLEN_T lenN)
     31: {
     32:   PetscScalar *v;
     33:   char        *fieldname;

     35:   FIXCHAR(name, lenN, fieldname);
     36:   *ierr = F90Array1dAccess(ptr, MPIU_SCALAR, (void **)&v PETSC_F90_2PTR_PARAM(ptrd));
     37:   if (*ierr) return;
     38:   *ierr = DMSwarmRestoreField(*dm, fieldname, blocksize, type, (void **)&v);
     39:   if (*ierr) return;
     40:   *ierr = F90Array1dDestroy(ptr, MPIU_SCALAR PETSC_F90_2PTR_PARAM(ptrd));
     41:   FREECHAR(name, fieldname);
     42: }