15c6c1daeSBarry 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 65c6c1daeSBarry Smith #define petscviewerasciiprintf_ PETSCVIEWERASCIIPRINTF 75c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ PETSCVIEWERASCIISYNCHRONIZEDPRINTF 85c6c1daeSBarry Smith #define petscviewerasciisynchronizedallow_ PETSCVIEWERASCIISYNCHRONIZEALLOW 95c6c1daeSBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 105c6c1daeSBarry Smith #define petscviewerfilesetname_ petscviewerfilesetname 115c6c1daeSBarry Smith #define petscviewerasciiprintf_ petscviewerasciiprintf 125c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ petscviewerasciisynchronizedprintf 135c6c1daeSBarry Smith #define petscviewerasciisynchronizedallow_ petscviewerasciisynchronizedallow 145c6c1daeSBarry Smith #endif 155c6c1daeSBarry Smith 168cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerfilesetname_(PetscViewer *viewer,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 175c6c1daeSBarry Smith { 185c6c1daeSBarry Smith char *c1; 195c6c1daeSBarry Smith PetscViewer v; 205c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 215c6c1daeSBarry Smith FIXCHAR(name,len,c1); 225c6c1daeSBarry Smith *ierr = PetscViewerFileSetName(v,c1); 235c6c1daeSBarry Smith FREECHAR(name,c1); 245c6c1daeSBarry Smith } 255c6c1daeSBarry Smith 265c6c1daeSBarry Smith #undef __FUNCT__ 275c6c1daeSBarry Smith #define __FUNCT__ "PetscFixSlashN" 285c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out) 295c6c1daeSBarry Smith { 305c6c1daeSBarry Smith PetscErrorCode ierr; 315c6c1daeSBarry Smith PetscInt i; 325c6c1daeSBarry Smith size_t len; 335c6c1daeSBarry Smith 345c6c1daeSBarry Smith PetscFunctionBegin; 355c6c1daeSBarry Smith ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 365c6c1daeSBarry Smith ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 375c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 385c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 395c6c1daeSBarry Smith } 405c6c1daeSBarry Smith PetscFunctionReturn(0); 415c6c1daeSBarry Smith } 425c6c1daeSBarry Smith 438cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciiprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 445c6c1daeSBarry Smith { 455c6c1daeSBarry Smith char *c1, *tmp; 465c6c1daeSBarry Smith PetscViewer v; 475c6c1daeSBarry Smith 485c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 495c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 505c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 515c6c1daeSBarry Smith FREECHAR(str,c1); 52*8bceffaeSBarry Smith *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return; 53*8bceffaeSBarry Smith *ierr = PetscFree(tmp); 545c6c1daeSBarry Smith } 555c6c1daeSBarry Smith 568cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciisynchronizedprintf_(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); 65*8bceffaeSBarry Smith *ierr = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return; 66*8bceffaeSBarry Smith *ierr = PetscFree(tmp); 675c6c1daeSBarry Smith } 685c6c1daeSBarry Smith 698cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciisynchronizedallow_(PetscViewer *viewer,PetscBool *allow,PetscErrorCode *ierr) 705c6c1daeSBarry Smith { 715c6c1daeSBarry Smith PetscViewer v; 725c6c1daeSBarry Smith 735c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 745c6c1daeSBarry Smith *ierr = PetscViewerASCIISynchronizedAllow(v,*allow); 755c6c1daeSBarry Smith } 76