xref: /petsc/src/sys/memory/ftn-custom/zmtrf.c (revision b45d2f2cb7e031d9c0de5873eca80614ca7b863b)
1*b45d2f2cSJed Brown #include <petsc-private/fortranimpl.h>
2c6db04a5SJed Brown #include <petscsys.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
1936366135SMatthew G Knepley 
20e878f7f2SJed Brown #undef __FUNCT__
21e878f7f2SJed Brown #define __FUNCT__ "PetscFixSlashN"
2236366135SMatthew G Knepley static PetscErrorCode PetscFixSlashN(const char *in, char **out)
2336366135SMatthew G Knepley {
2436366135SMatthew G Knepley   PetscErrorCode ierr;
2536366135SMatthew G Knepley   PetscInt       i;
2636366135SMatthew G Knepley   size_t         len;
2736366135SMatthew G Knepley 
2836366135SMatthew G Knepley   PetscFunctionBegin;
2936366135SMatthew G Knepley   ierr = PetscStrallocpy(in,out);CHKERRQ(ierr);
3036366135SMatthew G Knepley   ierr = PetscStrlen(*out,&len);CHKERRQ(ierr);
3136366135SMatthew G Knepley   for (i=0; i<(int)len-1; i++) {
3236366135SMatthew G Knepley     if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';}
3336366135SMatthew G Knepley   }
3436366135SMatthew G Knepley   PetscFunctionReturn(0);
3536366135SMatthew G Knepley }
3636366135SMatthew G Knepley 
3755fcb7f5SSatish Balay void PETSC_STDCALL  petscmallocdump_(PetscErrorCode *ierr)
3855fcb7f5SSatish Balay {
3955fcb7f5SSatish Balay   *ierr = PetscMallocDump(stdout);
4055fcb7f5SSatish Balay }
4155fcb7f5SSatish Balay void PETSC_STDCALL petscmallocdumplog_(PetscErrorCode *ierr)
4255fcb7f5SSatish Balay {
4355fcb7f5SSatish Balay   *ierr = PetscMallocDumpLog(stdout);
4455fcb7f5SSatish Balay }
4555fcb7f5SSatish Balay 
4655fcb7f5SSatish Balay void PETSC_STDCALL petscmallocvalidate_(PetscErrorCode *ierr)
4755fcb7f5SSatish Balay {
4855fcb7f5SSatish Balay   *ierr = PetscMallocValidate(0,"Unknown Fortran",0,0);
4955fcb7f5SSatish Balay }
5055fcb7f5SSatish Balay 
517a4fe282SBarry Smith void PETSC_STDCALL petscmemorysetgetmaximumusage_(PetscErrorCode *ierr)
527a4fe282SBarry Smith {
537a4fe282SBarry Smith   *ierr = PetscMemorySetGetMaximumUsage();
547a4fe282SBarry Smith }
557a4fe282SBarry Smith 
56fe7fb379SMatthew Knepley void PETSC_STDCALL petscmemoryshowusage_(PetscViewer *vin, CHAR message PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len))
57fe7fb379SMatthew Knepley {
58fe7fb379SMatthew Knepley   PetscViewer v;
5936366135SMatthew G Knepley   char *msg, *tmp;
60fe7fb379SMatthew Knepley 
61fe7fb379SMatthew Knepley   FIXCHAR(message,len,msg);
6236366135SMatthew G Knepley   *ierr = PetscFixSlashN(msg,&tmp);if (*ierr) return;
63fe7fb379SMatthew Knepley   PetscPatchDefaultViewers_Fortran(vin,v);
6436366135SMatthew G Knepley   *ierr = PetscMemoryShowUsage(v,tmp);
65fe7fb379SMatthew Knepley   FREECHAR(message,msg);
66fe7fb379SMatthew Knepley }
67fe7fb379SMatthew Knepley 
6855fcb7f5SSatish Balay EXTERN_C_END
69