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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
/*============================================================================
WCSLIB 4.8 - an implementation of the FITS WCS standard.
Copyright (C) 1995-2011, Mark Calabretta
This file is part of WCSLIB.
WCSLIB is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with WCSLIB. If not, see <http://www.gnu.org/licenses/>.
Correspondence concerning WCSLIB may be directed to:
Internet email: mcalabre@atnf.csiro.au
Postal address: Dr. Mark Calabretta
Australia Telescope National Facility, CSIRO
PO Box 76
Epping NSW 1710
AUSTRALIA
Author: Mark Calabretta, Australia Telescope National Facility
http://www.atnf.csiro.au/~mcalabre/index.html
$Id: tab_f.c,v 4.8.1.1 2011/08/15 08:07:07 cal103 Exp cal103 $
*===========================================================================*/
#include <stdio.h>
#include <tab.h>
/* Fortran name mangling. */
#include <wcsconfig_f77.h>
#define tabini_ F77_FUNC(tabini, TABINI)
#define tabmem_ F77_FUNC(tabmem, TABMEM)
#define tabcpy_ F77_FUNC(tabcpy, TABCPY)
#define tabput_ F77_FUNC(tabput, TABPUT)
#define tabget_ F77_FUNC(tabget, TABGET)
#define tabfree_ F77_FUNC(tabfree, TABFREE)
#define tabprt_ F77_FUNC(tabprt, TABPRT)
#define tabset_ F77_FUNC(tabset, TABSET)
#define tabx2s_ F77_FUNC(tabx2s, TABX2S)
#define tabs2x_ F77_FUNC(tabs2x, TABS2X)
#define tabptd_ F77_FUNC(tabptd, TABPTD)
#define tabpti_ F77_FUNC(tabpti, TABPTI)
#define tabgtd_ F77_FUNC(tabgtd, TABGTD)
#define tabgti_ F77_FUNC(tabgti, TABGTI)
#define TAB_FLAG 100
#define TAB_M 101
#define TAB_K 102
#define TAB_MAP 103
#define TAB_CRVAL 104
#define TAB_INDEX 105
#define TAB_COORD 106
#define TAB_NC 200
#define TAB_SENSE 201
#define TAB_P0 202
#define TAB_DELTA 203
#define TAB_EXTREMA 204
#define TAB_ERR 205
/*--------------------------------------------------------------------------*/
int tabini_(const int *M, const int *K, int *tab)
{
return tabini(1, *M, K, (struct tabprm *)tab);
}
/*--------------------------------------------------------------------------*/
int tabmem_(int *tab)
{
return tabmem((struct tabprm *)tab);
}
/*--------------------------------------------------------------------------*/
int tabcpy_(const int *tabsrc, int *tabdst)
{
return tabcpy(1, (const struct tabprm *)tabsrc, (struct tabprm *)tabdst);
}
/*--------------------------------------------------------------------------*/
int tabput_(
int *tab,
const int *what,
const void *value,
const int *m,
const int *k)
{
int k0, m0;
const int *ivalp;
const double *dvalp;
struct tabprm *tabp;
/* Cast pointers. */
tabp = (struct tabprm *)tab;
ivalp = (const int *)value;
dvalp = (const double *)value;
/* Convert 1-relative FITS axis numbers to 0-relative C array indices. */
m0 = *m - 1;
k0 = *k - 1;
tabp->flag = 0;
switch (*what) {
case TAB_FLAG:
tabp->flag = *ivalp;
break;
case TAB_M:
tabp->M = *ivalp;
break;
case TAB_K:
tabp->K[m0] = *ivalp;
break;
case TAB_MAP:
tabp->map[m0] = *ivalp;
break;
case TAB_CRVAL:
tabp->crval[m0] = *dvalp;
break;
case TAB_INDEX:
tabp->index[m0][k0] = *dvalp;
break;
case TAB_COORD:
tabp->coord[m0] = *dvalp;
break;
default:
return 1;
}
return 0;
}
int tabptd_(int *tab, const int *what, const double *value, const int *m,
const int *k)
{
return tabput_(tab, what, value, m, k);
}
int tabpti_(int *tab, const int *what, const int *value, const int *m,
const int *k)
{
return tabput_(tab, what, value, m, k);
}
/*--------------------------------------------------------------------------*/
int tabget_(const int *tab, const int *what, void *value)
{
int i, k, m, n;
int *ivalp;
double *dvalp;
const int *itabp;
const struct tabprm *tabp;
/* Cast pointers. */
tabp = (const struct tabprm *)tab;
ivalp = (int *)value;
dvalp = (double *)value;
switch (*what) {
case TAB_FLAG:
*ivalp = tabp->flag;
break;
case TAB_M:
*ivalp = tabp->M;
break;
case TAB_K:
for (m = 0; m < tabp->M; m++) {
*(ivalp++) = tabp->K[m];
}
break;
case TAB_MAP:
for (m = 0; m < tabp->M; m++) {
*(ivalp++) = tabp->map[m];
}
break;
case TAB_CRVAL:
for (m = 0; m < tabp->M; m++) {
*(dvalp++) = tabp->crval[m];
}
break;
case TAB_INDEX:
for (m = 0; m < tabp->M; m++) {
for (k = 0; k < tabp->K[m]; k++) {
*(dvalp++) = tabp->index[m][k];
}
}
break;
case TAB_COORD:
/* Don't rely on tabprm.nc being set. */
n = tabp->M;
for (m = 0; m < tabp->M; m++) {
n *= tabp->K[m];
}
for (i = 0; i < n; i++) {
*(dvalp++) = tabp->coord[i];
}
break;
case TAB_NC:
*ivalp = tabp->nc;
break;
case TAB_SENSE:
for (m = 0; m < tabp->M; m++) {
*(ivalp++) = tabp->sense[m];
}
break;
case TAB_P0:
for (m = 0; m < tabp->M; m++) {
*(ivalp++) = tabp->p0[m];
}
break;
case TAB_DELTA:
for (m = 0; m < tabp->M; m++) {
*(dvalp++) = tabp->delta[m];
}
break;
case TAB_EXTREMA:
n = 2 * tabp->M;
for (m = 1; m < tabp->M; m++) {
n *= tabp->K[m];
}
for (i = 0; i < n; i++) {
*(dvalp++) = tabp->extrema[i];
}
break;
case TAB_ERR:
/* Copy the contents of the wcserr struct. */
if (tabp->err) {
itabp = (int *)(tabp->err);
for (k = 0; k < ERRLEN; k++) {
*(ivalp++) = *(itabp++);
}
} else {
for (k = 0; k < ERRLEN; k++) {
*(ivalp++) = 0;
}
}
break;
default:
return 1;
}
return 0;
}
int tabgtd_(const int *tab, const int *what, double *value)
{
return tabget_(tab, what, value);
}
int tabgti_(const int *tab, const int *what, int *value)
{
return tabget_(tab, what, value);
}
/*--------------------------------------------------------------------------*/
int tabfree_(int *tab)
{
return tabfree((struct tabprm *)tab);
}
/*--------------------------------------------------------------------------*/
int tabprt_(const int *tab)
{
/* This may or may not force the Fortran I/O buffers to be flushed. If
* not, try CALL FLUSH(6) before calling TABPRT in the Fortran code. */
fflush(NULL);
return tabprt((const struct tabprm *)tab);
}
/*--------------------------------------------------------------------------*/
int tabset_(int *tab)
{
return tabset((struct tabprm *)tab);
}
/*--------------------------------------------------------------------------*/
int tabx2s_(
int *tab,
const int *ncoord,
const int *nelem,
const double x[],
double world[],
int stat[])
{
return tabx2s((struct tabprm *)tab, *ncoord, *nelem, x, world, stat);
}
/*--------------------------------------------------------------------------*/
int tabs2x_(
struct tabprm* tab,
const int *ncoord,
const int *nelem,
const double world[],
double x[],
int stat[])
{
return tabs2x((struct tabprm *)tab, *ncoord, *nelem, world, x, stat);
}
|