xref: /petsc/src/sys/memory/ftn-custom/zmtrf.c (revision 390e1bf27627d887df99a9f4d0d0ad68037f55ec)
1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h>
2c6db04a5SJed Brown #include <petscsys.h>
3665c2dedSJed Brown #include <petscviewer.h>
455fcb7f5SSatish Balay 
555fcb7f5SSatish Balay #if defined(PETSC_HAVE_FORTRAN_CAPS)
655fcb7f5SSatish Balay #define petscmallocdump_               PETSCMALLOCDUMP
755fcb7f5SSatish Balay #define petscmallocdumplog_            PETSCMALLOCDUMPLOG
855fcb7f5SSatish Balay #define petscmallocvalidate_           PETSCMALLOCVALIDATE
90841954dSBarry Smith #define petscmemoryview_               PETSCMEMORYVIEW
107a4fe282SBarry Smith #define petscmemorysetgetmaximumusage_ PETSCMEMORYSETGETMAXIMUMUSAGE
1155fcb7f5SSatish Balay #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
1255fcb7f5SSatish Balay #define petscmallocdump_               petscmallocdump
1355fcb7f5SSatish Balay #define petscmallocdumplog_            petscmallocdumplog
1455fcb7f5SSatish Balay #define petscmallocvalidate_           petscmallocvalidate
150841954dSBarry Smith #define petscmemoryview_               petscmemoryview
167a4fe282SBarry Smith #define petscmemorysetgetmaximumusage_ petscmemorysetgetmaximumusage
1755fcb7f5SSatish Balay #endif
1855fcb7f5SSatish Balay 
1936366135SMatthew G Knepley static PetscErrorCode PetscFixSlashN(const char *in, char **out)
2036366135SMatthew G Knepley {
2136366135SMatthew G Knepley   PetscErrorCode ierr;
2236366135SMatthew G Knepley   PetscInt       i;
2336366135SMatthew G Knepley   size_t         len;
2436366135SMatthew G Knepley 
2536366135SMatthew G Knepley   PetscFunctionBegin;
2636366135SMatthew G Knepley   ierr = PetscStrallocpy(in,out);CHKERRQ(ierr);
2736366135SMatthew G Knepley   ierr = PetscStrlen(*out,&len);CHKERRQ(ierr);
2836366135SMatthew G Knepley   for (i=0; i<(int)len-1; i++) {
2936366135SMatthew G Knepley     if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';}
3036366135SMatthew G Knepley   }
3136366135SMatthew G Knepley   PetscFunctionReturn(0);
3236366135SMatthew G Knepley }
3336366135SMatthew G Knepley 
348cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocdump_(PetscErrorCode *ierr)
3555fcb7f5SSatish Balay {
3655fcb7f5SSatish Balay   *ierr = PetscMallocDump(stdout);
3755fcb7f5SSatish Balay }
388cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocdumplog_(PetscErrorCode *ierr)
3955fcb7f5SSatish Balay {
4055fcb7f5SSatish Balay   *ierr = PetscMallocDumpLog(stdout);
4155fcb7f5SSatish Balay }
4255fcb7f5SSatish Balay 
438cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocvalidate_(PetscErrorCode *ierr)
4455fcb7f5SSatish Balay {
45efca3c55SSatish Balay   *ierr = PetscMallocValidate(0,"Unknown Fortran",0);
4655fcb7f5SSatish Balay }
4755fcb7f5SSatish Balay 
488cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmemorysetgetmaximumusage_(PetscErrorCode *ierr)
497a4fe282SBarry Smith {
507a4fe282SBarry Smith   *ierr = PetscMemorySetGetMaximumUsage();
517a4fe282SBarry Smith }
527a4fe282SBarry Smith 
53*390e1bf2SBarry Smith PETSC_EXTERN void PETSC_STDCALL petscmemoryview_(PetscViewer *vin, char* message PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
54fe7fb379SMatthew Knepley {
55fe7fb379SMatthew Knepley   PetscViewer v;
5636366135SMatthew G Knepley   char        *msg, *tmp;
57fe7fb379SMatthew Knepley 
58fe7fb379SMatthew Knepley   FIXCHAR(message,len,msg);
5936366135SMatthew G Knepley   *ierr = PetscFixSlashN(msg,&tmp);if (*ierr) return;
60fe7fb379SMatthew Knepley   FREECHAR(message,msg);
618bceffaeSBarry Smith   PetscPatchDefaultViewers_Fortran(vin,v);
620841954dSBarry Smith   *ierr = PetscMemoryView(v,tmp);if (*ierr) return;
638bceffaeSBarry Smith   *ierr = PetscFree(tmp);
64fe7fb379SMatthew Knepley }
65fe7fb379SMatthew Knepley 
66