Date: 2025-03-29T05:58:54+00:00

Actual source code: zvectorf.c

      1: #include <petsc/private/ftnimpl.h>
      2: #include <petscvec.h>
      3: #include <petscviewer.h>

      5: #if defined(PETSC_HAVE_FORTRAN_CAPS)
      6:   #define vecsetvalue_               VECSETVALUE
      7:   #define vecsetvaluelocal_          VECSETVALUELOCAL
      8:   #define vecgetownershipranges_     VECGETOWNERSHIPRANGES
      9:   #define vecrestoreownershipranges_ VECRESTOREOWNERSHIPRANGES
     10: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     11:   #define vecsetvalue_               vecsetvalue
     12:   #define vecsetvaluelocal_          vecsetvaluelocal
     13:   #define vecgetownershipranges_     vecgetownershipranges
     14:   #define vecrestoreownershipranges_ vecrestoreownershipranges
     15: #endif

     17: PETSC_EXTERN void vecsetvalue_(Vec *v, PetscInt *i, PetscScalar *va, InsertMode *mode, PetscErrorCode *ierr)
     18: {
     19:   /* cannot use VecSetValue() here since that uses PetscCall() which has a return in it */
     20:   *ierr = VecSetValues(*v, 1, i, va, *mode);
     21: }

     23: PETSC_EXTERN void vecsetvaluelocal_(Vec *v, PetscInt *i, PetscScalar *va, InsertMode *mode, PetscErrorCode *ierr)
     24: {
     25:   /* cannot use VecSetValue() here since that uses PetscCall() which has a return in it */
     26:   *ierr = VecSetValuesLocal(*v, 1, i, va, *mode);
     27: }

     29: PETSC_EXTERN void vecgetownershipranges_(Vec *v, F90Array1d *ptr, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd))
     30: {
     31:   PetscInt   *fa;
     32:   PetscMPIInt size;

     34:   *ierr = VecGetOwnershipRanges(*v, (const PetscInt **)&fa);
     35:   if (*ierr) return;
     36:   MPI_Comm_size(PetscObjectComm((PetscObject)*v), &size);
     37:   *ierr = F90Array1dCreate(fa, MPIU_INT, 1, size + 1, ptr PETSC_F90_2PTR_PARAM(ptrd));
     38: }

     40: PETSC_EXTERN void vecrestoreownershipranges_(Vec *v, F90Array1d *ptr, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd))
     41: {
     42:   *ierr = F90Array1dDestroy(ptr, MPIU_INT PETSC_F90_2PTR_PARAM(ptrd));
     43: }