1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/**
* Copyright 1981-2007 ECMWF
*
* Licensed under the GNU Lesser General Public License which
* incorporates the terms and conditions of version 3 of the GNU
* General Public License.
* See LICENSE and gpl-3.0.txt for details.
*/
#ifdef FORTRAN_NO_UNDERSCORE
#define IINSERT iinsert
#define RINSERT rinsert
#define DINSERT dinsert
#define IXTRACT ixtract
#define RXTRACT rxtract
#define DXTRACT dxtract
#define RMOVEN rmoven
#define JLOC jloc
#else
#define IINSERT iinsert_
#define RINSERT rinsert_
#define DINSERT dinsert_
#define IXTRACT ixtract_
#define RXTRACT rxtract_
#define DXTRACT dxtract_
#define RMOVEN rmoven_
#define JLOC jloc_
#endif
#include <memory.h>
#include "fortint.h"
fortint IXTRACT(JPointer * array, fortint * index) {
fortint * p = (fortint *) *array;
/*
// Extracts a Fortran integer from an array.
// Note that the array pointer is given by reference.
*/
return (fortint) p[(*index)-1];
}
fortreal RXTRACT(RPointer * array, fortint * index) {
fortreal * p = (fortreal *) *array;
/*
// Extracts a Fortran real from an array.
// Note that the array pointer is given by reference.
*/
return (fortreal) p[(*index)-1];
}
void DXTRACT(void * target, void ** array, fortint * index) {
/*
// Extracts a Fortran REAL*8 from an array of doubles.
// Note that the array pointer is given by reference.
*/
unsigned char * p = (unsigned char*)(*array) + ((*index)-1)*8;
memmove(target, p, 8);
return;
}
void IINSERT(JPointer * array, fortint * index, fortint * value) {
fortint * p = (fortint *) *array;
/*
// Inserts a Fortran integer into an array.
// Note that the array pointer is given by reference.
*/
p[(*index)-1] = *value;
return;
}
void RINSERT(RPointer * array, fortint * index, fortreal * value) {
fortreal * p = (fortreal *) *array;
/*
// Inserts a Fortran real into an array.
// Note that the array pointer is given by reference.
*/
p[(*index)-1] = *value;
return;
}
void DINSERT(void ** array, fortint * index, void * value) {
/*
// Inserts a Fortran single into a (double) array.
// Note that the array pointer is given by reference.
*/
unsigned char * p = (unsigned char*)(*array) + ((*index)-1)*8;
memmove(p,value,8);
return;
}
void RMOVEN(RPointer * target, RPointer * source, fortint * number) {
fortreal * Target = (fortreal *) *target;
fortreal * Source = (fortreal *) *source;
size_t N = (*number) * sizeof(fortreal);
/*
// Moves Fortran reals from one array to another.
// Note that the array pointers are given by reference.
*/
memmove(Target, Source, N);
}
RPointer JLOC(RPointer array) {
/*
// Emulates the Fortran %LOC function
*/
return array;
}
|