xref: /petsc/src/sys/classes/viewer/impls/ascii/ftn-custom/zfilevf.c (revision 1575c14d35e6562ef67dce5e5a97f4a0489f95e5)
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
65c6c1daeSBarry Smith #define petscviewerasciiprintf_                PETSCVIEWERASCIIPRINTF
75c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_    PETSCVIEWERASCIISYNCHRONIZEDPRINTF
8*1575c14dSBarry Smith #define petscviewerasciipushsynchronized_      PETSCVIEWERASCIIPUSHSYNCHRONIZE
9*1575c14dSBarry Smith #define petscviewerasciipopsynchronized_       PETSCVIEWERASCIIPOPSYNCHRONIZE
105c6c1daeSBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
115c6c1daeSBarry Smith #define petscviewerfilesetname_                petscviewerfilesetname
125c6c1daeSBarry Smith #define petscviewerasciiprintf_                petscviewerasciiprintf
135c6c1daeSBarry Smith #define petscviewerasciisynchronizedprintf_    petscviewerasciisynchronizedprintf
14*1575c14dSBarry Smith #define petscviewerasciipushsynchronized_      petscviewerasciipushsynchronized
15*1575c14dSBarry Smith #define petscviewerasciipopsynchronized_       petscviewerasciipopsynchronized
165c6c1daeSBarry Smith #endif
175c6c1daeSBarry Smith 
188cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerfilesetname_(PetscViewer *viewer,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
195c6c1daeSBarry Smith {
205c6c1daeSBarry Smith   char        *c1;
215c6c1daeSBarry Smith   PetscViewer v;
225c6c1daeSBarry Smith   PetscPatchDefaultViewers_Fortran(viewer,v);
235c6c1daeSBarry Smith   FIXCHAR(name,len,c1);
245c6c1daeSBarry Smith   *ierr = PetscViewerFileSetName(v,c1);
255c6c1daeSBarry Smith   FREECHAR(name,c1);
265c6c1daeSBarry Smith }
275c6c1daeSBarry Smith 
285c6c1daeSBarry Smith #undef __FUNCT__
295c6c1daeSBarry Smith #define __FUNCT__ "PetscFixSlashN"
305c6c1daeSBarry Smith static PetscErrorCode PetscFixSlashN(const char *in, char **out)
315c6c1daeSBarry Smith {
325c6c1daeSBarry Smith   PetscErrorCode ierr;
335c6c1daeSBarry Smith   PetscInt       i;
345c6c1daeSBarry Smith   size_t         len;
355c6c1daeSBarry Smith 
365c6c1daeSBarry Smith   PetscFunctionBegin;
375c6c1daeSBarry Smith   ierr = PetscStrallocpy(in,out);CHKERRQ(ierr);
385c6c1daeSBarry Smith   ierr = PetscStrlen(*out,&len);CHKERRQ(ierr);
395c6c1daeSBarry Smith   for (i=0; i<(int)len-1; i++) {
405c6c1daeSBarry Smith     if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';}
415c6c1daeSBarry Smith   }
425c6c1daeSBarry Smith   PetscFunctionReturn(0);
435c6c1daeSBarry Smith }
445c6c1daeSBarry Smith 
458cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciiprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1))
465c6c1daeSBarry Smith {
475c6c1daeSBarry Smith   char        *c1, *tmp;
485c6c1daeSBarry Smith   PetscViewer v;
495c6c1daeSBarry Smith 
505c6c1daeSBarry Smith   PetscPatchDefaultViewers_Fortran(viewer,v);
515c6c1daeSBarry Smith   FIXCHAR(str,len1,c1);
525c6c1daeSBarry Smith   *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return;
535c6c1daeSBarry Smith   FREECHAR(str,c1);
548bceffaeSBarry Smith   *ierr = PetscViewerASCIIPrintf(v,tmp);if (*ierr) return;
558bceffaeSBarry Smith   *ierr = PetscFree(tmp);
565c6c1daeSBarry Smith }
575c6c1daeSBarry Smith 
588cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscviewerasciisynchronizedprintf_(PetscViewer *viewer,CHAR str PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(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 = PetscViewerASCIISynchronizedPrintf(v,tmp);if (*ierr) return;
688bceffaeSBarry Smith   *ierr = PetscFree(tmp);
695c6c1daeSBarry Smith }
705c6c1daeSBarry Smith 
71*1575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipushsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr)
725c6c1daeSBarry Smith {
735c6c1daeSBarry Smith   PetscViewer v;
745c6c1daeSBarry Smith 
755c6c1daeSBarry Smith   PetscPatchDefaultViewers_Fortran(viewer,v);
76*1575c14dSBarry Smith   *ierr = PetscViewerASCIIPushSynchronized(v);
77*1575c14dSBarry Smith }
78*1575c14dSBarry Smith 
79*1575c14dSBarry Smith PETSC_EXTERN void PETSC_STDCALL petscviewerasciipopsynchronized_(PetscViewer *viewer,PetscErrorCode *ierr)
80*1575c14dSBarry Smith {
81*1575c14dSBarry Smith   PetscViewer v;
82*1575c14dSBarry Smith 
83*1575c14dSBarry Smith   PetscPatchDefaultViewers_Fortran(viewer,v);
84*1575c14dSBarry Smith   *ierr = PetscViewerASCIIPopSynchronized(v);
855c6c1daeSBarry Smith }
86