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 6*df863907SAlex 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 13*df863907SAlex 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 208cc058d9SJed Brown 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*df863907SAlex Fikl PETSC_EXTERN void PETSC_STDCALL petscviewerfilegetname_(PetscViewer *viewer, CHAR name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 31*df863907SAlex Fikl { 32*df863907SAlex Fikl const char *c1; 33*df863907SAlex Fikl 34*df863907SAlex Fikl *ierr = PetscViewerGetType(*viewer, &c1); 35*df863907SAlex Fikl *ierr = PetscStrncpy(name, c1, len); 36*df863907SAlex Fikl FIXRETURNCHAR(PETSC_TRUE, name, len); 37*df863907SAlex Fikl } 38*df863907SAlex Fikl 395c6c1daeSBarry Smith #undef __FUNCT__ 405c6c1daeSBarry Smith #define __FUNCT__ "PetscFixSlashN" 415c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out) 425c6c1daeSBarry Smith { 435c6c1daeSBarry Smith PetscErrorCode ierr; 445c6c1daeSBarry Smith PetscInt i; 455c6c1daeSBarry Smith size_t len; 465c6c1daeSBarry Smith 475c6c1daeSBarry Smith PetscFunctionBegin; 485c6c1daeSBarry Smith ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 495c6c1daeSBarry Smith ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 505c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 515c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 525c6c1daeSBarry Smith } 535c6c1daeSBarry Smith PetscFunctionReturn(0); 545c6c1daeSBarry Smith } 555c6c1daeSBarry Smith 568cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciiprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 575c6c1daeSBarry Smith { 585c6c1daeSBarry Smith char *c1, *tmp; 595c6c1daeSBarry Smith PetscViewer v; 605c6c1daeSBarry Smith 615c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 625c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 635c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 645c6c1daeSBarry Smith FREECHAR(str,c1); 658bceffaeSBarry Smith *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return; 668bceffaeSBarry Smith *ierr = PetscFree(tmp); 675c6c1daeSBarry Smith } 685c6c1daeSBarry Smith 698cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciisynchronizedprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 705c6c1daeSBarry Smith { 715c6c1daeSBarry Smith char *c1, *tmp; 725c6c1daeSBarry Smith PetscViewer v; 735c6c1daeSBarry Smith 745c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 755c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 765c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 775c6c1daeSBarry Smith FREECHAR(str,c1); 788bceffaeSBarry Smith *ierr = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return; 798bceffaeSBarry Smith *ierr = PetscFree(tmp); 805c6c1daeSBarry Smith } 815c6c1daeSBarry Smith 821575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipushsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 835c6c1daeSBarry Smith { 845c6c1daeSBarry Smith PetscViewer v; 855c6c1daeSBarry Smith 865c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 871575c14dSBarry Smith *ierr = PetscViewerASCIIPushSynchronized(v); 881575c14dSBarry Smith } 891575c14dSBarry Smith 901575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipopsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 911575c14dSBarry Smith { 921575c14dSBarry Smith PetscViewer v; 931575c14dSBarry Smith 941575c14dSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 951575c14dSBarry Smith *ierr = PetscViewerASCIIPopSynchronized(v); 965c6c1daeSBarry Smith } 97