xref: /petsc/src/sys/memory/ftn-custom/zmtrf.c (revision 36366135a1972fb09bc2b7bdc4a57b3879d4b6c7)
1ce0a2cd1SBarry Smith #include "private/fortranimpl.h"
255fcb7f5SSatish Balay #include "petsc.h"
355fcb7f5SSatish Balay 
455fcb7f5SSatish Balay #if defined(PETSC_HAVE_FORTRAN_CAPS)
555fcb7f5SSatish Balay #define petscmallocdump_           PETSCMALLOCDUMP
655fcb7f5SSatish Balay #define petscmallocdumplog_        PETSCMALLOCDUMPLOG
755fcb7f5SSatish Balay #define petscmallocvalidate_       PETSCMALLOCVALIDATE
8fe7fb379SMatthew Knepley #define petscmemoryshowusage_      PETSCMEMORYSHOWUSAGE
97a4fe282SBarry Smith #define petscmemorysetgetmaximumusage_ PETSCMEMORYSETGETMAXIMUMUSAGE
1055fcb7f5SSatish Balay #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
1155fcb7f5SSatish Balay #define petscmallocdump_           petscmallocdump
1255fcb7f5SSatish Balay #define petscmallocdumplog_        petscmallocdumplog
1355fcb7f5SSatish Balay #define petscmallocvalidate_       petscmallocvalidate
14fe7fb379SMatthew Knepley #define petscmemoryshowusage_      petscmemoryshowusage
157a4fe282SBarry Smith #define petscmemorysetgetmaximumusage_ petscmemorysetgetmaximumusage
1655fcb7f5SSatish Balay #endif
1755fcb7f5SSatish Balay 
1855fcb7f5SSatish Balay EXTERN_C_BEGIN
19*36366135SMatthew G Knepley 
20*36366135SMatthew G Knepley static PetscErrorCode PetscFixSlashN(const char *in, char **out)
21*36366135SMatthew G Knepley {
22*36366135SMatthew G Knepley   PetscErrorCode ierr;
23*36366135SMatthew G Knepley   PetscInt       i;
24*36366135SMatthew G Knepley   size_t         len;
25*36366135SMatthew G Knepley 
26*36366135SMatthew G Knepley   PetscFunctionBegin;
27*36366135SMatthew G Knepley   ierr = PetscStrallocpy(in,out);CHKERRQ(ierr);
28*36366135SMatthew G Knepley   ierr = PetscStrlen(*out,&len);CHKERRQ(ierr);
29*36366135SMatthew G Knepley   for (i=0; i<(int)len-1; i++) {
30*36366135SMatthew G Knepley     if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';}
31*36366135SMatthew G Knepley   }
32*36366135SMatthew G Knepley   PetscFunctionReturn(0);
33*36366135SMatthew G Knepley }
34*36366135SMatthew G Knepley 
3555fcb7f5SSatish Balay void PETSC_STDCALL  petscmallocdump_(PetscErrorCode *ierr)
3655fcb7f5SSatish Balay {
3755fcb7f5SSatish Balay   *ierr = PetscMallocDump(stdout);
3855fcb7f5SSatish Balay }
3955fcb7f5SSatish Balay void PETSC_STDCALL petscmallocdumplog_(PetscErrorCode *ierr)
4055fcb7f5SSatish Balay {
4155fcb7f5SSatish Balay   *ierr = PetscMallocDumpLog(stdout);
4255fcb7f5SSatish Balay }
4355fcb7f5SSatish Balay 
4455fcb7f5SSatish Balay void PETSC_STDCALL petscmallocvalidate_(PetscErrorCode *ierr)
4555fcb7f5SSatish Balay {
4655fcb7f5SSatish Balay   *ierr = PetscMallocValidate(0,"Unknown Fortran",0,0);
4755fcb7f5SSatish Balay }
4855fcb7f5SSatish Balay 
497a4fe282SBarry Smith void PETSC_STDCALL petscmemorysetgetmaximumusage_(PetscErrorCode *ierr)
507a4fe282SBarry Smith {
517a4fe282SBarry Smith   *ierr = PetscMemorySetGetMaximumUsage();
527a4fe282SBarry Smith }
537a4fe282SBarry Smith 
54fe7fb379SMatthew Knepley void PETSC_STDCALL petscmemoryshowusage_(PetscViewer *vin, CHAR message PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
55fe7fb379SMatthew Knepley {
56fe7fb379SMatthew Knepley   PetscViewer v;
57*36366135SMatthew G Knepley   char *msg, *tmp;
58fe7fb379SMatthew Knepley 
59fe7fb379SMatthew Knepley   FIXCHAR(message,len,msg);
60*36366135SMatthew G Knepley   *ierr = PetscFixSlashN(msg,&tmp);if (*ierr) return;
61fe7fb379SMatthew Knepley   PetscPatchDefaultViewers_Fortran(vin,v);
62*36366135SMatthew G Knepley   *ierr = PetscMemoryShowUsage(v,tmp);
63fe7fb379SMatthew Knepley   FREECHAR(message,msg);
64fe7fb379SMatthew Knepley }
65fe7fb379SMatthew Knepley 
6655fcb7f5SSatish Balay EXTERN_C_END
67