function g = gravity(z) % This function determines gravity as a funtion of height from sea level. % It is in the SECOND ORDER stage of development. % VARIABLES and UNITS % % conventions: Large arrays are in all caps % Vectors and other variables are in mixed case, as appropriate % % r_earth :radius of the Earth constant, in m. % G :Earth's gravitational constant, in Nm2/kg2. % M :Mass of the Earth, in kg. % GM :G*M to ease the calc load of the computer, in Nm2/kg. global data; global index; % CONSTANTS r_earth = 6378140; % m G = 6.672E-11; % Nm2/kg2 M = 5976E24; % kg GM = 3.9871872E14; % Nm2/kg % MAIN PROGRAM g = -1 * GM / (r_earth + z)^2; % z down is negative in this coord system data(index,96) = g;