Menu

[r6421]: / trunk / toolkits / natgrid / src / nnusers.c  Maximize  Restore  History

Download this file

190 lines (176 with data), 4.6 kB

  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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "nnuheads.h"
#include "nnuhead.h"
/*
* Get values for float parameters.
*/
void c_nngetr(char *pnam, float *dval)
{
if (!strncmp(pnam,"bi",2) OR !strncmp(pnam,"BI",2) OR
!strncmp(pnam,"bI",2) OR !strncmp(pnam,"Bi",2)) {
*dval = bI;
}
else if (!strncmp(pnam,"bj",2) OR !strncmp(pnam,"BJ",2) OR
!strncmp(pnam,"bJ",2) OR !strncmp(pnam,"Bj",2)) {
*dval = bJ;
}
else if (!strncmp(pnam,"magx",4) OR !strncmp(pnam,"MAGX",4)) {
*dval = magx;
}
else if (!strncmp(pnam,"magy",4) OR !strncmp(pnam,"MAGY",4)) {
*dval = magy;
}
else if (!strncmp(pnam,"magz",4) OR !strncmp(pnam,"MAGZ",4)) {
*dval = magz;
}
else if (!strncmp(pnam,"hor",3) OR !strncmp(pnam,"HOR",3)) {
*dval = horilap;
}
else if (!strncmp(pnam,"ver",3) OR !strncmp(pnam,"VER",3)) {
*dval = vertlap;
}
else if (!strncmp(pnam,"nul",3) OR !strncmp(pnam,"NUL",3)) {
*dval = nuldat;
}
else if (!strncmp(pnam,"xas",3) OR !strncmp(pnam,"XAS",3)) {
*dval = magx_auto;
}
else if (!strncmp(pnam,"yas",3) OR !strncmp(pnam,"YAS",3)) {
*dval = magy_auto;
}
else if (!strncmp(pnam,"zas",3) OR !strncmp(pnam,"ZAS",3)) {
*dval = magz_auto;
}
else {
sprintf(emsg,"\n Parameter name supplied is: %s\n",pnam);
ErrorHnd(23, "c_nngetr", stderr, emsg);
}
}
/*
* Set values for float parameters.
*/
void c_nnsetr(char *pnam, float dval)
{
if (!strncmp(pnam,"bi",2) OR !strncmp(pnam,"BI",2) OR
!strncmp(pnam,"bI",2) OR !strncmp(pnam,"Bi",2)) {
if (dval < 1.) {
bI = 1.;
}
else if (dval > 3.) {
bI = 3.;
}
else {
bI = dval;
}
}
else if (!strncmp(pnam,"bj",2) OR !strncmp(pnam,"BJ",2) OR
!strncmp(pnam,"bJ",2) OR !strncmp(pnam,"Bj",2)) {
if (dval < 3.) {
bJ = 3.;
}
else if (dval > 9.) {
bJ = 9.;
}
else {
bJ = dval;
}
}
else if (!strncmp(pnam,"magx",4) OR !strncmp(pnam,"MAGX",4)) {
magx = dval;
}
else if (!strncmp(pnam,"magy",4) OR !strncmp(pnam,"MAGY",4)) {
magy = dval;
}
else if (!strncmp(pnam,"magz",4) OR !strncmp(pnam,"MAGZ",4)) {
magz = dval;
}
else if (!strncmp(pnam,"hor",3) OR !strncmp(pnam,"HOR",3)) {
horilap = dval;
}
else if (!strncmp(pnam,"ver",3) OR !strncmp(pnam,"VER",3)) {
vertlap = dval;
}
else if (!strncmp(pnam,"nul",3) OR !strncmp(pnam,"NUL",3)) {
nuldat = dval;
}
else {
sprintf(emsg,"\n Parameter name supplied is: %s\n",pnam);
ErrorHnd(23, "c_nngetc", stderr, emsg);
}
}
/*
* C entries in support of the Fortran interface.
*/
void NGCALLF(natgrids,NATGRIDS) (int *n, float *x, float *y, float *z,
int *nxg, int *nyg, float *xg, float *yg,
float *zg, int *ier)
{
float *zar;
int nn, mm;
zar = c_natgrids(*n, x, y, z, *nxg, *nyg, xg, yg, ier);
if (*ier) return;
for (mm = 0 ; mm < *nxg ; mm++) {
for (nn = 0 ; nn < *nyg ; nn++) {
*(zg + nn * (*nxg) + mm) = zar[mm*(*nyg)+nn];
}
}
free(zar);
return;
}
void NGCALLF(nnsetr,NNSETR) (char *pnam, float *rval)
{
c_nnsetr(pnam, *rval);
}
void NGCALLF(nngetr,NNGETR) (char *pnam, float *rval)
{
c_nngetr(pnam, rval);
}
void NGCALLF(nngetslopes,NNGETSLOPES) (int *row, int *col,
float *slope, int *ier)
{
c_nngetslopes(*row-1, *col-1, slope, ier);
}
void NGCALLF(nngetaspects,NNGETASPECTS) (int *row, int *col,
float *aspect, int *ier)
{
c_nngetaspects(*row-1, *col-1, aspect, ier);
}
void NGCALLF(nnpntinits,NNPNTINITS) (int *n, float *x, float *y, float *z)
{
c_nnpntinits (*n, x, y, z);
}
void NGCALLF(nnpnts,NNPNTS) (float *x, float *y, float *point)
{
c_nnpnts (*x, *y, point);
}
void NGCALLF(nnpntend,NNPNTEND) ()
{
c_nnpntend ();
}
void NGCALLF(nngetwts,NNGETWTS) (int *numw, int *neighs, float *wts, float *px, float *py, float *pz)
{
int i;
if (igrad || !single_point) {
ErrorHnd(31, "c_nngetwts", stderr, emsg);
}
c_nngetwts(numw, neighs, wts, px, py, pz);
/*
* Adjust the indices for Fortran.
*/
for (i = 0; i < *numw; i++) {
neighs[i]++;
}
}
void NGCALLF(nngetwtsd,NNGETWTSD) (int *numw, int *neighs, double *wts, double *px, double *py, double *pz)
{
int i;
if (igrad || !single_point) {
ErrorHnd(31, "c_nngetwtsd", stderr, emsg);
}
c_nngetwtsd(numw, neighs, wts, px, py, pz);
/*
* Adjust the indices for Fortran.
*/
for (i = 0; i < *numw; i++) {
neighs[i]++;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.