NewMadeleine

Documentation

« back to PM2 home.
nm_mpif_private.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2006-2026 (see AUTHORS file)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef NM_MPIF_PRIVATE_H
17#define NM_MPIF_PRIVATE_H
18
19#include <Padico/Puk.h>
20
26#define NM_MPIF_PMPI(SYM_MPI, SYM_INTERNAL) \
27 __typeof__(SYM_INTERNAL ## _) p ## SYM_INTERNAL ## _ __attribute__ ((alias (NM_TOSTRING(SYM_INTERNAL ## _))));
28
29extern void*NM_MPI_F_MPI_BOTTOM;
30extern void*NM_MPI_F_MPI_IN_PLACE;
31extern void*NM_MPI_F_MPI_UNWEIGHTED;
34extern void*NM_MPI_F_MPI_ARGV_NULL;
35extern void*NM_MPI_F_MPI_ARGVS_NULL;
36
38extern void nm_mpi_initf_(void);
39
41#define NM_MPI_F_STATUS_DECLARE(_status) MPI_Status *_status, _status2;
42
43#define NM_MPI_F_STATUS_SET(_status, status) { \
44 if(status == MPI_F_STATUS_IGNORE) { \
45 _status = MPI_STATUS_IGNORE; \
46 } \
47 else { \
48 _status = &_status2; \
49 } \
50 }
51
52#define NM_MPI_F_STATUS_RETURN(_status, status) { \
53 if(_status != MPI_STATUS_IGNORE) { \
54 mpi_status_c2f(_status, status); \
55 } \
56 } \
57
58#define NM_MPI_F2C_BOTTOM(addr) { \
59 if(addr == NM_MPI_F_MPI_BOTTOM) { \
60 addr = MPI_BOTTOM; \
61 } \
62 }
63
64#define NM_MPI_F2C_IN_PLACE(addr) { \
65 if(addr == NM_MPI_F_MPI_IN_PLACE) { \
66 addr = MPI_IN_PLACE; \
67 } \
68 }
69
70
71/* ** some f2c & c2f internal helper */
72
73static inline void nm_mpif_array_c2f(int*c_array, MPI_Fint f_array[], int size)
74{
75 int i;
76 for(i = 0; i < size; i++)
77 {
78 f_array[i] = c_array[i];
79 }
80}
81
82static inline int*nm_mpif_array_f2c(MPI_Fint f_array[], int size)
83{
84 int*c_array = padico_malloc(sizeof(int) * size);
85 int i;
86 for(i = 0; i < size; i++)
87 {
88 c_array[i] = f_array[i];
89 }
90 return c_array;
91}
92
93static inline void nm_mpif_string_c2f(char*c_str, char*f_str, long int len)
94{
95 long int i;
96 long int c_len = strlen(c_str);
97 for(i = 0; i < c_len; i++)
98 f_str[i] = c_str[i];
99 for(i = c_len; i < len; i++)
100 f_str[i] = ' ';
101}
102
103static inline char*nm_mpif_string_f2c(char*f_str, long int len)
104{
105 long int i;
106 char*c_str;
107 char*pf = f_str + len - 1;
108 while(*pf == ' ' && pf > f_str)
109 pf--;
110 pf++;
111 long int c_len = pf - f_str;//len without null char
112 c_str = padico_malloc(sizeof(char) * (c_len + 1));
113 for(i = 0; i < c_len; i++)
114 c_str[i] = f_str[i];
115 c_str[i] = 0;
116 return c_str;
117}
118
119static inline char*nm_mpif_info_string_f2c(char*f_str, long int len)
120{
121 long int i;
122 char*c_str;
123 char*pf = f_str + len - 1;
124 char*pf_b = f_str;
125 while(*pf == ' ' && pf > f_str)
126 pf--;
127 pf++;
128 while(*pf_b == ' ' && pf_b < pf)
129 pf_b++;
130
131 long int c_len = pf - pf_b;//len without null char
132 c_str = padico_malloc(sizeof(char) * (c_len + 1));
133 for(i = 0; i < c_len; i++)
134 c_str[i] = pf_b[i];
135 c_str[i] = 0;
136 return c_str;
137}
138
139
140#endif /* NM_MPIF_PRIVATE_H */
nm_len_t len
Definition nm_data.h:1007
void * NM_MPI_F_MPI_ERRCODES_IGNORE
static char * nm_mpif_string_f2c(char *f_str, long int len)
static char * nm_mpif_info_string_f2c(char *f_str, long int len)
static void nm_mpif_array_c2f(int *c_array, MPI_Fint f_array[], int size)
void nm_mpi_initf_(void)
init Fortran constants
void * NM_MPI_F_MPI_IN_PLACE
static void nm_mpif_string_c2f(char *c_str, char *f_str, long int len)
void * NM_MPI_F_MPI_BOTTOM
static int * nm_mpif_array_f2c(MPI_Fint f_array[], int size)
void * NM_MPI_F_MPI_WEIGHTS_EMPTY
void * NM_MPI_F_MPI_UNWEIGHTED
void * NM_MPI_F_MPI_ARGV_NULL
void * NM_MPI_F_MPI_ARGVS_NULL
nm_len_t size
size of the onsided data (not incuding target-side completion)