forked from scottransom/psrfits2psrfits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsla.c
1551 lines (1326 loc) · 41.1 KB
/
sla.c
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Name:
* sla.c
* Purpose:
* Implement a C interface to the Fortran SLALIB library.
* Description:
* This file implements a C interface to the Fortran version of the
* SLALIB library.
* Notes:
* This interface only supports a subset of the functions provided by
* SLALIB. It should be extended as and when necessary.
* Copyright:
* Copyright (C) 2006 Council for the Central Laboratory of the
* Research Councils
* Licence:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public Licence as
* published by the Free Software Foundation; either version 2 of
* the Licence, or (at your option) any later version.
*
* This program 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 General Public Licence for more details.
*
* You should have received a copy of the GNU General Public Licence
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place,Suite 330, Boston, MA
* 02111-1307, USA
* Authors:
* RFWS: R.F. Warren-Smith (STARLINK)
* DSB: David S. Berry (STARLINK)
* TIMJ: Tim Jenness (JAC, Hawaii)
* History:
* 12-NOV-1996 (RFWS):
* Original version.
* 28-APR-1997 (RFWS):
* Added SLA_DJCAL.
* 26-SEP-1997 (DSB):
* Added SLA_DD2TF, SLA_DJCL.
* 21-JUN-2001 (DSB):
* Added SLA_DBEAR, SLA_DVDV.
* 23-AUG-2001 (DSB):
* Added SLA_SVD and SLA_SVDSOL
* 11-NOV-2002 (DSB):
* Added SLA_RVEROT, SLA_GMST, SLA_EQEQX, SLA_RVLSRK, SLA_RVLSRD,
* SLA_RVLG, SLA_RVGALC.
* 11-JUN-2003 (DSB):
* Added SLA_GEOC, SLA_HFK5Z and SLA_FK5HZ.
* 2-DEC-2004 (DSB):
* Added SLA_DEULER.
* 29-SEP-2005 (DSB):
* Added SLA_DE2H and SLA_DH2E
* 12-JUN-2006 (DSB):
* Moved from AST to SLALIB.
* 25-JUN-2006 (TIMJ):
* Add SLA_AIRMAS.
* 07-AUG-2006 (TIMJ):
* Import cnfImprt from CNF.
* Add SLA_OBS
* 08-AUG-2006 (TIMJ):
* Add SLA_PA
* 12-DEC-2006 (TIMJ):
* Add SLA_DTT and SLA_DAT
* 21-DEC-2006 (TIMJ):
* Add SLA_RDPLAN
*-
*/
/* Header files. */
/* ============= */
#include "f77.h" /* FORTRAN <-> C interface macros (SUN/209) */
#include "slalib.h" /* Prototypes for C SLALIB functions */
#include <stdlib.h> /* Malloc etc */
#include <string.h> /* string manipulation */
/* Functions needed to avoid a dependence on CNF. */
/* ============================================== */
static void slaStringExport(const char *, char *, int);
static void slaStringImport(const char *source_f, int source_len, char *dest_c);
static void slaStringExport(const char *source_c, char *dest_f, int dest_len)
{
/*
*+
* Name:
* slaStringExport
* Purpose:
* Export a C string to a FORTRAN string.
* Type:
* Protected function.
* Synopsis:
* void slaStringExport( const char *source_c, char *dest_f, int dest_len )
* Description:
* This function creates a FORTRAN string from a C string, storing
* it in the supplied memory. If the C string is shorter than the
* space allocated for the FORTRAN string, then it is padded with
* blanks. If the C string is longer than the space allocated for
* the FORTRAN string, then the string is truncated.
* Parameters:
* source_c
* A pointer to the input C string.
* dest_f
* A pointer to the output FORTRAN string.
* dest_len
* The length of the output FORTRAN string.
* Notes:
* - This function is potentially platform-specific. For example,
* if FORTRAN strings were passed by descriptor, then the
* descriptor address would be passed as "dest_f" and this must
* then be used to locate the actual FORTRAN character data.
* - This function is equivalent to cnfExprt but is included here to
* avoid SLALIB becoming dependent on CNF.
*-
*/
/* Local Variables:*/
int i; /* Loop counter for characters */
/* Check the supplied pointers. */
if (!source_c || !dest_f)
return;
/* Copy the characters of the input C string to the output FORTRAN
string, taking care not to go beyond the end of the FORTRAN
string.*/
for (i = 0; source_c[i] && (i < dest_len); i++) {
dest_f[i] = source_c[i];
}
/* Fill the rest of the output FORTRAN string with blanks. */
for (; i < dest_len; i++)
dest_f[i] = ' ';
}
void slaStringImport(const char *source_f, int source_len, char *dest_c)
/*
*+
* Name:
* slaStringImportt
* Purpose:
* Import a FORTRAN string into a C string
* Type:
* Protected function.
* Language:
* ANSI C
* Invocation:
* slaStringImport( source_f, source_len, dest_c )
* Description:
* Import a FORTRAN string into a C string, discarding trailing
* blanks. The NUL character is appended to the C string after
* the last non-blank character. The input string and output string
* pointers can point to the same location if the string is to be
* modified in place (but care must be taken to allow for the additional
* C terminator when allocating memory).
* Arguments:
* const char *source_f (Given)
* A pointer to the input FORTRAN string
* int source_len (Given)
* The length of the input FORTRAN string
* char *dest_c (Returned via pointer)
* A pointer to the output C string. Can be same as source.
* Notes:
* - No check is made that there is sufficient space allocated to
* the C string to hold the FORTRAN string and a terminating null.
* It is responsibility of the programmer to check this.
* - This function is equivalent to cnfImprt but is included here to
* avoid SLALIB becoming dependent on CNF.
* Authors:
* PMA: Peter Allan (Starlink, RAL)
* AJC: Alan Chipperfield (Starlink, RAL)
* TIMJ: Tim Jenness (JAC, Hawaii)
* {enter_new_authors_here}
* History:
* 27-MAR-1991 (PMA):
* Original version.
* 22-MAY-1996 (AJC):
* Correct description re trailing blanks
* 24-SEP-1998 (AJC):
* Specify const char * for input strings
* 25-NOV-2005 (TIMJ):
* Allow the strings to be identical
* {enter_changes_here}
*-
*...........................................................................*/
{
/* Local Variables: */
int i; /* Loop counter */
/* Find the last non blank character in the input FORTRAN string. */
for (i = source_len - 1; (i >= 0) && (source_f[i] == ' '); i--);
/* Put a null character at the end of the output C string. */
dest_c[i + 1] = '\0';
/* Copy the characters from the input FORTRAN string to the output C */
/* string if the strings are different. */
if (dest_c != source_f) {
memmove(dest_c, source_f, (size_t) i + 1);
}
}
/* SLALIB wrapper implementations. */
/* =============================== */
/* Fortran routine prototype. */
F77_SUBROUTINE(sla_addet) (DOUBLE(RM),
DOUBLE(DM), DOUBLE(EQ), DOUBLE(RC), DOUBLE(DC));
/* C interface implementation. */
void slaAddet(double rm, double dm, double eq, double *rc, double *dc)
{
DECLARE_DOUBLE(RM);
DECLARE_DOUBLE(DM);
DECLARE_DOUBLE(EQ);
DECLARE_DOUBLE(RC);
DECLARE_DOUBLE(DC);
RM = rm;
DM = dm;
EQ = eq;
F77_CALL(sla_addet) (DOUBLE_ARG(&RM),
DOUBLE_ARG(&DM),
DOUBLE_ARG(&EQ), DOUBLE_ARG(&RC), DOUBLE_ARG(&DC));
*rc = RC;
*dc = DC;
}
/* etc... */
F77_SUBROUTINE(sla_ampqk) (DOUBLE(RA),
DOUBLE(DA), DOUBLE_ARRAY(AMPRMS), DOUBLE(RM), DOUBLE(DM));
void slaAmpqk(double ra, double da, double amprms[21], double *rm, double *dm)
{
DECLARE_DOUBLE(RA);
DECLARE_DOUBLE(DA);
DECLARE_DOUBLE_ARRAY(AMPRMS, 21);
DECLARE_DOUBLE(RM);
DECLARE_DOUBLE(DM);
int i;
RA = ra;
DA = da;
for (i = 0; i < 21; i++)
AMPRMS[i] = amprms[i];
F77_CALL(sla_ampqk) (DOUBLE_ARG(&RA),
DOUBLE_ARG(&DA),
DOUBLE_ARRAY_ARG(AMPRMS), DOUBLE_ARG(&RM), DOUBLE_ARG(&DM));
*rm = RM;
*dm = DM;
}
F77_DOUBLE_FUNCTION(sla_airmas) (DOUBLE(ZD));
double slaAirmas(double zd)
{
DECLARE_DOUBLE(ZD);
double result;
ZD = zd;
result = F77_CALL(sla_airmas) (DOUBLE_ARG(&ZD));
return result;
}
F77_SUBROUTINE(sla_caldj) (INTEGER(IY),
INTEGER(IM), INTEGER(ID), DOUBLE(DJM), INTEGER(J));
void slaCaldj(int iy, int im, int id, double *djm, int *j)
{
DECLARE_INTEGER(IY);
DECLARE_INTEGER(IM);
DECLARE_INTEGER(ID);
DECLARE_DOUBLE(DJM);
DECLARE_INTEGER(J);
IY = iy;
IM = im;
ID = id;
F77_CALL(sla_caldj) (INTEGER_ARG(&IY),
INTEGER_ARG(&IM),
INTEGER_ARG(&ID), DOUBLE_ARG(&DJM), INTEGER_ARG(&J));
*djm = DJM;
*j = J;
}
F77_SUBROUTINE(sla_daf2r) (INTEGER(IDEG),
INTEGER(IAMIN), DOUBLE(ASEC), DOUBLE(RAD), INTEGER(J));
void slaDaf2r(int ideg, int iamin, double asec, double *rad, int *j)
{
DECLARE_INTEGER(IDEG);
DECLARE_INTEGER(IAMIN);
DECLARE_DOUBLE(ASEC);
DECLARE_DOUBLE(RAD);
DECLARE_INTEGER(J);
IDEG = ideg;
IAMIN = iamin;
ASEC = asec;
F77_CALL(sla_daf2r) (INTEGER_ARG(&IDEG),
INTEGER_ARG(&IAMIN),
DOUBLE_ARG(&ASEC), DOUBLE_ARG(&RAD), INTEGER_ARG(&J));
*rad = RAD;
*j = J;
}
F77_SUBROUTINE(sla_dav2m) (DOUBLE_ARRAY(AXVEC), DOUBLE_ARRAY(RMAT));
void slaDav2m(double axvec[3], double rmat[3][3])
{
DECLARE_DOUBLE_ARRAY(AXVEC, 3);
DECLARE_DOUBLE_ARRAY(RMAT, 9);
int i;
int j;
for (i = 0; i < 3; i++)
AXVEC[i] = axvec[i];
F77_CALL(sla_dav2m) (DOUBLE_ARRAY_ARG(AXVEC), DOUBLE_ARRAY_ARG(RMAT));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
rmat[i][j] = RMAT[i + 3 * j];
}
}
F77_SUBROUTINE(sla_dcc2s) (DOUBLE_ARRAY(V), DOUBLE(A), DOUBLE(B));
void slaDcc2s(double v[3], double *a, double *b)
{
DECLARE_DOUBLE_ARRAY(V, 3);
DECLARE_DOUBLE(A);
DECLARE_DOUBLE(B);
int i;
for (i = 0; i < 3; i++)
V[i] = v[i];
F77_CALL(sla_dcc2s) (DOUBLE_ARRAY_ARG(V), DOUBLE_ARG(&A), DOUBLE_ARG(&B));
*a = A;
*b = B;
}
F77_SUBROUTINE(sla_dcs2c) (DOUBLE(A), DOUBLE(B), DOUBLE_ARRAY(V));
void slaDcs2c(double a, double b, double v[3])
{
DECLARE_DOUBLE(A);
DECLARE_DOUBLE(B);
DECLARE_DOUBLE_ARRAY(V, 3);
int i;
A = a;
B = b;
F77_CALL(sla_dcs2c) (DOUBLE_ARG(&A), DOUBLE_ARG(&B), DOUBLE_ARRAY_ARG(V));
for (i = 0; i < 3; i++)
v[i] = V[i];
}
F77_SUBROUTINE(sla_dd2tf) (INTEGER(NDP),
DOUBLE(DAYS), CHARACTER(SIGN), INTEGER_ARRAY(IHMSF)
TRAIL(SIGN));
void slaDd2tf(int ndp, double days, char *sign, int ihmsf[4])
{
DECLARE_INTEGER(NDP);
DECLARE_DOUBLE(DAYS);
DECLARE_CHARACTER(SIGN, 2);
DECLARE_INTEGER_ARRAY(IHMSF, 4);
int i;
NDP = ndp;
DAYS = days;
F77_CALL(sla_dd2tf) (INTEGER_ARG(&NDP),
DOUBLE_ARG(&DAYS),
CHARACTER_ARG(SIGN), INTEGER_ARRAY_ARG(IHMSF)
TRAIL_ARG(SIGN));
sign[0] = SIGN[0];
sign[1] = 0;
for (i = 0; i < 4; i++)
ihmsf[i] = IHMSF[i];
}
F77_SUBROUTINE(sla_dimxv) (DOUBLE_ARRAY(DM), DOUBLE_ARRAY(VA), DOUBLE_ARRAY(VB));
void slaDimxv(double dm[3][3], double va[3], double vb[3])
{
DECLARE_DOUBLE_ARRAY(DM, 9);
DECLARE_DOUBLE_ARRAY(VA, 3);
DECLARE_DOUBLE_ARRAY(VB, 3);
int i;
int j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
DM[i + j * 3] = dm[i][j];
VA[i] = va[i];
}
F77_CALL(sla_dimxv) (DOUBLE_ARRAY_ARG(DM),
DOUBLE_ARRAY_ARG(VA), DOUBLE_ARRAY_ARG(VB));
for (i = 0; i < 3; i++)
vb[i] = VB[i];
}
F77_SUBROUTINE(sla_djcal) (INTEGER(NDP),
DOUBLE(DJM), INTEGER_ARRAY(IYMDF), INTEGER(J));
void slaDjcal(int ndp, double djm, int iymdf[4], int *j)
{
DECLARE_INTEGER(NDP);
DECLARE_DOUBLE(DJM);
DECLARE_INTEGER_ARRAY(IYMDF, 4);
DECLARE_INTEGER(J);
int i;
NDP = ndp;
DJM = djm;
F77_CALL(sla_djcal) (INTEGER_ARG(&NDP),
DOUBLE_ARG(&DJM),
INTEGER_ARRAY_ARG(IYMDF), INTEGER_ARG(&J));
for (i = 0; i < 4; i++)
iymdf[i] = IYMDF[i];
*j = J;
}
F77_SUBROUTINE(sla_djcl) (DOUBLE(DJM),
INTEGER(IY),
INTEGER(IM), INTEGER(ID), DOUBLE(FD), INTEGER(J));
void slaDjcl(double djm, int *iy, int *im, int *id, double *fd, int *j)
{
DECLARE_DOUBLE(DJM);
DECLARE_INTEGER(IY);
DECLARE_INTEGER(IM);
DECLARE_INTEGER(ID);
DECLARE_DOUBLE(FD);
DECLARE_INTEGER(J);
DJM = djm;
F77_CALL(sla_djcl) (DOUBLE_ARG(&DJM),
INTEGER_ARG(&IY),
INTEGER_ARG(&IM),
INTEGER_ARG(&ID), DOUBLE_ARG(&FD), INTEGER_ARG(&J));
*iy = IY;
*im = IM;
*id = ID;
*fd = FD;
*j = J;
}
F77_SUBROUTINE(sla_dmat) (INTEGER(N),
DOUBLE_ARRAY(A),
DOUBLE_ARRAY(Y),
DOUBLE(D), INTEGER(JF), INTEGER_ARRAY(IW));
void slaDmat(int n, double *a, double *y, double *d, int *jf, int *iw)
{
DECLARE_INTEGER(N);
F77_DOUBLE_TYPE *A;
F77_DOUBLE_TYPE *Y;
DECLARE_DOUBLE(D);
DECLARE_INTEGER(JF);
F77_INTEGER_TYPE *IW;
int i;
int j;
A = malloc(sizeof(F77_DOUBLE_TYPE) * (size_t) (n * n));
Y = malloc(sizeof(F77_DOUBLE_TYPE) * (size_t) n);
if (sizeof(F77_INTEGER_TYPE) > sizeof(int)) {
IW = malloc(sizeof(F77_INTEGER_TYPE) * (size_t) n);
} else {
IW = (F77_INTEGER_TYPE *) iw;
}
if (IW) {
N = n;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
A[i + n * j] = a[n * i + j];
Y[i] = y[i];
}
F77_CALL(sla_dmat) (INTEGER_ARG(&N), DOUBLE_ARRAY_ARG(A),
DOUBLE_ARRAY_ARG(Y), DOUBLE_ARG(&D),
INTEGER_ARG(&JF), INTEGER_ARG(IW));
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
a[n * i + j] = A[i + n * j];
y[i] = Y[i];
}
*d = D;
*jf = JF;
}
free(A);
free(Y);
if (sizeof(F77_INTEGER_TYPE) > sizeof(int))
free(IW);
}
F77_SUBROUTINE(sla_dmxm) (DOUBLE_ARRAY(A), DOUBLE_ARRAY(B), DOUBLE_ARRAY(C));
void slaDmxm(double a[3][3], double b[3][3], double c[3][3])
{
DECLARE_DOUBLE_ARRAY(A, 9);
DECLARE_DOUBLE_ARRAY(B, 9);
DECLARE_DOUBLE_ARRAY(C, 9);
int i;
int j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
A[i + 3 * j] = a[i][j];
B[i + 3 * j] = b[i][j];
}
}
F77_CALL(sla_dmxm) (DOUBLE_ARRAY_ARG(A),
DOUBLE_ARRAY_ARG(B), DOUBLE_ARRAY_ARG(C));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
c[i][j] = C[i + 3 * j];
}
}
F77_SUBROUTINE(sla_dmxv) (DOUBLE_ARRAY(DM), DOUBLE_ARRAY(VA), DOUBLE_ARRAY(VB));
void slaDmxv(double dm[3][3], double va[3], double vb[3])
{
DECLARE_DOUBLE_ARRAY(DM, 9);
DECLARE_DOUBLE_ARRAY(VA, 3);
DECLARE_DOUBLE_ARRAY(VB, 3);
int i;
int j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
DM[i + 3 * j] = dm[i][j];
VA[i] = va[i];
}
F77_CALL(sla_dmxv) (DOUBLE_ARRAY_ARG(DM),
DOUBLE_ARRAY_ARG(VA), DOUBLE_ARRAY_ARG(VB));
for (i = 0; i < 3; i++)
vb[i] = VB[i];
}
F77_DOUBLE_FUNCTION(sla_dbear) (DOUBLE(A1), DOUBLE(B1), DOUBLE(A2), DOUBLE(B2));
double slaDbear(double a1, double b1, double a2, double b2)
{
DECLARE_DOUBLE(A1);
DECLARE_DOUBLE(B1);
DECLARE_DOUBLE(A2);
DECLARE_DOUBLE(B2);
double result;
A1 = a1;
B1 = b1;
A2 = a2;
B2 = b2;
result = F77_CALL(sla_dbear) (DOUBLE_ARG(&A1), DOUBLE_ARG(&B1),
DOUBLE_ARG(&A2), DOUBLE_ARG(&B2));
return result;
}
F77_DOUBLE_FUNCTION(sla_drange) (DOUBLE(ANGLE));
double slaDrange(double angle)
{
DECLARE_DOUBLE(ANGLE);
double result;
ANGLE = angle;
result = F77_CALL(sla_drange) (DOUBLE_ARG(&ANGLE));
return result;
}
F77_DOUBLE_FUNCTION(sla_dranrm) (DOUBLE(ANGLE));
double slaDranrm(double angle)
{
DECLARE_DOUBLE(ANGLE);
double result;
ANGLE = angle;
result = F77_CALL(sla_dranrm) (DOUBLE_ARG(&ANGLE));
return result;
}
F77_DOUBLE_FUNCTION(sla_dsep) (DOUBLE(A1), DOUBLE(B1), DOUBLE(A2), DOUBLE(B2));
double slaDsep(double a1, double b1, double a2, double b2)
{
DECLARE_DOUBLE(A1);
DECLARE_DOUBLE(B1);
DECLARE_DOUBLE(A2);
DECLARE_DOUBLE(B2);
double result;
A1 = a1;
B1 = b1;
A2 = a2;
B2 = b2;
result = F77_CALL(sla_dsep) (DOUBLE_ARG(&A1),
DOUBLE_ARG(&B1), DOUBLE_ARG(&A2), DOUBLE_ARG(&B2));
return result;
}
F77_DOUBLE_FUNCTION(sla_dvdv) (DOUBLE_ARRAY(VA), DOUBLE_ARRAY(VB));
double slaDvdv(double va[3], double vb[3])
{
DECLARE_DOUBLE_ARRAY(VA, 3);
DECLARE_DOUBLE_ARRAY(VB, 3);
double result;
int i;
for (i = 0; i < 3; i++) {
VA[i] = va[i];
VB[i] = vb[i];
}
result = F77_CALL(sla_dvdv) (DOUBLE_ARRAY_ARG(VA), DOUBLE_ARRAY_ARG(VB));
return result;
}
F77_SUBROUTINE(sla_dtf2d) (INTEGER(IHOUR),
INTEGER(IMIN), DOUBLE(SEC), DOUBLE(DAYS), INTEGER(J));
void slaDtf2d(int ihour, int imin, double sec, double *days, int *j)
{
DECLARE_INTEGER(IHOUR);
DECLARE_INTEGER(IMIN);
DECLARE_DOUBLE(SEC);
DECLARE_DOUBLE(DAYS);
DECLARE_INTEGER(J);
IHOUR = ihour;
IMIN = imin;
SEC = sec;
F77_CALL(sla_dtf2d) (INTEGER_ARG(&IHOUR),
INTEGER_ARG(&IMIN),
DOUBLE_ARG(&SEC), DOUBLE_ARG(&DAYS), INTEGER_ARG(&J));
*days = DAYS;
*j = J;
}
F77_SUBROUTINE(sla_dtf2r) (INTEGER(IHOUR),
INTEGER(IMIN), DOUBLE(SEC), DOUBLE(RAD), INTEGER(J));
void slaDtf2r(int ihour, int imin, double sec, double *rad, int *j)
{
DECLARE_INTEGER(IHOUR);
DECLARE_INTEGER(IMIN);
DECLARE_DOUBLE(SEC);
DECLARE_DOUBLE(RAD);
DECLARE_INTEGER(J);
IHOUR = ihour;
IMIN = imin;
SEC = sec;
F77_CALL(sla_dtf2r) (INTEGER_ARG(&IHOUR),
INTEGER_ARG(&IMIN),
DOUBLE_ARG(&SEC), DOUBLE_ARG(&RAD), INTEGER_ARG(&J));
*rad = RAD;
*j = J;
}
F77_DOUBLE_FUNCTION(sla_dt) (DOUBLE(EPOCH));
double slaDt(double epoch)
{
DECLARE_DOUBLE(EPOCH);
double result;
EPOCH = epoch;
result = F77_CALL(sla_dt) (DOUBLE_ARG(&EPOCH));
return result;
}
F77_SUBROUTINE(sla_dvn) (DOUBLE_ARRAY(V), DOUBLE_ARRAY(UV), DOUBLE(VM));
void slaDvn(double v[3], double uv[3], double *vm)
{
DECLARE_DOUBLE_ARRAY(V, 3);
DECLARE_DOUBLE_ARRAY(UV, 3);
DECLARE_DOUBLE(VM);
int i;
for (i = 0; i < 3; i++)
V[i] = v[i];
F77_CALL(sla_dvn) (DOUBLE_ARRAY_ARG(V), DOUBLE_ARRAY_ARG(UV), DOUBLE_ARG(&VM));
for (i = 0; i < 3; i++)
uv[i] = UV[i];
*vm = VM;
}
F77_SUBROUTINE(sla_dvxv) (DOUBLE_ARRAY(VA), DOUBLE_ARRAY(VB), DOUBLE_ARRAY(VC));
void slaDvxv(double va[3], double vb[3], double vc[3])
{
DECLARE_DOUBLE_ARRAY(VA, 3);
DECLARE_DOUBLE_ARRAY(VB, 3);
DECLARE_DOUBLE_ARRAY(VC, 3);
int i;
for (i = 0; i < 3; i++) {
VA[i] = va[i];
VB[i] = vb[i];
}
F77_CALL(sla_dvxv) (DOUBLE_ARRAY_ARG(VA),
DOUBLE_ARRAY_ARG(VB), DOUBLE_ARRAY_ARG(VC));
for (i = 0; i < 3; i++)
vc[i] = VC[i];
}
F77_SUBROUTINE(sla_ecmat) (DOUBLE(DATE), DOUBLE_ARRAY(RMAT));
void slaEcmat(double date, double rmat[3][3])
{
DECLARE_DOUBLE(DATE);
DECLARE_DOUBLE_ARRAY(RMAT, 9);
int i;
int j;
DATE = date;
F77_CALL(sla_ecmat) (DOUBLE_ARG(&DATE), DOUBLE_ARRAY_ARG(RMAT));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
rmat[i][j] = RMAT[i + 3 * j];
}
}
F77_DOUBLE_FUNCTION(sla_epb) (DOUBLE(DATE));
double slaEpb(double date)
{
DECLARE_DOUBLE(DATE);
double result;
DATE = date;
result = F77_CALL(sla_epb) (DOUBLE_ARG(&DATE));
return result;
}
F77_DOUBLE_FUNCTION(sla_epb2d) (DOUBLE(EPB));
double slaEpb2d(double epb)
{
DECLARE_DOUBLE(EPB);
double result;
EPB = epb;
result = F77_CALL(sla_epb2d) (DOUBLE_ARG(&EPB));
return result;
}
F77_DOUBLE_FUNCTION(sla_epj) (DOUBLE(DATE));
double slaEpj(double date)
{
DECLARE_DOUBLE(DATE);
double result;
DATE = date;
result = F77_CALL(sla_epj) (DOUBLE_ARG(&DATE));
return result;
}
F77_DOUBLE_FUNCTION(sla_epj2d) (DOUBLE(EPJ));
double slaEpj2d(double epj)
{
DECLARE_DOUBLE(EPJ);
double result;
EPJ = epj;
result = F77_CALL(sla_epj2d) (DOUBLE_ARG(&EPJ));
return result;
}
F77_DOUBLE_FUNCTION(sla_eqeqx) (DOUBLE(DATE));
double slaEqeqx(double date)
{
DECLARE_DOUBLE(DATE);
double result;
DATE = date;
result = F77_CALL(sla_eqeqx) (DOUBLE_ARG(&DATE));
return result;
}
F77_SUBROUTINE(sla_eqgal) (DOUBLE(DR), DOUBLE(DD), DOUBLE(DL), DOUBLE(DB));
void slaEqgal(double dr, double dd, double *dl, double *db)
{
DECLARE_DOUBLE(DR);
DECLARE_DOUBLE(DD);
DECLARE_DOUBLE(DL);
DECLARE_DOUBLE(DB);
DR = dr;
DD = dd;
F77_CALL(sla_eqgal) (DOUBLE_ARG(&DR),
DOUBLE_ARG(&DD), DOUBLE_ARG(&DL), DOUBLE_ARG(&DB));
*dl = DL;
*db = DB;
}
F77_SUBROUTINE(sla_fk45z) (DOUBLE(R1950),
DOUBLE(D1950),
DOUBLE(BEPOCH), DOUBLE(R2000), DOUBLE(D2000));
void slaFk45z(double r1950, double d1950, double bepoch,
double *r2000, double *d2000)
{
DECLARE_DOUBLE(R1950);
DECLARE_DOUBLE(D1950);
DECLARE_DOUBLE(BEPOCH);
DECLARE_DOUBLE(R2000);
DECLARE_DOUBLE(D2000);
R1950 = r1950;
D1950 = d1950;
BEPOCH = bepoch;
F77_CALL(sla_fk45z) (DOUBLE_ARG(&R1950),
DOUBLE_ARG(&D1950),
DOUBLE_ARG(&BEPOCH),
DOUBLE_ARG(&R2000), DOUBLE_ARG(&D2000));
*r2000 = R2000;
*d2000 = D2000;
}
F77_SUBROUTINE(sla_fk54z) (DOUBLE(R2000),
DOUBLE(D2000),
DOUBLE(BEPOCH),
DOUBLE(R1950),
DOUBLE(D1950), DOUBLE(DR1950), DOUBLE(DD1950));
void slaFk54z(double r2000, double d2000, double bepoch,
double *r1950, double *d1950, double *dr1950, double *dd1950)
{
DECLARE_DOUBLE(R2000);
DECLARE_DOUBLE(D2000);
DECLARE_DOUBLE(BEPOCH);
DECLARE_DOUBLE(R1950);
DECLARE_DOUBLE(D1950);
DECLARE_DOUBLE(DR1950);
DECLARE_DOUBLE(DD1950);
R2000 = r2000;
D2000 = d2000;
BEPOCH = bepoch;
F77_CALL(sla_fk54z) (DOUBLE_ARG(&R2000),
DOUBLE_ARG(&D2000),
DOUBLE_ARG(&BEPOCH),
DOUBLE_ARG(&R1950),
DOUBLE_ARG(&D1950),
DOUBLE_ARG(&DR1950), DOUBLE_ARG(&DD1950));
*r1950 = R1950;
*d1950 = D1950;
*dr1950 = DR1950;
*dd1950 = DD1950;
}
F77_SUBROUTINE(sla_galeq) (DOUBLE(DL), DOUBLE(DB), DOUBLE(DR), DOUBLE(DD));
void slaGaleq(double dl, double db, double *dr, double *dd)
{
DECLARE_DOUBLE(DL);
DECLARE_DOUBLE(DB);
DECLARE_DOUBLE(DR);
DECLARE_DOUBLE(DD);
DL = dl;
DB = db;
F77_CALL(sla_galeq) (DOUBLE_ARG(&DL),
DOUBLE_ARG(&DB), DOUBLE_ARG(&DR), DOUBLE_ARG(&DD));
*dr = DR;
*dd = DD;
}
F77_SUBROUTINE(sla_galsup) (DOUBLE(DL), DOUBLE(DB), DOUBLE(DSL), DOUBLE(DSB));
void slaGalsup(double dl, double db, double *dsl, double *dsb)
{
DECLARE_DOUBLE(DL);
DECLARE_DOUBLE(DB);
DECLARE_DOUBLE(DSL);
DECLARE_DOUBLE(DSB);
DL = dl;
DB = db;
F77_CALL(sla_galsup) (DOUBLE_ARG(&DL),
DOUBLE_ARG(&DB), DOUBLE_ARG(&DSL), DOUBLE_ARG(&DSB));
*dsl = DSL;
*dsb = DSB;
}
F77_DOUBLE_FUNCTION(sla_gmst) (DOUBLE(UT1));
double slaGmst(double ut1)
{
DECLARE_DOUBLE(UT1);
double result;
UT1 = ut1;
result = F77_CALL(sla_gmst) (DOUBLE_ARG(&UT1));
return result;
}
F77_SUBROUTINE(sla_mappa) (DOUBLE(EQ), DOUBLE(DATE), DOUBLE_ARRAY(AMPRMS));
void slaMappa(double eq, double date, double amprms[21])
{
DECLARE_DOUBLE(EQ);
DECLARE_DOUBLE(DATE);
DECLARE_DOUBLE_ARRAY(AMPRMS, 21);
int i;
EQ = eq;
DATE = date;
F77_CALL(sla_mappa) (DOUBLE_ARG(&EQ),
DOUBLE_ARG(&DATE), DOUBLE_ARRAY_ARG(AMPRMS));
for (i = 0; i < 21; i++)
amprms[i] = AMPRMS[i];
}
F77_SUBROUTINE(sla_mapqkz) (DOUBLE(RM),
DOUBLE(DM),
DOUBLE_ARRAY(AMPRMS), DOUBLE(RA), DOUBLE(DA));
void slaMapqkz(double rm, double dm, double amprms[21], double *ra, double *da)
{
DECLARE_DOUBLE(RM);
DECLARE_DOUBLE(DM);
DECLARE_DOUBLE_ARRAY(AMPRMS, 21);
DECLARE_DOUBLE(RA);
DECLARE_DOUBLE(DA);
int i;
RM = rm;
DM = dm;
for (i = 0; i < 21; i++)
AMPRMS[i] = amprms[i];
F77_CALL(sla_mapqkz) (DOUBLE_ARG(&RM),
DOUBLE_ARG(&DM),
DOUBLE_ARRAY_ARG(AMPRMS),
DOUBLE_ARG(&RA), DOUBLE_ARG(&DA));
*ra = RA;
*da = DA;
}
F77_SUBROUTINE(sla_prebn) (DOUBLE(BEP0), DOUBLE(BEP1), DOUBLE_ARRAY(RMATP));
void slaPrebn(double bep0, double bep1, double rmatp[3][3])
{
DECLARE_DOUBLE(BEP0);
DECLARE_DOUBLE(BEP1);
DECLARE_DOUBLE_ARRAY(RMATP, 9);
int i;
int j;
BEP0 = bep0;
BEP1 = bep1;
F77_CALL(sla_prebn) (DOUBLE_ARG(&BEP0),
DOUBLE_ARG(&BEP1), DOUBLE_ARRAY_ARG(RMATP));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
rmatp[i][j] = RMATP[i + 3 * j];
}
}
F77_SUBROUTINE(sla_prec) (DOUBLE(EP0), DOUBLE(EP1), DOUBLE_ARRAY(RMATP));
void slaPrec(double ep0, double ep1, double rmatp[3][3])
{
DECLARE_DOUBLE(EP0);
DECLARE_DOUBLE(EP1);
DECLARE_DOUBLE_ARRAY(RMATP, 9);
int i;
int j;
EP0 = ep0;
EP1 = ep1;
F77_CALL(sla_prec) (DOUBLE_ARG(&EP0), DOUBLE_ARG(&EP1), DOUBLE_ARRAY_ARG(RMATP));
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++)
rmatp[i][j] = RMATP[i + 3 * j];
}
}
F77_REAL_FUNCTION(sla_rverot) (REAL(PHI), REAL(RA), REAL(DEC), REAL(ST));
float slaRverot(float phi, float ra, float dec, float st)
{
DECLARE_REAL(PHI);
DECLARE_REAL(RA);
DECLARE_REAL(DEC);
DECLARE_REAL(ST);
float result;
PHI = phi;
RA = ra;
DEC = dec;
ST = st;
result = F77_CALL(sla_rverot) (REAL_ARG(&PHI),
REAL_ARG(&RA), REAL_ARG(&DEC), REAL_ARG(&ST));
return result;
}
F77_REAL_FUNCTION(sla_rvgalc) (REAL(RA), REAL(DEC));