It is also known that at the perihelion, the distance between the planet and the Sun is shortest and its orbital speed is largest. Whereas at at the aphelion, the distance between the planet and the Sun is largest and its orbital speed is smallest.
Beginning one day, to be called day #0, and about every week thereafter, the scientist
records the day number (0, 1, 2, ...) and the x-y coordinates of the planet on a piece
of paper. After several years, it was decided to automate the analysis of the recorded
data and, hence, these pieces of paper were collected and entered, albeit not in order,
into a text file named: orbit.txt (you can download this file
by right-clicking its name and choosing to save it in the same directory in which you
will write the program for this Lab). Each record in the file contains three
real*8, space-delimitted numbers: the day number (not sorted), the
x-coordinate, and the y-coordinate (measured in kilometers).
For array declaration purposes, you can assume that the file has less than
a thousand records.
We need to analyze this data to determine certain orbital attributes. To that end, we follow the structured approach and divide the problem into subproblems and then write the following main program:
program orbit implicit none real*8 dayAR(1000), xAR(1000), yAR(1000) real*8 minMaxOrb(4), minMaxRad(4) real*8 min, max integer*4 lengthAR, maxSize /1000/, permute(1000) call loadFile(dayAR, xAR, yAR, lengthAR, maxSize) call sortMe(dayAR, xAR, yAR, permute, lengthAR) call radial(dayAR, xAR, yAR, lengthAR, minMaxRad) call orbital(dayAR, xAR, yAR, lengthAR, minMaxOrb, min, max) call showGeo(minMaxRad) call showGeo(minMaxOrb) call showPeriod(minMaxRad, min, max) endHere are descriptions (and hints) for each subprogram:
maxSizeis an input parameter (sent by the caller to the sub) to enable array declaration, whereas
lengthARis an output parameter (returned from the sub to the caller) to let the caller know the actual size of the arrays. The reading loop is terminated upon encountering end-of-file; i.e. when the integer*4 variable set by
IOSTAT = variablebecomes non-zero (the 3rd argument of the
readstatement). This can be implemented in ~20 lines.
SLATECto generate a sorted permutation (
permute) of it, and then using the
dpPermroutine to physically re-arrange the three arrays based on that permutation. This can be implemented in ~10 lines.
Angles of A, B, and of AB: 56.99 -120.28 58.85 Semi major axis (in M.km): 799.11where A refers to the first point and B to the second, as received from the caller in the 4-element array. Use the
atan2function to compute the angle given the x,y coordinate of a point; viz. atan2(y,x), and then convert to degrees. Note that main invokes this sub twice, once sending radial data and once orbital data. The two results should be close but may not be identical.
Minimum orbital speed (in km/sec) = xx.xx Maximum orbital speed (in km/sec) = xx.xx Planet's period (in Earth years) = xx.xx