diff --git a/libLanlGeoMag/Lgm/Lgm_IGRF.h b/libLanlGeoMag/Lgm/Lgm_IGRF.h index 2234db8c..00c1dbd4 100644 --- a/libLanlGeoMag/Lgm/Lgm_IGRF.h +++ b/libLanlGeoMag/Lgm/Lgm_IGRF.h @@ -29,8 +29,6 @@ static int IGRF_nModels = 26; static double IGRF_epoch[27] = { 1900.0, 1905.0, 1910.0, 1915.0, 1920.0, 1925.0, 1930.0, 1935.0, 1940.0, 1945.0, 1950.0, 1955.0, 1960.0, 1965.0, 1970.0, 1975.0, 1980.0, 1985.0, 1990.0, 1995.0, 2000.0, 2005.0, 2010.0, 2015.0, 2020.0, 2025.0 }; -static int IGRF_MaxN[27] = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 13, 13, 13 }; - static double IGRF_Re = 6371.2; // km This is the so-called "magnetic reference spherical radius" that is adopted in IGRF modeling static char IGRF_Model[] = "IGRF14"; static char IGRF_Model_Description[] = "14th Generation International Geomagnetic Reference Field"; diff --git a/libLanlGeoMag/Utils/fmt_igrf.c b/libLanlGeoMag/Utils/fmt_igrf.c index 1a414539..48c6d043 100644 --- a/libLanlGeoMag/Utils/fmt_igrf.c +++ b/libLanlGeoMag/Utils/fmt_igrf.c @@ -1,16 +1,12 @@ #include +#include #include #include #include - int NumberOfColumns( char *String ){ - - int n; - - /* * strip off trailing non-alpha-numeric characters... */ @@ -22,29 +18,21 @@ int NumberOfColumns( char *String ){ } } - n = 0; if ( strtok( String, " \t" ) == NULL ) return(0); else ++n; - while ( strtok( NULL, " \t" ) != NULL ){ ++n; } return( n ); - } - - -main(){ - - - +int main(){ char Line[4098], GaussType, ModelName[50][128]; double ModelYear[50]; char h1[2048], h2, h3; @@ -53,7 +41,6 @@ main(){ double g[50][14][14], h[50][14][14]; FILE *fpin, *fpout; - for (i=0; i<50; ++i){ for(n=0; n<13; ++n){ for(m=0; m<13; ++m){ @@ -62,19 +49,19 @@ main(){ } } - - // open txt file containing coefficients // fpin = fopen("igrf12coeffs.txt", "r"); fpin = fopen("igrf14coeffs.txt", "r"); - // read off header - fgets(Line, 4096, fpin); - printf("Line = %s\n", Line); + // read off header (two comment lines, two header lines) + for (int hl=0; hl<4; hl++) { + fgets(Line, 4096, fpin); + printf("Line = %s\n", Line); + } // read in a line of data (as opposed to the header -- better indicator of whats really here fgets(Line, 4096, fpin); - printf("Line = %s\n", Line); + printf("Data Line = %s\n", Line); nColumns = NumberOfColumns( Line ); printf("Columns = %d\n", nColumns); @@ -82,8 +69,12 @@ main(){ nModels = nColumns - 4; // there are 3 colums at start defining coeff, plus SV at the end. printf("nModels = %d\n", nModels); - - rewind(fpin); + rewind(fpin); // rewind to start of filee + // read off header + for (int hl=0; hl<3; hl++) { + fgets(Line, 4096, fpin); + printf("Line = %s\n", Line); + } fscanf(fpin, "%s %c %c", h1, &h2, &h3); for (i=0; i