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 24*19caf8f3SSatish 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 34*19caf8f3SSatish 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 PetscErrorCode ierr; 465c6c1daeSBarry Smith PetscInt i; 475c6c1daeSBarry Smith size_t len; 485c6c1daeSBarry Smith 495c6c1daeSBarry Smith PetscFunctionBegin; 505c6c1daeSBarry Smith ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 515c6c1daeSBarry Smith ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 525c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 535c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 545c6c1daeSBarry Smith } 555c6c1daeSBarry Smith PetscFunctionReturn(0); 565c6c1daeSBarry Smith } 575c6c1daeSBarry Smith 58*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciiprintf_(PetscViewer *viewer,char* str,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len1) 595c6c1daeSBarry Smith { 605c6c1daeSBarry Smith char *c1, *tmp; 615c6c1daeSBarry Smith PetscViewer v; 625c6c1daeSBarry Smith 635c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 645c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 655c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 665c6c1daeSBarry Smith FREECHAR(str,c1); 678bceffaeSBarry Smith *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return; 688bceffaeSBarry Smith *ierr = PetscFree(tmp); 695c6c1daeSBarry Smith } 705c6c1daeSBarry Smith 71*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipushtab_(PetscViewer *viewer,PetscErrorCode *ierr) 721c297824SMatthew G. Knepley { 731c297824SMatthew G. Knepley PetscViewer v; 741c297824SMatthew G. Knepley PetscPatchDefaultViewers_Fortran(viewer,v); 751c297824SMatthew G. Knepley *ierr = PetscViewerASCIIPushTab(v); 761c297824SMatthew G. Knepley } 771c297824SMatthew G. Knepley 78*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipoptab_(PetscViewer *viewer,PetscErrorCode *ierr) 791c297824SMatthew G. Knepley { 801c297824SMatthew G. Knepley PetscViewer v; 811c297824SMatthew G. Knepley PetscPatchDefaultViewers_Fortran(viewer,v); 821c297824SMatthew G. Knepley *ierr = PetscViewerASCIIPopTab(v); 831c297824SMatthew G. Knepley } 841c297824SMatthew G. Knepley 85*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciisynchronizedprintf_(PetscViewer *viewer,char* str,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len1) 865c6c1daeSBarry Smith { 875c6c1daeSBarry Smith char *c1, *tmp; 885c6c1daeSBarry Smith PetscViewer v; 895c6c1daeSBarry Smith 905c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 915c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 925c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 935c6c1daeSBarry Smith FREECHAR(str,c1); 948bceffaeSBarry Smith *ierr = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return; 958bceffaeSBarry Smith *ierr = PetscFree(tmp); 965c6c1daeSBarry Smith } 975c6c1daeSBarry Smith 98*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipushsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 995c6c1daeSBarry Smith { 1005c6c1daeSBarry Smith PetscViewer v; 1015c6c1daeSBarry Smith 1025c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 1031575c14dSBarry Smith *ierr = PetscViewerASCIIPushSynchronized(v); 1041575c14dSBarry Smith } 1051575c14dSBarry Smith 106*19caf8f3SSatish Balay PETSC_EXTERN void petscviewerasciipopsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr) 1071575c14dSBarry Smith { 1081575c14dSBarry Smith PetscViewer v; 1091575c14dSBarry Smith 1101575c14dSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 1111575c14dSBarry Smith *ierr = PetscViewerASCIIPopSynchronized(v); 1125c6c1daeSBarry Smith } 113