1*5c6c1daeSBarry Smith #include <petsc-private/fortranimpl.h> 2*5c6c1daeSBarry Smith 3*5c6c1daeSBarry Smith #if defined(PETSC_HAVE_FORTRAN_CAPS) 4*5c6c1daeSBarry Smith #define petscviewerfilesetname_ PETSCVIEWERFILESETNAME 5*5c6c1daeSBarry Smith #define petscviewerasciiprintf_ PETSCVIEWERASCIIPRINTF 6*5c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ PETSCVIEWERASCIISYNCHRONIZEDPRINTF 7*5c6c1daeSBarry Smith #define petscviewerasciisynchronizedallow_ PETSCVIEWERASCIISYNCHRONIZEALLOW 8*5c6c1daeSBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 9*5c6c1daeSBarry Smith #define petscviewerfilesetname_ petscviewerfilesetname 10*5c6c1daeSBarry Smith #define petscviewerasciiprintf_ petscviewerasciiprintf 11*5c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_ petscviewerasciisynchronizedprintf 12*5c6c1daeSBarry Smith #define petscviewerasciisynchronizedallow_ petscviewerasciisynchronizedallow 13*5c6c1daeSBarry Smith #endif 14*5c6c1daeSBarry Smith 15*5c6c1daeSBarry Smith EXTERN_C_BEGIN 16*5c6c1daeSBarry Smith 17*5c6c1daeSBarry Smith void PETSC_STDCALL petscviewerfilesetname_(PetscViewer *viewer,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 18*5c6c1daeSBarry Smith { 19*5c6c1daeSBarry Smith char *c1; 20*5c6c1daeSBarry Smith PetscViewer v; 21*5c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 22*5c6c1daeSBarry Smith FIXCHAR(name,len,c1); 23*5c6c1daeSBarry Smith *ierr = PetscViewerFileSetName(v,c1); 24*5c6c1daeSBarry Smith FREECHAR(name,c1); 25*5c6c1daeSBarry Smith } 26*5c6c1daeSBarry Smith 27*5c6c1daeSBarry Smith #undef __FUNCT__ 28*5c6c1daeSBarry Smith #define __FUNCT__ "PetscFixSlashN" 29*5c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out) 30*5c6c1daeSBarry Smith { 31*5c6c1daeSBarry Smith PetscErrorCode ierr; 32*5c6c1daeSBarry Smith PetscInt i; 33*5c6c1daeSBarry Smith size_t len; 34*5c6c1daeSBarry Smith 35*5c6c1daeSBarry Smith PetscFunctionBegin; 36*5c6c1daeSBarry Smith ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 37*5c6c1daeSBarry Smith ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 38*5c6c1daeSBarry Smith for (i=0; i<(int)len-1; i++) { 39*5c6c1daeSBarry Smith if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 40*5c6c1daeSBarry Smith } 41*5c6c1daeSBarry Smith PetscFunctionReturn(0); 42*5c6c1daeSBarry Smith } 43*5c6c1daeSBarry Smith 44*5c6c1daeSBarry Smith void PETSC_STDCALL petscviewerasciiprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 45*5c6c1daeSBarry Smith { 46*5c6c1daeSBarry Smith char *c1, *tmp; 47*5c6c1daeSBarry Smith PetscViewer v; 48*5c6c1daeSBarry Smith 49*5c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 50*5c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 51*5c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 52*5c6c1daeSBarry Smith *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return; 53*5c6c1daeSBarry Smith *ierr = PetscFree(tmp);if (*ierr) return; 54*5c6c1daeSBarry Smith FREECHAR(str,c1); 55*5c6c1daeSBarry Smith } 56*5c6c1daeSBarry Smith 57*5c6c1daeSBarry Smith void PETSC_STDCALL petscviewerasciisynchronizedprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) 58*5c6c1daeSBarry Smith { 59*5c6c1daeSBarry Smith char *c1, *tmp; 60*5c6c1daeSBarry Smith PetscViewer v; 61*5c6c1daeSBarry Smith 62*5c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 63*5c6c1daeSBarry Smith FIXCHAR(str,len1,c1); 64*5c6c1daeSBarry Smith *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; 65*5c6c1daeSBarry Smith *ierr = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return; 66*5c6c1daeSBarry Smith *ierr = PetscFree(tmp);if (*ierr) return; 67*5c6c1daeSBarry Smith FREECHAR(str,c1); 68*5c6c1daeSBarry Smith } 69*5c6c1daeSBarry Smith 70*5c6c1daeSBarry Smith void PETSC_STDCALL petscviewerasciisynchronizedallow_(PetscViewer *viewer,PetscBool *allow,PetscErrorCode *ierr) 71*5c6c1daeSBarry Smith { 72*5c6c1daeSBarry Smith PetscViewer v; 73*5c6c1daeSBarry Smith 74*5c6c1daeSBarry Smith PetscPatchDefaultViewers_Fortran(viewer,v); 75*5c6c1daeSBarry Smith *ierr = PetscViewerASCIISynchronizedAllow(v,*allow); 76*5c6c1daeSBarry Smith } 77*5c6c1daeSBarry Smith 78*5c6c1daeSBarry Smith EXTERN_C_END 79