1b45d2f2cSJed Brown #include <petsc-private/fortranimpl.h> 2c6db04a5SJed Brown #include <petscsys.h> 3*665c2dedSJed 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 1955fcb7f5SSatish Balay EXTERN_C_BEGIN 2036366135SMatthew G Knepley 21e878f7f2SJed Brown #undef __FUNCT__ 22e878f7f2SJed Brown #define __FUNCT__ "PetscFixSlashN" 2336366135SMatthew G Knepley static PetscErrorCode PetscFixSlashN(const char *in, char **out) 2436366135SMatthew G Knepley { 2536366135SMatthew G Knepley PetscErrorCode ierr; 2636366135SMatthew G Knepley PetscInt i; 2736366135SMatthew G Knepley size_t len; 2836366135SMatthew G Knepley 2936366135SMatthew G Knepley PetscFunctionBegin; 3036366135SMatthew G Knepley ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); 3136366135SMatthew G Knepley ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); 3236366135SMatthew G Knepley for (i=0; i<(int)len-1; i++) { 3336366135SMatthew G Knepley if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} 3436366135SMatthew G Knepley } 3536366135SMatthew G Knepley PetscFunctionReturn(0); 3636366135SMatthew G Knepley } 3736366135SMatthew G Knepley 3855fcb7f5SSatish Balay void PETSC_STDCALL petscmallocdump_(PetscErrorCode *ierr) 3955fcb7f5SSatish Balay { 4055fcb7f5SSatish Balay *ierr = PetscMallocDump(stdout); 4155fcb7f5SSatish Balay } 4255fcb7f5SSatish Balay void PETSC_STDCALL petscmallocdumplog_(PetscErrorCode *ierr) 4355fcb7f5SSatish Balay { 4455fcb7f5SSatish Balay *ierr = PetscMallocDumpLog(stdout); 4555fcb7f5SSatish Balay } 4655fcb7f5SSatish Balay 4755fcb7f5SSatish Balay void PETSC_STDCALL petscmallocvalidate_(PetscErrorCode *ierr) 4855fcb7f5SSatish Balay { 4955fcb7f5SSatish Balay *ierr = PetscMallocValidate(0,"Unknown Fortran",0,0); 5055fcb7f5SSatish Balay } 5155fcb7f5SSatish Balay 527a4fe282SBarry Smith void PETSC_STDCALL petscmemorysetgetmaximumusage_(PetscErrorCode *ierr) 537a4fe282SBarry Smith { 547a4fe282SBarry Smith *ierr = PetscMemorySetGetMaximumUsage(); 557a4fe282SBarry Smith } 567a4fe282SBarry Smith 57fe7fb379SMatthew Knepley void PETSC_STDCALL petscmemoryshowusage_(PetscViewer *vin, CHAR message PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 58fe7fb379SMatthew Knepley { 59fe7fb379SMatthew Knepley PetscViewer v; 6036366135SMatthew G Knepley char *msg, *tmp; 61fe7fb379SMatthew Knepley 62fe7fb379SMatthew Knepley FIXCHAR(message,len,msg); 6336366135SMatthew G Knepley *ierr = PetscFixSlashN(msg,&tmp);if (*ierr) return; 64fe7fb379SMatthew Knepley PetscPatchDefaultViewers_Fortran(vin,v); 6536366135SMatthew G Knepley *ierr = PetscMemoryShowUsage(v,tmp); 66fe7fb379SMatthew Knepley FREECHAR(message,msg); 67fe7fb379SMatthew Knepley } 68fe7fb379SMatthew Knepley 6955fcb7f5SSatish Balay EXTERN_C_END 70