Skip to content

Instantly share code, notes, and snippets.

@fenrir-naru fenrir-naru/f477.c
Last active Sep 26, 2017

Embed
What would you like to do?
EGM96 Geoid Fortran to C
void main(){
double AR = AE / RE,
ARN = AR,
AC = 0.0,
A = 0.0,
B = 0.0;
int K = 3;
for(int N = 2; N <= NMAX; N++){ // DO 030 N=2,NMAX
ARN *= AR;
K++;
double SUM = P[K] * HC[K]; // HC from EGM96, M = 0
double SUMC = P[K] * CC[K]; // CC from CORRCOEF, M = 0
for(int M = 1; M <= N; M++){ // DO 020 M=1,N
K++;
SUM += P[K] * (HC[K] * COSML[M] + HS[K] * SINML[M]);
SUMC += P[K] * (CC[K] * COSML[M] + CS[K] * SINML[M]);
} // 20
A += SUM * ARN;
AC += SUMC;
} // 30
AC += CC[1] + (P[2] * CC[2]) + (P[3] * (CC[3] * COSML[1] + CS[3] * SINML[1])); // (n = 0, m = 0), (n = 1, m = 0/1)
UNDU = A * GM / (GR * RE);
// ADD HACO (=AC/100) TO CONVERT HEIGHT ANOMALY ON THE ELLIPSOID TO THE UNDULATION
// ADD -0.53M TO MAKE UNDULATION REFER TO THE WGS84 ELLIPSOID.
UNDU += (AC / 100.0E0) - 0.53E0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.