1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h> 2665c2dedSJed Brown #include <petscviewer.h> 35c6c1daeSBarry Smith 45c6c1daeSBarry Smith #if defined(PETSC_HAVE_FORTRAN_CAPS) 55c6c1daeSBarry Smith #define petscviewerfilesetname_ PETSCVIEWERFILESETNAME 6df863907SAlex Fikl #define petscviewerfilegetname_ PETSCVIEWERFILEGETNAME 75c6c1daeSBarry Smith #define petscviewerasciiprintf_ PETSCVIEWERASCIIPRINTF 85c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ PETSCVIEWERASCIISYNCHRONIZEDPRINTF 960cf285bSSatish Balay #define petscviewerasciipushsynchronized_ PETSCVIEWERASCIIPUSHSYNCHRONIZED 1060cf285bSSatish Balay #define petscviewerasciipopsynchronized_ PETSCVIEWERASCIIPOPSYNCHRONIZED 115c6c1daeSBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 125c6c1daeSBarry Smith #define petscviewerfilesetname_ petscviewerfilesetname 13df863907SAlex Fikl #define petscviewerfilegetname_ petscviewerfilegetname 145c6c1daeSBarry Smith #define petscviewerasciiprintf_ petscviewerasciiprintf 155c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ petscviewerasciisynchronizedprintf 161575c14dSBarry Smith #define petscviewerasciipushsynchronized_ petscviewerasciipushsynchronized 171575c14dSBarry Smith #define petscviewerasciipopsynchronized_ petscviewerasciipopsynchronized 185c6c1daeSBarry Smith #endif 195c6c1daeSBarry Smith 20*390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerfilesetname_(PetscViewer *viewer,char* name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 215c6c1daeSBarry Smith { 225c6c1daeSBarry Smith char *c1; 235c6c1daeSBarry Smith PetscViewer v; 245c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 255c6c1daeSBarry Smith FIXCHAR(name,len,c1); 265c6c1daeSBarry Smith *ierr = PetscViewerFileSetName(v,c1); 275c6c1daeSBarry Smith FREECHAR(name,c1); 285c6c1daeSBarry Smith } 295c6c1daeSBarry Smith 30*390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerfilegetname_(PetscViewer *viewer, char* name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 31df863907SAlex Fikl { 32df863907SAlex Fikl const char *c1; 33df863907SAlex Fikl 34df863907SAlex Fikl *ierr = PetscViewerGetType(*viewer, &c1); 35df863907SAlex Fikl *ierr = PetscStrncpy(name, c1, len); 36df863907SAlex Fikl FIXRETURNCHAR(PETSC_TRUE, name, len); 37df863907SAlex Fikl } 38df863907SAlex Fikl 395c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out) 405c6c1daeSBarry Smith { 415c6c1daeSBarry Smith PetscErrorCode ierr; 425c6c1daeSBarry Smith PetscInt i; 435c6c1daeSBarry Smith size_t len; 445c6c1daeSBarry Smith 455c6c1daeSBarry Smith PetscFunctionBegin; 465c6c1daeSBarry Smith ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 475c6c1daeSBarry Smith ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 485c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 495c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 505c6c1daeSBarry Smith } 515c6c1daeSBarry Smith PetscFunctionReturn(0); 525c6c1daeSBarry Smith } 535c6c1daeSBarry Smith 54*390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciiprintf_(PetscViewer *viewer,char* str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 555c6c1daeSBarry Smith { 565c6c1daeSBarry Smith char *c1, *tmp; 575c6c1daeSBarry Smith PetscViewer v; 585c6c1daeSBarry Smith 595c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 605c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 615c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 625c6c1daeSBarry Smith FREECHAR(str,c1); 638bceffaeSBarry Smith *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return; 648bceffaeSBarry Smith *ierr = PetscFree(tmp); 655c6c1daeSBarry Smith } 665c6c1daeSBarry Smith 67*390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciisynchronizedprintf_(PetscViewer *viewer,char* str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 685c6c1daeSBarry Smith { 695c6c1daeSBarry Smith char *c1, *tmp; 705c6c1daeSBarry Smith PetscViewer v; 715c6c1daeSBarry Smith 725c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 735c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 745c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 755c6c1daeSBarry Smith FREECHAR(str,c1); 768bceffaeSBarry Smith *ierr = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return; 778bceffaeSBarry Smith *ierr = PetscFree(tmp); 785c6c1daeSBarry Smith } 795c6c1daeSBarry Smith 801575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipushsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 815c6c1daeSBarry Smith { 825c6c1daeSBarry Smith PetscViewer v; 835c6c1daeSBarry Smith 845c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 851575c14dSBarry Smith *ierr = PetscViewerASCIIPushSynchronized(v); 861575c14dSBarry Smith } 871575c14dSBarry Smith 881575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipopsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 891575c14dSBarry Smith { 901575c14dSBarry Smith PetscViewer v; 911575c14dSBarry Smith 921575c14dSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 931575c14dSBarry Smith *ierr = PetscViewerASCIIPopSynchronized(v); 945c6c1daeSBarry Smith } 95