mirror of
https://code.it4i.cz/sccs/easyconfigs-it4i.git
synced 2025-04-16 11:48:06 +01:00
104 lines
1.7 KiB
C
104 lines
1.7 KiB
C
/*
|
|
FORTRAN callable routines
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <utmpx.h>
|
|
#include <sched.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int sched_getcpu();
|
|
|
|
#ifdef INT64
|
|
void sleep_f_(long int *time)
|
|
#else
|
|
void sleep_f_(int *time)
|
|
#endif
|
|
{
|
|
unsigned int time_rem;
|
|
time_rem = sleep((unsigned int)*time);
|
|
if(time_rem != 0) {
|
|
printf("Sleep interrupted by signal handler.\n");
|
|
}
|
|
}
|
|
|
|
#ifdef INT64
|
|
void usleep_f_(long int *time)
|
|
#else
|
|
void usleep_f_(int *time)
|
|
#endif
|
|
{
|
|
int error;
|
|
error = usleep((useconds_t)*time);
|
|
if(error != 0) {
|
|
if(errno == EINTR) {
|
|
printf("Sleep interrupted by a signal.\n");
|
|
} else if(errno == EINVAL) {
|
|
usleep((useconds_t)1000000);
|
|
}
|
|
}
|
|
}
|
|
|
|
#ifdef INT64
|
|
long int getcpu_ ()
|
|
#else
|
|
int getcpu_ ()
|
|
#endif
|
|
{
|
|
int cpu;
|
|
cpu = sched_getcpu();
|
|
return cpu;
|
|
}
|
|
|
|
#ifdef INT64
|
|
long int getpid_f_ () {
|
|
long int pid;
|
|
#else
|
|
int getpid_f_ () {
|
|
int pid;
|
|
#endif
|
|
pid = getpid();
|
|
return pid;
|
|
}
|
|
|
|
void exec_mpirun_(int *implementation) {
|
|
int nargs = 5 + (*implementation == 2 ? 3 : 0);
|
|
char **args = (char **)calloc(nargs, sizeof(char *));
|
|
args[0] = "mpirun";
|
|
args[1] = "-np";
|
|
args[2] = "1";
|
|
if(*implementation == 2) {
|
|
args[3] = "-oversubscribe";
|
|
args[4] = "-map-by";
|
|
args[5] = "node";
|
|
}
|
|
args[nargs - 2] = "dmrcc_mpi";
|
|
execvp("mpirun", args);
|
|
}
|
|
|
|
#ifdef STATIC
|
|
asm (".symver memcpy, memcpy@GLIBC_2.2.5");
|
|
|
|
void *__wrap_memcpy(void *dest, const void *src, size_t n)
|
|
{
|
|
return memcpy(dest, src, n);
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
int __wrap_mkl_serv_intel_cpu_true()
|
|
{
|
|
return 1;
|
|
}
|