OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
mon_c.c File Reference
#include "hardware.inc"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <sys/utsname.h>

Go to the source code of this file.

Macros

#define _FCALL

Functions

void cpuinfo_c (char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo (char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo_ (char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo__ (char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void _FCALL CPUINFO (char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)

Macro Definition Documentation

◆ _FCALL

#define _FCALL

Definition at line 28 of file mon_c.c.

Function Documentation

◆ CPUINFO()

void _FCALL CPUINFO ( char * hostname,
int * lenhost,
char * cputype,
int * lencputype,
int * frequence,
int * memory,
int * swap )

Definition at line 686 of file mon_c.c.

687{
688 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory, swap );
689}
void cpuinfo_c(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
Definition mon_c.c:47
#define swap(a, b, tmp)
Definition macros.h:40

◆ cpuinfo()

void cpuinfo ( char * hostname,
int * lenhost,
char * cputype,
int * lencputype,
int * frequence,
int * memory,
int * swap )

Definition at line 671 of file mon_c.c.

672{
673 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory, swap );
674}

◆ cpuinfo_()

void cpuinfo_ ( char * hostname,
int * lenhost,
char * cputype,
int * lencputype,
int * frequence,
int * memory,
int * swap )

Definition at line 676 of file mon_c.c.

677{
678 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory, swap );
679}

◆ cpuinfo__()

void cpuinfo__ ( char * hostname,
int * lenhost,
char * cputype,
int * lencputype,
int * frequence,
int * memory,
int * swap )

Definition at line 681 of file mon_c.c.

682{
683 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory, swap );
684}

◆ cpuinfo_c()

void cpuinfo_c ( char * hostname,
int * lenhost,
char * cputype,
int * lencputype,
int * frequence,
int * memory,
int * swap )

Definition at line 47 of file mon_c.c.

48{
49
50 FILE * stream = NULL;
51 char ligne[256];
52 char freq[256];
53 int size,i,j;
54 int flag = 0;
55 int debut;
56 float fre;
57 struct sysinfo info;
58 struct utsname unam;
59#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
60 char * compstr="family :";
61#elif 1
62 char * compstr="model name";
63#endif
64 char * compMHZ="cpu MHz";
65 int cpMHZ=strlen(compMHZ);
66 int cmplen=strlen(compstr);
67 int unknown;
68 int lenmach;
69
70 unknown = 1;
71 j= 0;
72
73 stream=fopen("/proc/cpuinfo","r");
74
75 /* ------------ */
76 /* find cputype */
77 /* ------------ */
78 uname(&unam);
79 lenmach=strlen(unam.machine);
80
81 while (fgets(ligne,255,stream) && unknown){
82 if (strncmp(compstr,ligne,cmplen)==0){
83 unknown = 0;
84 break;
85 }
86 }
87
88 if (unknown == 0){
89 size = strlen(ligne);
90 debut = 12;
91 /*Elimination de blanc au debut*/
92 do
93 {
94 debut=debut+1;
95 }
96 while (ligne[debut]==' ' );
97
98 for (i=debut; i<size-1;i++) {
99 if (ligne[i]>31){
100 cputype[j] = ligne[i];
101 j=j+1 ;
102 }
103 }
104 cputype[j] = ' ' ;
105 j=j+1 ;
106 cputype[j] = '(' ;
107 j=j+1 ;
108 for (i=0; i<lenmach;i++) {
109 cputype[j] = unam.machine[i];
110 j=j+1 ;
111 }
112 cputype[j] = ')' ;
113 j=j+1 ;
114 cputype[j]='\0';
115
116 }else{
117 sprintf(cputype,"Unknown");
118 }
119 *lencputype = strlen(cputype);
120
121 /* -------------- */
122 /* find Frequence */
123 /* -------------- */
124
125 unknown = 1;
126 while (fgets(ligne,255,stream) && unknown){
127 if (strncmp(compMHZ,ligne,cpMHZ)==0){
128 unknown = 0;
129 break;
130 }
131 }
132 if ( unknown == 0){
133#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
134 debut = 13;
135#elif 1
136 debut = 10;
137#endif
138 j=0;
139 size = strlen(ligne);
140 for (i=debut; i<size-1;i++) {
141 freq[j] = ligne[i];
142 j=j+1 ;
143 }
144 freq[j]='\0';
145#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
146 fre = atof(freq);
147 *frequence = fre;
148#elif 1
149 *frequence = atoi(freq);
150#endif
151 }
152 else{
153 *frequence = -1;
154 }
155
156 fclose(stream);
157
158 gethostname(hostname, 256);
159 *lenhost = strlen(hostname);
160
161 /*memory - swap */
162 sysinfo ( &info );
163 *memory = info.totalram*info.mem_unit/(1024*1024);
164 *swap = info.freeswap*info.mem_unit/(1024*1024);
165
166
167}
*fortran !University of Stuttgart All rights reserved Inc All rights reserved ! $COPYRIGHT$ !Additional copyrights may follow ! $HEADER$ !WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING !Do ***not ***copy this file to the directory where your Fortran !fortran application is compiled unless it is absolutely necessary !Most !modern Fortran compilers now support the I command line flag
Definition mpif.h:26