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 81c297824SMatthew G. Knepley #define petscviewerasciipushtab_ PETSCVIEWERASCIIPUSHTAB 91c297824SMatthew G. Knepley #define petscviewerasciipoptab_ PETSCVIEWERASCIIPOPTAB 105c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ PETSCVIEWERASCIISYNCHRONIZEDPRINTF 1160cf285bSSatish Balay #define petscviewerasciipushsynchronized_ PETSCVIEWERASCIIPUSHSYNCHRONIZED 1260cf285bSSatish Balay #define petscviewerasciipopsynchronized_ PETSCVIEWERASCIIPOPSYNCHRONIZED 135c6c1daeSBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 145c6c1daeSBarry Smith #define petscviewerfilesetname_ petscviewerfilesetname 15df863907SAlex Fikl #define petscviewerfilegetname_ petscviewerfilegetname 165c6c1daeSBarry Smith #define petscviewerasciiprintf_ petscviewerasciiprintf 171c297824SMatthew G. Knepley #define petscviewerasciipushtab_ petscviewerasciipushtab 181c297824SMatthew G. Knepley #define petscviewerasciipoptab_ petscviewerasciipoptab 195c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ petscviewerasciisynchronizedprintf 201575c14dSBarry Smith #define petscviewerasciipushsynchronized_ petscviewerasciipushsynchronized 211575c14dSBarry Smith #define petscviewerasciipopsynchronized_ petscviewerasciipopsynchronized 225c6c1daeSBarry Smith #endif 235c6c1daeSBarry Smith 2419caf8f3SSatish Balay PETSC_EXTERN void petscviewerfilesetname_(PetscViewer *viewer,char* name,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len) 255c6c1daeSBarry Smith { 265c6c1daeSBarry Smith char *c1; 275c6c1daeSBarry Smith PetscViewer v; 285c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 295c6c1daeSBarry Smith FIXCHAR(name,len,c1); 30443a0152SBarry Smith *ierr = PetscViewerFileSetName(v,c1);if (*ierr) return; 315c6c1daeSBarry Smith FREECHAR(name,c1); 325c6c1daeSBarry Smith } 335c6c1daeSBarry Smith 3419caf8f3SSatish Balay PETSC_EXTERN void petscviewerfilegetname_(PetscViewer *viewer, char* name, PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len) 35df863907SAlex Fikl { 36df863907SAlex Fikl const char *c1; 37df863907SAlex Fikl 38443a0152SBarry Smith *ierr = PetscViewerGetType(*viewer, &c1);if (*ierr) return; 39443a0152SBarry Smith *ierr = PetscStrncpy(name, c1, len);if (*ierr) return; 40df863907SAlex Fikl FIXRETURNCHAR(PETSC_TRUE, name, len); 41df863907SAlex Fikl } 42df863907SAlex Fikl 435c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out) 445c6c1daeSBarry Smith { 455c6c1daeSBarry Smith PetscInt i; 465c6c1daeSBarry Smith size_t len; 475c6c1daeSBarry Smith 485c6c1daeSBarry Smith PetscFunctionBegin; 499566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(in,out)); 509566063dSJacob Faibussowitsch PetscCall(PetscStrlen(*out,&len)); 515c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 525c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 535c6c1daeSBarry Smith } 54*3ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 555c6c1daeSBarry Smith } 565c6c1daeSBarry Smith 5719caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciiprintf_(PetscViewer *viewer,char* str,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len1) 585c6c1daeSBarry Smith { 595c6c1daeSBarry Smith char *c1, *tmp; 605c6c1daeSBarry Smith PetscViewer v; 615c6c1daeSBarry Smith 625c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 635c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 645c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 655c6c1daeSBarry Smith FREECHAR(str,c1); 663ca90d2dSJacob Faibussowitsch *ierr = PetscViewerASCIIPrintf(v,"%s",tmp);if (*ierr) return; 678bceffaeSBarry Smith *ierr = PetscFree(tmp); 685c6c1daeSBarry Smith } 695c6c1daeSBarry Smith 7019caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipushtab_(PetscViewer *viewer,PetscErrorCode *ierr) 711c297824SMatthew G. Knepley { 721c297824SMatthew G. Knepley PetscViewer v; 731c297824SMatthew G. Knepley PetscPatchDefaultViewers_Fortran(viewer,v); 741c297824SMatthew G. Knepley *ierr = PetscViewerASCIIPushTab(v); 751c297824SMatthew G. Knepley } 761c297824SMatthew G. Knepley 7719caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipoptab_(PetscViewer *viewer,PetscErrorCode *ierr) 781c297824SMatthew G. Knepley { 791c297824SMatthew G. Knepley PetscViewer v; 801c297824SMatthew G. Knepley PetscPatchDefaultViewers_Fortran(viewer,v); 811c297824SMatthew G. Knepley *ierr = PetscViewerASCIIPopTab(v); 821c297824SMatthew G. Knepley } 831c297824SMatthew G. Knepley 8419caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciisynchronizedprintf_(PetscViewer *viewer,char* str,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len1) 855c6c1daeSBarry Smith { 865c6c1daeSBarry Smith char *c1, *tmp; 875c6c1daeSBarry Smith PetscViewer v; 885c6c1daeSBarry Smith 895c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 905c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 915c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 925c6c1daeSBarry Smith FREECHAR(str,c1); 933ca90d2dSJacob Faibussowitsch *ierr = PetscViewerASCIISynchronizedPrintf(v,"%s",tmp);if (*ierr) return; 948bceffaeSBarry Smith *ierr = PetscFree(tmp); 955c6c1daeSBarry Smith } 965c6c1daeSBarry Smith 9719caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipushsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 985c6c1daeSBarry Smith { 995c6c1daeSBarry Smith PetscViewer v; 1005c6c1daeSBarry Smith 1015c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 1021575c14dSBarry Smith *ierr = PetscViewerASCIIPushSynchronized(v); 1031575c14dSBarry Smith } 1041575c14dSBarry Smith 10519caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipopsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 1061575c14dSBarry Smith { 1071575c14dSBarry Smith PetscViewer v; 1081575c14dSBarry Smith 1091575c14dSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 1101575c14dSBarry Smith *ierr = PetscViewerASCIIPopSynchronized(v); 1115c6c1daeSBarry Smith } 112