Actual source code: zviewer.c

     2:  #include src/fortran/custom/zpetsc.h
     3:  #include petsc.h

      5: #ifdef PETSC_HAVE_FORTRAN_CAPS
      6: #define petscviewerdestroy_        PETSCVIEWERDESTROY
      7: #define petscviewerasciiopen_      PETSCVIEWERASCIIOPEN
      8: #define petscviewersetformat_      PETSCVIEWERSETFORMAT
      9: #define petscviewerpushformat_     PETSCVIEWERPUSHFORMAT
     10: #define petscviewerpopformat_      PETSCVIEWERPOPFORMAT
     11: #define petscviewerbinaryopen_     PETSCVIEWERBINARYOPEN
     12: #define petscviewermatlabopen_     PETSCVIEWERMATLABOPEN
     13: #define petscviewersocketopen_     PETSCVIEWERSOCKETOPEN
     14: #define petscviewerstringopen_     PETSCVIEWERSTRINGOPEN
     15: #define petscviewerdrawopen_       PETSCVIEWERDRAWOPEN
     16: #define petscviewersetfiletype_    PETSCVIEWERSETFILETYPE
     17: #define petscviewersetfilename_    PETSCVIEWERSETFILENAME
     18: #define petscviewersocketputscalar_ PETSCVIEWERSOCKETPUTSCALAR
     19: #define petscviewersocketputint_    PETSCVIEWERSOCKETPUTINT
     20: #define petscviewersocketputreal_   PETSCVIEWERSOCKETPUTREAL
     21: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
     22: #define petscviewersocketputscalar_ petscviewersocketputscalar
     23: #define petscviewersocketputint_    petscviewersocketputint
     24: #define petscviewersocketputreal_   petscviewersocketputreal
     25: #define petscviewerdestroy_        petscviewerdestroy
     26: #define petscviewerasciiopen_      petscviewerasciiopen
     27: #define petscviewersetformat_      petscviewersetformat
     28: #define petscviewerpushformat_     petscviewerpushformat
     29: #define petscviewerpopformat_      petscviewerpopformat
     30: #define petscviewerbinaryopen_     petscviewerbinaryopen
     31: #define petscviewermatlabopen_     petscviewermatlabopen
     32: #define petscviewersocketopen_     petscviewersocketopen
     33: #define petscviewerstringopen_     petscviewerstringopen
     34: #define petscviewerdrawopen_       petscviewerdrawopen
     35: #define petscviewersetfiletype_    petscviewersetfiletype
     36: #define petscviewersetfilename_    petscviewersetfilename
     37: #endif

     41: #if defined(PETSC_USE_SOCKET_VIEWER)
     42: void PETSC_STDCALL petscviewersocketputscalar(PetscViewer *viewer,PetscInt *m,PetscInt *n,PetscScalar *s,PetscErrorCode *ierr)
     43: {
     44:   PetscViewer v;
     45:   PetscPatchDefaultViewers_Fortran(viewer,v);
     46:   *PetscViewerSocketPutScalar(v,*m,*n,s);
     47: }

     49: void PETSC_STDCALL petscviewersocketputreal(PetscViewer *viewer,PetscInt *m,PetscInt *n,PetscReal *s,PetscErrorCode *ierr)
     50: {
     51:   PetscViewer v;
     52:   PetscPatchDefaultViewers_Fortran(viewer,v);
     53:   *PetscViewerSocketPutReal(v,*m,*n,s);
     54: }

     56: void PETSC_STDCALL petscviewersocketputint(PetscViewer *viewer,PetscInt *m,PetscInt *s,PetscErrorCode *ierr)
     57: {
     58:   PetscViewer v;
     59:   PetscPatchDefaultViewers_Fortran(viewer,v);
     60:   *PetscViewerSocketPutInt(v,*m,s);
     61: }
     62: #endif

     64: void PETSC_STDCALL petscviewersetfilename_(PetscViewer *viewer,CHAR name PETSC_MIXED_LEN(len),
     65:                                       PetscErrorCode *ierr PETSC_END_LEN(len))
     66: {
     67:   char   *c1;
     68:   PetscViewer v;
     69:   PetscPatchDefaultViewers_Fortran(viewer,v);
     70:   FIXCHAR(name,len,c1);
     71:   *PetscViewerSetFilename(v,c1);
     72:   FREECHAR(name,c1);
     73: }

     75: void PETSC_STDCALL  petscviewersetfiletype_(PetscViewer *viewer,PetscViewerFileType *type,PetscErrorCode *ierr)
     76: {
     77:   PetscViewer v;
     78:   PetscPatchDefaultViewers_Fortran(viewer,v);
     79:   *PetscViewerSetFileType(v,*type);
     80: }

     82: #if defined(PETSC_USE_SOCKET_VIEWER)
     83: void PETSC_STDCALL petscviewersocketopen_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len),int *port,PetscViewer *lab,PetscErrorCode *ierr PETSC_END_LEN(len))
     84: {
     85:   char   *c1;
     86:   FIXCHAR(name,len,c1);
     87:   *PetscViewerSocketOpen((MPI_Comm)PetscToPointerComm(*comm),c1,*port,lab);
     88:   FREECHAR(name,c1);
     89: }
     90: #endif

     92: void PETSC_STDCALL petscviewerbinaryopen_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len),PetscViewerFileType *type,
     93:                            PetscViewer *binv,PetscErrorCode *ierr PETSC_END_LEN(len))
     94: {
     95:   char   *c1;
     96:   FIXCHAR(name,len,c1);
     97:   *PetscViewerBinaryOpen((MPI_Comm)PetscToPointerComm(*comm),c1,*type,binv);
     98:   FREECHAR(name,c1);
     99: }

    101: #if defined(PETSC_HAVE_MATLAB)
    102: void PETSC_STDCALL petscviewermatlabopen_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len),PetscViewerFileType *type,
    103:                            PetscViewer *binv,PetscErrorCode *ierr PETSC_END_LEN(len))
    104: {
    105:   char   *c1;
    106:   FIXCHAR(name,len,c1);
    107:   *PetscViewerMatlabOpen((MPI_Comm)PetscToPointerComm(*comm),c1,*type,binv);
    108:   FREECHAR(name,c1);
    109: }
    110: #endif

    112: void PETSC_STDCALL petscviewerasciiopen_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len),PetscViewer *lab,
    113:                                     PetscErrorCode *ierr PETSC_END_LEN(len))
    114: {
    115:   char   *c1;
    116:   FIXCHAR(name,len,c1);
    117:   *PetscViewerASCIIOpen((MPI_Comm)PetscToPointerComm(*comm),c1,lab);
    118:   FREECHAR(name,c1);
    119: }

    121: void PETSC_STDCALL petscviewersetformat_(PetscViewer *vin,PetscViewerFormat *format,PetscErrorCode *ierr)
    122: {
    123:   PetscViewer v;
    124:   PetscPatchDefaultViewers_Fortran(vin,v);
    125:   *PetscViewerSetFormat(v,*format);
    126: }

    128: void PETSC_STDCALL petscviewerpushformat_(PetscViewer *vin,PetscViewerFormat *format,PetscErrorCode *ierr)
    129: {
    130:   PetscViewer v;
    131:   PetscPatchDefaultViewers_Fortran(vin,v);
    132:   *PetscViewerPushFormat(v,*format);
    133: }

    135: void PETSC_STDCALL petscviewerpopformat_(PetscViewer *vin,PetscErrorCode *ierr)
    136: {
    137:   PetscViewer v;
    138:   PetscPatchDefaultViewers_Fortran(vin,v);
    139:   *PetscViewerPopFormat(v);
    140: }

    142: void PETSC_STDCALL petscviewerdestroy_(PetscViewer *v,PetscErrorCode *ierr)
    143: {
    144:   *PetscViewerDestroy(*v);
    145: }

    147: void PETSC_STDCALL petscviewerstringopen_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len1),PetscInt *len,PetscViewer *str,
    148:                                      PetscErrorCode *ierr PETSC_END_LEN(len1))
    149: {
    150: #if defined(PETSC_USES_CPTOFCD)
    151:   *PetscViewerStringOpen((MPI_Comm)PetscToPointerComm(*comm),_fcdtocp(name),*len,str);
    152: #else
    153:   *PetscViewerStringOpen((MPI_Comm)PetscToPointerComm(*comm),name,*len,str);
    154: #endif
    155: }
    156:
    157: void PETSC_STDCALL petscviewerdrawopen_(MPI_Comm *comm,CHAR display PETSC_MIXED_LEN(len1),
    158:                    CHAR title PETSC_MIXED_LEN(len2),int *x,int*y,int*w,int*h,PetscViewer *v,
    159:                    PetscErrorCode *ierr PETSC_END_LEN(len1) PETSC_END_LEN(len2))
    160: {
    161:   char   *c1,*c2;

    163:   FIXCHAR(display,len1,c1);
    164:   FIXCHAR(title,len2,c2);
    165:   *PetscViewerDrawOpen((MPI_Comm)PetscToPointerComm(*comm),c1,c2,*x,*y,*w,*h,v);
    166:   FREECHAR(display,c1);
    167:   FREECHAR(title,c2);
    168: }