Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / external / bufr / preproc.sh.ok
blob435e0ff038183c1f00779e33bfc95f7ab506ca26
1 #!/bin/sh
3 #-------------------------------------------------------------------------------
4 # Determine the byte-ordering scheme used by the local machine.
6 cat > endiantest.c << ENDIANTEST
8 #define Order(x)\
9 fill((char *)&x, sizeof(x)); \
10 for (i=1; i<=sizeof(x); i++) { \
11 c=((x>>(byte_size*(sizeof(x)-i)))&mask); \
12 putchar(c==0 ? '?' : (char)c); \
13 } \
14 printf("\n");
16 void fill(p, size) char *p; int size; {
17 char *ab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
18 int i;
20 for (i=0; i<size; i++) p[i]= ab[i];
23 void endian(byte_size) int byte_size; {
24 int j=0;
25 unsigned int mask, i, c;
27 mask=0;
28 for (i=1; i<=(unsigned)byte_size; i++) mask= (mask<<1)|1;
29 Order(j);
32 int cprop() {
33 /* Properties of type char */
34 char c;
35 int byte_size;
37 c=1; byte_size=0;
38 do { c<<=1; byte_size++; } while(c!=0);
40 return byte_size;
43 main()
45 int byte_size;
47 byte_size= cprop();
48 endian(byte_size);
50 ENDIANTEST
52 $CC -o endiantest endiantest.c
54 if [ `./endiantest | cut -c1` = "A" ]
55 then
56 byte_order=BIG_ENDIAN
57 else
58 byte_order=LITTLE_ENDIAN
61 rm -f endiantest.c endiantest
64 #-------------------------------------------------------------------------------
65 # Preprocess any Fortran *.F files into corresponding *.f files.
67 BNFS=""
69 set -x
70 for i in `ls *.F`
72 bn=`basename $i .F`
73 bnf=${bn}.f
74 BNFS="$BNFS $bnf"
75 $CPP -D$byte_order $i $bnf
76 done
78 #-------------------------------------------------------------------------------