FV3 Bundle
memuse.c
Go to the documentation of this file.
1 /***********************************************************************
2  * GNU Lesser General Public License
3  *
4  * This file is part of the GFDL Flexible Modeling System (FMS).
5  *
6  * FMS is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or (at
9  * your option) any later version.
10  *
11  * FMS is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18  **********************************************************************/
19 #if defined(__sgi) || defined(__aix) || defined(__SX) || defined(__APPLE__)
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <sys/time.h>
24 #include <sys/resource.h>
25 
26 #define RUSAGE_SELF 0 /* calling process */
27 #define RUSAGE_CHILDREN -1 /* terminated child processes */
28 
29 #ifdef __aix
30 int memuse(void)
31 #else
32 int memuse_(void)
33 #endif
34 {
35  struct rusage my_rusage;
36  int iret;
37 
38  my_rusage.ru_maxrss = 0;
39  iret = getrusage(RUSAGE_SELF,&my_rusage);
40  iret = (int) my_rusage.ru_maxrss;
41  return iret;
42  /* printf("Max memuse in KB is %d \n",iret); */
43 }
44 #endif