SURFEX v8.1
General documentation of Surfex
iswap8.c
Go to the documentation of this file.
1 #include <string.h>
2 
3 static const char * T = "abcd";
4 static const int dTle = 0x64636261;
5 static const int dTbe = 0x61626364;
6 
7 void iswap_isle_ (int * reqd)
8 {
9  int * dT = (int *)T;
10 
11  if (*dT == dTle)
12  *reqd = 1;
13  else
14  *reqd = 0;
15 }
16 
17 void iswap (char * a, const char * b, int t, int n, int d)
18 {
19  int i, j;
20 
21  if (d)
22  {
23  for (i = 0; i < n; i++)
24  for (j = 0; j < t / 2; j++)
25  {
26  char c = b[i*t+j]; /* a and b may be the same */
27  a[i*t+j] = b[i*t+t-j-1];
28  a[i*t+t-j-1] = c;
29  }
30  }
31  else if (a != b)
32  {
33  size_t nbytes = t * n;
34  memcpy (a, b, nbytes);
35  }
36 
37 }
38 
39 void iswap_ (char * a, const char * b, const int * _t, const int * _n)
40 {
41  int * dT = (int *)T;
42  iswap (a, b, *_t, *_n, *dT == dTle);
43 }
44 
45 void jswap_ (char * a, const char * b, const int * _t, const int * _n)
46 {
47  iswap (a, b, *_t, *_n, 1);
48 }
49 
50 
void iswap_(char *a, const char *b, const int *_t, const int *_n)
Definition: iswap8.c:39
ERROR in a
Definition: ecsort_shared.h:90
static const char * T
Definition: iswap8.c:3
ERROR in n
Definition: ecsort_shared.h:90
void iswap(char *a, const char *b, int t, int n, int d)
Definition: iswap8.c:17
static const int dTbe
Definition: iswap8.c:5
void iswap_isle_(int *reqd)
Definition: iswap8.c:7
static const int dTle
Definition: iswap8.c:4
subroutine t(CDPREF, CDSUFF, KCODPA, LDNIVA, PMULTI)
Definition: faicor.F90:567
void jswap_(char *a, const char *b, const int *_t, const int *_n)
Definition: iswap8.c:45