ext/cvode/source/cvspgmr.c
static int CVSpgmrInit(CVodeMem cv_mem, boole *setupNonNull)
{
  CVSpgmrMem cvspgmr_mem;

  cvspgmr_mem = (CVSpgmrMem) lmem;

  /* Print error message and return if cvspgmr_mem is NULL */  
  if (cvspgmr_mem == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    return(LINIT_ERR);
  }

  /* Check for legal pretype, precond, and psolve */ 
  if ((pretype != NONE) && (pretype != LEFT) &&
      (pretype != RIGHT) && (pretype != BOTH)) {
    fprintf(errfp, MSG_BAD_PRETYPE, pretype, NONE, LEFT, RIGHT, BOTH);
    return(LINIT_ERR);
  }
  if ((pretype != NONE) && (psolve == NULL)) {
    fprintf(errfp, MSG_PSOLVE_REQ);
    return(LINIT_ERR);
  }

  /* Check for legal gstype */
  if ((gstype != MODIFIED_GS) && (gstype != CLASSICAL_GS)) {
    fprintf(errfp, MSG_BAD_GSTYPE, gstype, MODIFIED_GS, CLASSICAL_GS);
    return(LINIT_ERR);
  }

  /* Allocate memory for ytemp and x */
  ytemp = N_VNew(N, machenv);
  if (ytemp == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    return(LINIT_ERR);
  }
  x = N_VNew(N, machenv);
  if (x == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    N_VFree(ytemp);
    return(LINIT_ERR);
  }

  /* Call SpgmrMalloc to allocate workspace for Spgmr */
  spgmr_mem = SpgmrMalloc(N, maxl, machenv);
  if (spgmr_mem == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    N_VFree(ytemp);
    N_VFree(x);
    return(LINIT_ERR);
  }

  /* Initialize sqrtN and counters, and set workspace lengths */

  sqrtN = RSqrt(N);
  npe = nli = nps = ncfl = nstlpre = 0;
    
  if (iopt != NULL) {
    iopt[SPGMR_NPE] = npe;
    iopt[SPGMR_NLI] = nli;
    iopt[SPGMR_NPS] = nps;
    iopt[SPGMR_NCFL] = ncfl;
    iopt[SPGMR_LRW] = N*(maxl + 5) + maxl*(maxl + 4) + 1;
    iopt[SPGMR_LIW] = 0;
  }

  /* Set setupNonNull to TRUE iff there is preconditioning        */
  /* (pretype != NONE) and there is a preconditioning setup phase */
  /* (precond != NULL)                                            */
  *setupNonNull = (pretype != NONE) && (precond != NULL);

  return(LINIT_OK);
}
/*************** CVSpgmrInit *****************************************

 This routine initializes remaining memory specific to the Spgmr 
 linear solver.  If any memory request fails, all memory previously
 allocated is freed, and an error message printed, before returning.

**********************************************************************/
CVSpgmrInit
This routine initializes remaining memory specific to the Spgmr
linear solver.  If any memory request fails, all memory previously
allocated is freed, and an error message printed, before returning.
CVSpgmrInit This routine initializes remaining memory specific to the Spgmr linear solver . If any memory request fails all memory previously allocated is freed and an error message printed before returning .
static int CVSpgmrInit(CVodeMem cv_mem, boole *setupNonNull)
{
  CVSpgmrMem cvspgmr_mem;
  cvspgmr_mem = (CVSpgmrMem) lmem;
  if (cvspgmr_mem == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    return(LINIT_ERR);
  }
  if ((pretype != NONE) && (pretype != LEFT) &&
      (pretype != RIGHT) && (pretype != BOTH)) {
    fprintf(errfp, MSG_BAD_PRETYPE, pretype, NONE, LEFT, RIGHT, BOTH);
    return(LINIT_ERR);
  }
  if ((pretype != NONE) && (psolve == NULL)) {
    fprintf(errfp, MSG_PSOLVE_REQ);
    return(LINIT_ERR);
  }
  if ((gstype != MODIFIED_GS) && (gstype != CLASSICAL_GS)) {
    fprintf(errfp, MSG_BAD_GSTYPE, gstype, MODIFIED_GS, CLASSICAL_GS);
    return(LINIT_ERR);
  }
  ytemp = N_VNew(N, machenv);
  if (ytemp == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    return(LINIT_ERR);
  }
  x = N_VNew(N, machenv);
  if (x == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    N_VFree(ytemp);
    return(LINIT_ERR);
  }
  spgmr_mem = SpgmrMalloc(N, maxl, machenv);
  if (spgmr_mem == NULL) {
    fprintf(errfp, MSG_MEM_FAIL);
    N_VFree(ytemp);
    N_VFree(x);
    return(LINIT_ERR);
  }
  sqrtN = RSqrt(N);
  npe = nli = nps = ncfl = nstlpre = 0;
  if (iopt != NULL) {
    iopt[SPGMR_NPE] = npe;
    iopt[SPGMR_NLI] = nli;
    iopt[SPGMR_NPS] = nps;
    iopt[SPGMR_NCFL] = ncfl;
    iopt[SPGMR_LRW] = N*(maxl + 5) + maxl*(maxl + 4) + 1;
    iopt[SPGMR_LIW] = 0;
  }
  *setupNonNull = (pretype != NONE) && (precond != NULL);
  return(LINIT_OK);
}
static int CVSpgmrInit ( CVodeMem cv_mem , boole * setupNonNull ) { CVSpgmrMem cvspgmr_mem ; cvspgmr_mem = ( CVSpgmrMem ) lmem ; if ( cvspgmr_mem == NULL ) { fprintf ( errfp , MSG_MEM_FAIL ) ; return ( LINIT_ERR ) ; } if ( ( pretype != NONE ) && ( pretype != LEFT ) && ( pretype != RIGHT ) && ( pretype != BOTH ) ) { fprintf ( errfp , MSG_BAD_PRETYPE , pretype , NONE , LEFT , RIGHT , BOTH ) ; return ( LINIT_ERR ) ; } if ( ( pretype != NONE ) && ( psolve == NULL ) ) { fprintf ( errfp , MSG_PSOLVE_REQ ) ; return ( LINIT_ERR ) ; } if ( ( gstype != MODIFIED_GS ) && ( gstype != CLASSICAL_GS ) ) { fprintf ( errfp , MSG_BAD_GSTYPE , gstype , MODIFIED_GS , CLASSICAL_GS ) ; return ( LINIT_ERR ) ; } ytemp = N_VNew ( N , machenv ) ; if ( ytemp == NULL ) { fprintf ( errfp , MSG_MEM_FAIL ) ; return ( LINIT_ERR ) ; } x = N_VNew ( N , machenv ) ; if ( x == NULL ) { fprintf ( errfp , MSG_MEM_FAIL ) ; N_VFree ( ytemp ) ; return ( LINIT_ERR ) ; } spgmr_mem = SpgmrMalloc ( N , maxl , machenv ) ; if ( spgmr_mem == NULL ) { fprintf ( errfp , MSG_MEM_FAIL ) ; N_VFree ( ytemp ) ; N_VFree ( x ) ; return ( LINIT_ERR ) ; } sqrtN = RSqrt ( N ) ; npe = nli = nps = ncfl = nstlpre = 0 ; if ( iopt != NULL ) { iopt [ SPGMR_NPE ] = npe ; iopt [ SPGMR_NLI ] = nli ; iopt [ SPGMR_NPS ] = nps ; iopt [ SPGMR_NCFL ] = ncfl ; iopt [ SPGMR_LRW ] = N * ( maxl + 5 ) + maxl * ( maxl + 4 ) + 1 ; iopt [ SPGMR_LIW ] = 0 ; } * setupNonNull = ( pretype != NONE ) && ( precond != NULL ) ; return ( LINIT_OK ) ; }
CVSpgmrInit 
This routine initializes remaining memory specific to the Spgmr
linear solver.
CVSpgmrInit This routine initializes remaining memory specific to the Spgmr linear solver .
/* Print error message and return if cvspgmr_mem is NULL */ /* Check for legal pretype, precond, and psolve */ /* Check for legal gstype */ /* Allocate memory for ytemp and x */ /* Call SpgmrMalloc to allocate workspace for Spgmr */ /* Initialize sqrtN and counters, and set workspace lengths */ /* Set setupNonNull to TRUE iff there is preconditioning        */ /* (pretype != NONE) and there is a preconditioning setup phase */ /* (precond != NULL)                                            */