Actual source code: ztao_start.c

      1: /*$Id: ztao_start.c 1.20 05/05/10 15:21:37-05:00 sarich@zorak.(none) $*/

      3: /*
      4:   This file contains the Fortran version of TaoInitialize().
      5: */

      7: /*
      8:     This is to prevent the Cray T3D version of MPI (University of Edinburgh)
      9:   from redefining MPI_INIT(). They put this in to detect errors in C code,
     10:   but here we do want to be calling the Fortran version from a C subroutine.
     11: */
     12: #define T3DMPI_FORTRAN
     13: #define T3EMPI_FORTRAN

     15: #include "src/fortran/custom/zpetsc.h"
     16: #include "tao_solver.h"

     21: // static TaoTruth TaoInitializeCalled=TAO_FALSE;

     23: #if defined(PETSC_HAVE_NAGF90)
     24: #define iargc_  f90_unix_MP_iargc
     25: #define getarg_ f90_unix_MP_getarg
     26: #endif

     28: #ifdef PETSC_HAVE_FORTRAN_CAPS
     29: #define petscinitialize_              PETSCINITIALIZE
     30: #define taoinitialize_                TAOINITIALIZE
     31: #define iargc_                        IARGC
     32: #define getarg_                       GETARG
     33: #if defined(PARCH_win32)
     34: #define IARGC                         NARGS
     35: #endif

     37: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     38: #define petscinitialize_              petscinitialize
     39: #define taoinitialize_                taoinitialize
     40: /*
     41:     HP-UX does not have Fortran underscore but iargc and getarg
     42:   do have underscores????
     43: */
     44: #if !defined(PETSC_HAVE_FORTRAN_IARGC_UNDERSCORE)
     45: #define iargc_                        iargc
     46: #define getarg_                       getarg
     47: #endif

     49: #endif

     54: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
     56: #else
     58: #endif

     60: /*
     61:      Different Fortran compilers handle command lines in different ways
     62: */
     63: #if defined(PARCH_win32)
     64: /*
     67: */

     71: #else
     74: /*
     75:       The Cray T3D/T3E use the PXFGETARG() function
     76: */
     77: #if defined(PETSC_HAVE_PXFGETARG)
     79: #endif
     80: #endif

     86: /*
     87:     TaoInitialize - Version called from Fortran.

     89:     Notes:
     90:     Since this routine is called from Fortran it does not return error codes.
     91: */
     92: void PETSC_STDCALL taoinitialize_(CHAR filename PETSC_MIXED_LEN(len),int *ierr PETSC_END_LEN(len))
     93: {
     94:   *1;
     95:   if (TaoInitializeCalled) {*0; return;}

     97:   if (!PetscInitializeCalled) {
     98: #if defined(PETSC_USE_FORTRAN_MIXED_STR_ARG)
     99:     petscinitialize_(filename,len,ierr);
    100: #else
    101:     petscinitialize_(filename,ierr,len);
    102: #endif
    103:     if (*ierr) return;
    104:     TaoBeganPetsc = TAO_TRUE;
    105:   }

    107:   /* We currently register just one cookie for use by TAO solvers; in
    108:      the future we may need additional ones */
    109:   TAO_COOKIE = 0;
    110:   *ierr=PetscLogClassRegister(&TAO_COOKIE,"TAO Solver");

    112:   *TaoRegisterEvents();

    114:   *TaoStandardRegisterAll();

    116:   TaoInitializeCalled++;
    117:   *PetscLogInfo((0,"TaoInitialize:TAO successfully started from Fortran\n"));
    118: }