Date: 2024-10-28T09:14:59+00:00

Actual source code: zstart.c
slepc-3.22.1 2024-10-28
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */
     10: /*
     11:    This file contains the Fortran version of SlepcInitialize()
     12: */

     14: #include <slepc/private/slepcimpl.h>
     15: #include <petsc/private/fortranimpl.h>

     17: #if defined(PETSC_HAVE_FORTRAN_CAPS)
     18: #define petscinitializef_             PETSCINITIALIZEF
     19: #define petscfinalize_                PETSCFINALIZE
     20: #define slepcinitializef_             SLEPCINITIALIZEF
     21: #define slepcfinalize_                SLEPCFINALIZE
     22: #define slepcinitializefortran_       SLEPCINITIALIZEFORTRAN
     23: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     24: #define petscinitializef_             petscinitializef
     25: #define petscfinalize_                petscfinalize
     26: #define slepcinitializef_             slepcinitializef
     27: #define slepcfinalize_                slepcfinalize
     28: #define slepcinitializefortran_       slepcinitializefortran
     29: #endif

     31: SLEPC_EXTERN void petscinitializef_(char *filename,char* help,PetscBool *readarguments,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len,PETSC_FORTRAN_CHARLEN_T helplen);
     32: SLEPC_EXTERN void petscfinalize_(PetscErrorCode *ierr);

     34: /*
     35:     SlepcInitialize - Version called from Fortran.

     37:     Notes:
     38:     Since this routine is called from Fortran it does not return error codes.
     39: */
     40: SLEPC_EXTERN void slepcinitializef_(char *filename,char* help,PetscBool *readarguments,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len,PETSC_FORTRAN_CHARLEN_T helplen)
     41: {
     42:   PetscBool flg;

     44:   if (SlepcInitializeCalled) { *ierr = PETSC_SUCCESS; return; }

     46:   *ierr = PetscInitialized(&flg);
     47:   if (*ierr) { (void)(*PetscErrorPrintf)("SlepcInitialize:PetscInitialized failed");return; }
     48:   if (!flg) {
     49:     petscinitializef_(filename,help,readarguments,ierr,len,helplen);
     50:     if (*ierr) { (void)(*PetscErrorPrintf)("SlepcInitialize:PetscInitialize failed");return; }
     51:     SlepcBeganPetsc = PETSC_TRUE;
     52:   }

     54:   *ierr = SlepcCitationsInitialize();
     55:   if (*ierr) { (void)(*PetscErrorPrintf)("SlepcInitialize:SlepcCitationsInitialize()\n");return; }

     57:   *ierr = SlepcInitialize_DynamicLibraries();
     58:   if (*ierr) { (void)(*PetscErrorPrintf)("SlepcInitialize:Initializing dynamic libraries\n");return; }

     60:   SlepcInitializeCalled = PETSC_TRUE;
     61:   SlepcFinalizeCalled   = PETSC_FALSE;
     62:   *ierr = PetscInfo(0,"SLEPc successfully started from Fortran\n");
     63:   if (*ierr) { (void)(*PetscErrorPrintf)("SlepcInitialize:Calling PetscInfo()");return; }
     64: }

     66: SLEPC_EXTERN void slepcfinalize_(PetscErrorCode *ierr)
     67: {
     68:   if (PetscUnlikely(!SlepcInitializeCalled)) {
     69:     (void)(*PetscErrorPrintf)("SlepcInitialize() must be called before SlepcFinalize()");
     70:     return;
     71:   }

     73:   *ierr = PetscInfo(0,"SlepcFinalize() called from Fortran\n");
     74:   if (*ierr) { (void)(*PetscErrorPrintf)("SlepcFinalize:Calling PetscInfo()");return; }
     75:   *ierr = PETSC_SUCCESS;
     76:   if (SlepcBeganPetsc) {
     77:     petscfinalize_(ierr);
     78:     if (*ierr) { (void)(*PetscErrorPrintf)("SlepcFinalize:Calling petscfinalize_()");return; }
     79:     SlepcBeganPetsc = PETSC_FALSE;
     80:   }
     81:   SlepcInitializeCalled = PETSC_FALSE;
     82:   SlepcFinalizeCalled   = PETSC_TRUE;
     83: }

     85: SLEPC_EXTERN void slepcinitializefortran_(PetscErrorCode *info)
     86: {
     87:   *info = SlepcInitializeFortran();
     88: }