OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
kozsak2.f
Go to the documentation of this file.
1  SUBROUTINE kozsak2(IFLAG,GE,RE,AJ2,X,XN,XI,IER)
2 
3 C $Header: /app/shared/RCS/irix-5.2/seawifsd/src/mops/mopsV4.1/swfnav/kozsak2.f,v 1.1 1995/01/17 23:02:23 seawifsd Exp seawifsd $
4 C $Log: kozsak2.f,v $
5 C Revision 1.1 1995/01/17 23:02:23 seawifsd
6 C Initial revision
7 C
8 C VERSION 4/28/88
9 C PURPOSE
10 C CONVERTS BETWEEN MEAN AND OSCULATING ORBITAL ELEMENTS
11 C INPUT
12 C IFLAG = 1, MEAN TO OSCULATING
13 C = 2, OSCULATING TO MEAN
14 C = 3, OSCULATING TO MEAN WITH INITIAL GUESS FOR MEAN
15 C GE = PRODUCT OF GRAVITATIONAL CONSTANT * MASS OF
16 C PLANET (KM**3/SEC**2)
17 C RE = RADIUS OF PLANET (KM)
18 C AJ2 = J2 = -C20
19 C X = AN ARRAY OF 6 ORBITAL ELEMENTS, A, E, I, NODE, W, AND M
20 C (KM, RAD)
21 C XI = AN ARRAY OF 6 INITIAL MEAN ELEMENTS
22 C OUTPUT ARGUMENTS
23 C XN = AN ARRAY OF 6 ORBITAL ELEMENTS AFTER CONVERSION
24 C IER = ERROR FLAG (SET TO 1 IF OSCULATING-TO-MEAN CONVERSION
25 C DOES NOT CONVERGE)
26 C CALL SUBROUTINES
27 C DELM
28 C REFERENCES
29 C JPL IOM 312/85.2-927, 23 JANUARY 1985, BY C. UPHOFF
30 C JPL EM 312/87-153, 20 APRIL 1987
31 C ANALYSIS
32 C JOHNNY H. KWOK - JPL
33 C PROGRAMMER
34 C JOHNNY H. KWOK - JPL
35 C MODIFICATIONS
36 C ADDED OPTION TO INPUT INITIAL GUESS AT MEAN ELEMENTS FOR
37 C OSCULATING-TO-MEAN CONVERSION AND CONVERGENCE TEST FOR CONVERSION
38 C F.S. PATT, GSC, 29 NOVEMBER 1993
39 C
40 C CHANGED MAXIMUM NUMBER OF ITERATIONS TO 200 AND INITIALIZED ERROR
41 C RETURN CODE. F.S. PATT, GSC, OCTOBER 26, 1993
42 C
43 C COMMENTS
44 C THIS PROGRAM USES AN ALGORITHM DERIVED BY C. UPHOFF (REF) WHICH
45 C USES A COMBINATION OF KOZAI'S AND IZSAK'S THEORY.
46 C
47  IMPLICIT DOUBLE PRECISION (a-h,o-z)
48  dimension x(6),xn(6),xi(6),dx(6),xtol(6)
49  LOGICAL DONE
50  DATA tpi/6.283185307179586d0/
51  DATA zero/0.d0/,rtol/1.d-6/
52  DATA xtol/1.d-5,1.d-8,2*1.d-7,2*1.d-5/
53  pi = tpi/2.d0
54  p3o2 = 3.d0*tpi/2.d0
55 C IMAX=5
56 C IF (X(2).LT.1.D-1) IMAX=10
57 C IF (X(2).LT.1.D-2) IMAX=20
58 C IF (X(2).LT.1.D-3) IMAX=30
59  imax = 200
60  ier = 0
61  IF (iflag.NE.3) THEN
62  DO i=1,6
63  xi(i)=x(i)
64  END DO
65  END IF
66  icount=0
67 c print *,' '
68 c print *,x
69  IF (iflag.GT.1) THEN
70  done = .false.
71  dowhile((.NOT.done).AND.(icount.LT.imax))
72  CALL delm(re,ge,aj2,xi,dx)
73  DO i=3,6
74  dx(i)=dmod(dx(i)+p3o2,tpi)-pi
75  END DO
76 c print *,dx
77  icount = icount + 1
78  fac = 0.5*(1.d0-abs(dx(5))/pi)
79  done = .true.
80  DO i=1,6
81  xdel = (x(i)-dx(i)-xi(i))
82  IF (i.GE.3) xdel = dmod(xdel+p3o2,tpi)-pi
83  rdel = xdel/dx(i)
84  IF ((abs(xdel).GT.xtol(i)).AND.(abs(rdel).GT.rtol))
85  * done = .false.
86  xn(i)=xi(i) + xdel*fac
87  END DO
88  IF (xn(2).LT.zero) xn(2)=zero
89 c DO 30 I=3,6
90 c 30 XN(I)=DMOD(XN(I)+TPI,TPI)
91  DO i=1,6
92  xi(i)=xn(i)
93  END DO
94  ENDDO
95  print *,'KOZSAK2: Mean elements converged in ',icount,
96  * ' iterations'
97  IF (icount.EQ.imax) ier = 1
98  ELSE
99  CALL delm(re,ge,aj2,xi,dx)
100  DO i=1,6
101  xn(i)=xi(i)+dx(i)
102  ENDDO
103  ENDIF
104  900 CONTINUE
105  DO i=3,6
106  xn(i)=dmod(xn(i)+tpi,tpi)
107  END DO
108  RETURN
109  END
subroutine kozsak2(IFLAG, GE, RE, AJ2, X, XN, XI, IER)
Definition: kozsak2.f:2
#define fac
#define re
Definition: l1_czcs_hdf.c:701
#define pi
Definition: vincenty.c:23
subroutine delm(RE, GE, AJ2, X, DX)
Definition: delm.f:2
#define abs(a)
Definition: misc.h:90