Actual source code: error.c

      1: #define PETSCKSP_DLL

      3: /**********************************error.c*************************************

      5: Author: Henry M. Tufo III

      7: e-mail: hmt@cs.brown.edu

      9: snail-mail:
     10: Division of Applied Mathematics
     11: Brown University
     12: Providence, RI 02912

     14: Last Modification:
     15: 6.21.97
     16: ***********************************error.c************************************/

     18: /**********************************error.c*************************************
     19: File Description:
     20: -----------------

     22: ***********************************error.c************************************/
     23:  #include src/ksp/pc/impls/tfs/tfs.h

     25: /**********************************error.c*************************************
     26: Function error_msg_fatal()

     28: Input : pointer to formatted error message.
     29: Output: prints message to stdout.
     30: Return: na.
     31: Description: prints error message and terminates program.
     32: ***********************************error.c************************************/
     33: void error_msg_fatal(const char msg[], ...)
     34: {
     35:   va_list    ap;
     36:   const char *p;
     37:   char       *sval, cval;
     38:   int        ival;
     39:   PetscScalar       dval;

     42:   /* print error message along w/node identifier */
     43:   va_start(ap,msg);
     44:   printf("%d :: FATAL :: ", my_id);
     45:   for (p=msg; *p; p++)
     46:     {
     47:       if (*p != '%')
     48:         {
     49:           putchar(*p);
     50:           continue;
     51:         }
     52:       switch (*++p) {
     53:       case 'c':
     54:         cval = va_arg(ap,int);
     55:           putchar(cval);
     56:         break;
     57:       case 'd':
     58:         ival = va_arg(ap,int);
     59:         printf("%d",ival);
     60:         break;
     61:       case 'e':
     62:         dval = va_arg(ap,PetscScalar);
     63:         printf("%e",dval);
     64:         break;
     65:       case 'f':
     66:         dval = va_arg(ap,PetscScalar);
     67:         printf("%f",dval);
     68:         break;
     69:       case 'g':
     70:         dval = va_arg(ap,PetscScalar);
     71:         printf("%g",dval);
     72:         break;
     73:       case 's':
     74:         for (sval=va_arg(ap,char *); *sval; sval++)
     75:           {putchar(*sval);}
     76:         break;
     77:       default:
     78:         putchar(*p);
     79:         break;
     80:       }
     81:     }
     82:   /* printf("\n"); */
     83:   va_end(ap);

     85:   fflush(stdout);

     87:   /* Try with MPI_Finalize() as well _only_ if all procs call this routine */
     88:   /* Choose a more meaningful error code than -12 */
     89:   MPI_Abort(MPI_COMM_WORLD, -12);
     90: }

     94: /**********************************error.c*************************************
     95: Function error_msg_warning()

     97: Input : formatted string and arguments.
     98: Output: conversion printed to stdout.
     99: Return: na.
    100: Description: prints error message.
    101: ***********************************error.c************************************/
    102: void
    103: error_msg_warning(const char msg[], ...)
    104: {
    105:   /* print error message along w/node identifier */
    106: #if   defined V
    107:   va_list ap;
    108:   char *p, *sval, cval;
    109:   int ival;
    110:   PetscScalar dval;

    112:   va_start(ap,msg);
    113:   if (!my_id)
    114:     {
    115:       printf("%d :: WARNING :: ", my_id);
    116:       for (p=msg; *p; p++)
    117:         {
    118:           if (*p != '%')
    119:             {
    120:               putchar(*p);
    121:               continue;
    122:             }
    123:           switch (*++p) {
    124:           case 'c':
    125:             cval = va_arg(ap,char);
    126:             putchar(cval);
    127:             break;
    128:           case 'd':
    129:             ival = va_arg(ap,int);
    130:             printf("%d",ival);
    131:             break;
    132:           case 'e':
    133:             dval = va_arg(ap,PetscScalar);
    134:             printf("%e",dval);
    135:             break;
    136:           case 'f':
    137:             dval = va_arg(ap,PetscScalar);
    138:             printf("%f",dval);
    139:             break;
    140:           case 'g':
    141:             dval = va_arg(ap,PetscScalar);
    142:             printf("%g",dval);
    143:             break;
    144:           case 's':
    145:             for (sval=va_arg(ap,char *); *sval; sval++)
    146:               {putchar(*sval);}
    147:             break;
    148:           default:
    149:             putchar(*p);
    150:             break;
    151:           }
    152:         }
    153:       /*      printf("\n"); */
    154:     }
    155:   va_end(ap);

    158: #elif defined VV
    159:   va_list ap;
    160:   char *p, *sval, cval;
    161:   int ival;
    162:   PetscScalar dval;
    163:   va_start(ap,msg);
    164:   if (my_id>=0)
    165:     {
    166:       printf("%d :: WARNING :: ", my_id);
    167:       for (p=msg; *p; p++)
    168:         {
    169:           if (*p != '%')
    170:             {
    171:               putchar(*p);
    172:               continue;
    173:             }
    174:           switch (*++p) {
    175:           case 'c':
    176:             cval = va_arg(ap,char);
    177:             putchar(cval);
    178:             break;
    179:           case 'd':
    180:             ival = va_arg(ap,int);
    181:             printf("%d",ival);
    182:             break;
    183:           case 'e':
    184:             dval = va_arg(ap,PetscScalar);
    185:             printf("%e",dval);
    186:             break;
    187:           case 'f':
    188:             dval = va_arg(ap,PetscScalar);
    189:             printf("%f",dval);
    190:             break;
    191:           case 'g':
    192:             dval = va_arg(ap,PetscScalar);
    193:             printf("%g",dval);
    194:             break;
    195:           case 's':
    196:             for (sval=va_arg(ap,char *); *sval; sval++)
    197:               {putchar(*sval);}
    198:             break;
    199:           default:
    200:             putchar(*p);
    201:             break;
    202:           }
    203:         }
    204:       /* printf("\n"); */
    205:     }
    206:   va_end(ap);
    207: #endif

    209: #ifdef DELTA
    210:   fflush(stdout);
    211: #else
    212:   fflush(stdout);
    213:   /*  fflush(NULL); */
    214: #endif

    216: }