1b45d2f2cSJed Brown #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 9fe7fb379SMatthew Knepley #define petscmemoryshowusage_ PETSCMEMORYSHOWUSAGE 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 15fe7fb379SMatthew Knepley #define petscmemoryshowusage_ petscmemoryshowusage 167a4fe282SBarry Smith #define petscmemorysetgetmaximumusage_ petscmemorysetgetmaximumusage 1755fcb7f5SSatish Balay #endif 1855fcb7f5SSatish Balay 19e878f7f2SJed Brown #undef __FUNCT__ 20e878f7f2SJed Brown #define __FUNCT__ "PetscFixSlashN" 2136366135SMatthew G Knepley static PetscErrorCode PetscFixSlashN(const char *in, char **out) 2236366135SMatthew G Knepley { 2336366135SMatthew G Knepley PetscErrorCode ierr; 2436366135SMatthew G Knepley PetscInt i; 2536366135SMatthew G Knepley size_t len; 2636366135SMatthew G Knepley 2736366135SMatthew G Knepley PetscFunctionBegin; 2836366135SMatthew G Knepley ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 2936366135SMatthew G Knepley ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 3036366135SMatthew G Knepley for (i=0; i<(int)len-1; i++) { 3136366135SMatthew G Knepley if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 3236366135SMatthew G Knepley } 3336366135SMatthew G Knepley PetscFunctionReturn(0); 3436366135SMatthew G Knepley } 3536366135SMatthew G Knepley 368cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocdump_(PetscErrorCode *ierr) 3755fcb7f5SSatish Balay { 3855fcb7f5SSatish Balay *ierr = PetscMallocDump(stdout); 3955fcb7f5SSatish Balay } 408cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocdumplog_(PetscErrorCode *ierr) 4155fcb7f5SSatish Balay { 4255fcb7f5SSatish Balay *ierr = PetscMallocDumpLog(stdout); 4355fcb7f5SSatish Balay } 4455fcb7f5SSatish Balay 458cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmallocvalidate_(PetscErrorCode *ierr) 4655fcb7f5SSatish Balay { 47*efca3c55SSatish Balay *ierr = PetscMallocValidate(0,"Unknown Fortran",0); 4855fcb7f5SSatish Balay } 4955fcb7f5SSatish Balay 508cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmemorysetgetmaximumusage_(PetscErrorCode *ierr) 517a4fe282SBarry Smith { 527a4fe282SBarry Smith *ierr = PetscMemorySetGetMaximumUsage(); 537a4fe282SBarry Smith } 547a4fe282SBarry Smith 558cc058d9SJed Brown PETSC_EXTERN void PETSC_STDCALL petscmemoryshowusage_(PetscViewer *vin, CHAR message PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 56fe7fb379SMatthew Knepley { 57fe7fb379SMatthew Knepley PetscViewer v; 5836366135SMatthew G Knepley char *msg, *tmp; 59fe7fb379SMatthew Knepley 60fe7fb379SMatthew Knepley FIXCHAR(message,len,msg); 6136366135SMatthew G Knepley *ierr = PetscFixSlashN(msg,&tmp);if (*ierr) return; 62fe7fb379SMatthew Knepley PetscPatchDefaultViewers_Fortran(vin,v); 6336366135SMatthew G Knepley *ierr = PetscMemoryShowUsage(v,tmp); 64fe7fb379SMatthew Knepley FREECHAR(message,msg); 65fe7fb379SMatthew Knepley } 66fe7fb379SMatthew Knepley 67