Date: 2023-11-27T17:19:53+00:00

Actual source code: zslepc_start.c
slepc-3.20.1 2023-11-27
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: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     23: #define petscinitializef_             petscinitializef
     24: #define petscfinalize_                petscfinalize
     25: #define slepcinitializef_             slepcinitializef
     26: #define slepcfinalize_                slepcfinalize
     27: #endif

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

     32: /*
     33:     SlepcInitialize - Version called from Fortran.

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

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

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

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

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

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

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

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