Skip to content

Commit

Permalink
Merge pull request #316 from aodn/2.5.3
Browse files Browse the repository at this point in the history
2.5.3
  • Loading branch information
ggalibert committed Feb 18, 2016
2 parents 9f01aa9 + 76142ff commit 5cc77db
Show file tree
Hide file tree
Showing 16 changed files with 6,772 additions and 22 deletions.
31 changes: 14 additions & 17 deletions Geomag/geomag70.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
/****************************************************************************/
/* */
/* NGDC's Geomagnetic Field Modeling software for the IGRF and WMM */
/* NGDC's Geomagnetic Field Modelling software for the IGRF and WMM */
/* */
/****************************************************************************/
/* */
/* Disclaimer: This program has undergone limited testing. It is */
/* being distributed unoffically. The National Geophysical Data */
/* being distributed unofficially. The National Geophysical Data */
/* Center does not guarantee it's correctness. */
/* */
/****************************************************************************/
/* */
/* Version 7.01: */
/* - paths originally limited to 95 characters have been extended to OS */
/* MAX_PATH if exist (windows) or 1024 */
/* */
/* IMOS toolbox Nov-26-2015 */
/* */
/****************************************************************************/
/* */
/* Version 7.0: */
/* - input file format changed to */
/* -- accept new DGRF2005 coeffs with 0.01 nT precision */
/* -- make sure all values are separated by blanks */
/* -- swapped n and m: first is degree, second is order */
/* - new my_isnan function improves portablility */
/* - new my_isnan function improves portability */
/* - corrected feet to km conversion factor */
/* - fixed date conversion errors for yyyy,mm,dd format */
/* - fixed lon/lat conversion errors for deg,min,sec format */
Expand Down Expand Up @@ -130,7 +138,7 @@ int my_isnan(double d)
#define IEXT 0
#define FALSE 0
#define TRUE 1 /* constants */
#define RECL 80
#define RECL 81

#ifndef MAX_PATH
#define MAX_PATH 1024
Expand Down Expand Up @@ -276,7 +284,6 @@ FILE *stream = NULL; /* Pointer to specified model data file */
/* */
/****************************************************************************/


int main(int argc, char**argv)
{
#ifdef MAC
Expand Down Expand Up @@ -388,7 +395,7 @@ int main(int argc, char**argv)
strncpy(args[iarg],argv[iarg],MAXREAD);

/* printing out version number and header */
printf("\n\n Geomag v7.02 - Nov 30, 2015 ");
printf("\n\n Geomag v7.01 - Nov 26, 2015 ");

if ((argc==2)&&((*(args[1])=='h')||(*(args[1])=='?')||(args[1][1]=='?')))
{
Expand Down Expand Up @@ -464,14 +471,7 @@ int main(int argc, char**argv)
if (coords_from_file)
{
argc = 7;
char av[7][128];
int k;
for(k=2;k<argc;k++)
{
av[k][0] = '\0';
argv[k] = av[k];
}
read_flag = fscanf(coordfile,"%s%s%s%s%s%*[^\n\r]",args[2],args[3],args[4],args[5],args[6]);
read_flag = fscanf(coordfile,"%s%s%s%s%s%*[^\n]",args[2],args[3],args[4],args[5],args[6]);
if (read_flag == EOF) goto reached_EOF;
fprintf(outfile,"%s %s %s %s %s ",args[2],args[3],args[4],args[5],args[6]);fflush(outfile);
iline++;
Expand Down Expand Up @@ -697,9 +697,6 @@ int main(int argc, char**argv)
* read to end of line or buffer */
{
fileline++; /* On new line */

char* p = strchr(inbuff, '\n'); if (p != NULL) *p = '\0';
p = strchr(inbuff, '\r'); if (p != NULL) *p = '\0';
if (strlen(inbuff) != RECL) /* IF incorrect record size */
{
printf("Corrupt record in file %s on line %d.\n", mdfile, fileline);
Expand Down
9 changes: 6 additions & 3 deletions Geomag/geomag70.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,21 @@
computerDir = 'linux';
geomagExe = 'geomag70';
stdOutRedirection = '>/dev/null'; % we don't want standard output to be output in console (useless)
endOfLine = '\n';
maxPathLength = 1024;

case {'PCWIN', 'PCWIN64'}
computerDir = 'windows';
geomagExe = 'geomag70.exe';
stdOutRedirection = '>NUL';
endOfLine = '\r\n';
maxPathLength = 259;

case {'MACI64'}
computerDir = 'macosx';
geomagExe = 'geomag70';
stdOutRedirection = '>/dev/null';
endOfLine = '\n';
maxPathLength = 1024;

otherwise
Expand All @@ -73,7 +76,7 @@

geomagPath = fullfile(path, 'Geomag');
geomagExeFull = fullfile(geomagPath, computerDir, geomagExe);
geomagModelFile = fullfile(geomagPath, [model '.COF']);
geomagModelFile = fullfile(geomagPath, computerDir, [model '.COF']);
geomagInputFile = fullfile(geomagPath, 'sample_coords.txt');
geomagOutputFile = fullfile(geomagPath, ['sample_out_' model '.txt']);

Expand All @@ -94,13 +97,13 @@
geomagCmd = sprintf('%s %s f %s %s %s', geomagExeFull, geomagModelFile, geomagInputFile, geomagOutputFile, stdOutRedirection);
system(geomagCmd);

geomagFormat = '%s D M%f %f %f %fd %fm %*s %*s %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f\n';
geomagFormat = '%s D M%f %f %f %fd %fm %*s %*s %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f';
outputId = fopen(geomagOutputFile, 'rt');
geomagOutputData = textscan(outputId, geomagFormat, ...
'HeaderLines', 1, ...
'Delimiter', ' ', ...
'MultipleDelimsAsOne', true, ...
'EndOfLine', '\n');
'EndOfLine', endOfLine);
fclose(outputId);

geomagDate = datenum(geomagOutputData{1}, 'yyyy,mm,dd');
Expand Down
File renamed without changes.
File renamed without changes.
Binary file modified Geomag/linux/geomag70
Binary file not shown.
Loading

0 comments on commit 5cc77db

Please sign in to comment.