%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Startup file for Octave and Matlab. Sets paths and creates file with
% global variables named CISM_DX_GLOBALS.mat.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% IMPORTANT!: If this file is named .octaverc, *DO NOT* edit it. (For
% Octave/Matlab compatability, .octaverc is replaced with CISM_DX_startup.m
% when script cismdx_octave is used to start Octave with CISM_DX
% extensions.) Edit CISM_DX_startup.m instead.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global CISM_DX_GLOBALS_FILE
% R.S. Weigel 11/16/2004
if (exist('read_octaverc'))
break;
end
if (DEFAULT_LOADPATH(4:11)=='cygdrive')
OCTARC = 'cygwin';
else
OCTARC = 'linux-gnu';
end
CISM_DX_ROOT = ['/usr/local/CISM_DX/'];
CISM_DX_DATA_ROOT = ['/usr/local/CISM_DX_DATA/'];
curr_dir = pwd;
if (~exist('~/.inputrc'))
if (exist('~/'))
system(sprintf('cp %s ~/',[CISM_DX_ROOT,'.inputrc']));
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make sure path settings are correct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (exist(CISM_DX_ROOT) == 0)
fprintf('\n\nCould not find directory \n%s\n\n',CISM_DX_ROOT);
error(['You must edit the CISM_DX_ROOT variable in \n ' ...
' mfiles/CISM_DX_startup.m and restart cismdx_octave.\n\n']);
exit;
end
if (exist(CISM_DX_DATA_ROOT) == 0)
fprintf('\n\nCould not find directory \n%s\n\n',CISM_DX_DATA_ROOT);
error(['You must edit the CISM_DX_DATA_ROOT variable in \n ' ...
' mfiles/CISM_DX_startup.m and restart.\n\n']);
exit;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid = fopen([CISM_DX_ROOT,'VERSION'],'rt');
if (fid==-1)
error(['Unable to find CISM_DX VERSION file.']);
exit
end
CISM_DX_VERSION = deblank(fscanf(fid,'%s'));
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set some global variables. Global variables should be all CAPS.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set these global variables at install time!
% CISM_DX_DATA_ROOT2 is where downloaded data will go. It needs to
% be writable by the user, which will not be the case if CISM_DX_DATA
% is located in /usr/local or some other system directory.
% Assume a CISM_DX_DATA directory exists in users home dir.
% If it does not, one will not be created. Instead we will use
if (is_unix == 0) % For windows
CISM_DX_TEMPDIR = '/tmp/';
CISM_DX_USERNAME = 'user';
CISM_DX_DATA_ROOT_WR = CISM_DX_DATA_ROOT;
CISM_DX_DATA_FULL_ROOT = [CISM_DX_DATA_ROOT(1:end-1),'-Full/'];
CISM_DX_DATA_UTS = [CISM_DX_DATA_ROOT,...
'measurements/uniform_time_series/'];
CISM_DX_DATA_UTS_WR = [CISM_DX_DATA_ROOT,...
'measurements/uniform_time_series/'];
CISM_DX_DATA_ORIGINAL = [CISM_DX_DATA_ROOT,'measurements/original_data/'];
CISM_DX_AUXILIARY_ROOT = '';
CISM_DX_DATA_ACK_WARN = 0;
end
if (is_unix == 1) % For unix
if (is_octave)
CISM_DX_USERNAME = system('whoami');
else
[stat,CISM_DX_USERNAME] = system('whoami');
end
CISM_DX_USERNAME = CISM_DX_USERNAME(1:end-1); % Remove newline
CISM_DX_TEMPDIR = '/tmp/';
CISM_DX_DATA_ROOT_WR = CISM_DX_DATA_ROOT;
CISM_DX_DATA_FULL_ROOT = [CISM_DX_DATA_ROOT(1:end-1),'-Full/'];
CISM_DX_DATA_UTS = [CISM_DX_DATA_ROOT,...
'measurements/uniform_time_series/'];
CISM_DX_DATA_UTS_WR = [CISM_DX_DATA_ROOT,...
'measurements/uniform_time_series/'];
CISM_DX_DATA_ORIGINAL = [CISM_DX_DATA_ROOT,'measurements/original_data/'];
CISM_DX_AUXILIARY_ROOT = '';
CISM_DX_DATA_ACK_WARN = 0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Determine version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% See if CISM_DX_DATA_ROOT directory is writable
[s,err,m] = stat(CISM_DX_DATA_ROOT);
if ( (exist(CISM_DX_DATA_ROOT_WR)==0) & (s.modestr(3) == '-') )
fprintf('\nCannot write to %s\nand the directory %s was not found.\n',...
CISM_DX_DATA_ROOT(1:end-1),CISM_DX_DATA_ROOT_WR(1:end-1));
fprintf('Any data downloaded or created will be stored in %s\n',...
CISM_DX_TEMPDIR(1:end-1));
fprintf('If this is not what you want, exit and edit the variable\n');
fprintf('CISM_DX_DATA_ROOT_WR in in CISM_DX/Octave/CISM_DX_startup.m\n\n');
fflush(stdout);
CISM_DX_DATA_ROOT_WR = CISM_DX_TEMPDIR;
% Create a directory structure with no files
com = sprintf(['cd %s/.. ; pwd ; find ./CISM_DX_DATA -follow -type d',...
'| xargs -i mkdir \"%s/{}\"'],...
CISM_DX_DATA_ROOT,CISM_DX_TEMPDIR)
system(com);
end
if (is_octave)
warn_matlab_incompatable = 0;
suppress_verbose_help_message = 1;
crash_dumps_octave_core = 0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Global variables
CISM_DX_FTP_STR_ACE = 'ftp://ftp.sec.noaa.gov/pub/lists/ace/*_ace_*';
CISM_DX_FTP_STR_Ap = 'ftp://ftp.sec.noaa.gov/pub/lists/geomag/*AK.txt';
CISM_DX_FTP_STR_SYN = 'ftp://fusion.sec.noaa.gov/dist/narge/synoptic';
CISM_DX_FTP_STR_SSM = 'ftp://fusion.sec.noaa.gov/dist/ss_maps';
CISM_DX_FTP_STR_WSA = 'ftp://fusion.sec.noaa.gov/dist/narge/predictions';
CISM_DX_DATA_SERVER = 'http://lasp.colorado.edu/cism/CISM_DX/data';
CISM_DX_DATA_DIR_ACE = [CISM_DX_DATA_ROOT,'real_time_data/data_ace/'];
CISM_DX_DATA_DIR_Ap = [CISM_DX_DATA_ROOT,'real_time_data/data_Ap/'];
CISM_DX_DATA_DIR_SYN = [CISM_DX_DATA_ROOT,...
'real_time_data/data_solar/data_synoptic/'];
CISM_DX_DATA_DIR_WSA = [CISM_DX_DATA_ROOT,...
'real_time_data/data_solar/data_wsa/'];
CISM_DX_FLAG = 99999;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set paths for data and auxiliary programs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (is_unix == 0)
% Need C:\ form for making system calls.
CISM_DX_WGET_PATH = ['"',CISM_DX_AUXILIARY_ROOT,'wget/wget.exe"'];
CISM_DX_PERL_PATH = ['"',CISM_DX_AUXILIARY_ROOT,'perl/win32/bin/perl.exe"'];
CISM_DX_PERLFILES_ROOT = ['"',CISM_DX_AUXILIARY_ROOT,'perlfiles"'];
CISM_DX_CONVERT_PATH = 'convert.exe';
CISM_DX_GS_PATH = 'gswin32.exe';
CISM_DX_PS_PATH = 'gview32.exe';
CISM_DX_ARX_PATH = ['"',CISM_DX_ROOT,'models/filters/arx/arx.bat"'];
end
if ( (is_unix == 1) | (is_cygwin) )
octave_forge_path = ...
[CISM_DX_ROOT,'required_packages/octave-forge-2004.02.12/'];
CISM_DX_WGET_PATH = '/usr/bin/wget';
CISM_DX_PERL_PATH = '/usr/bin/perl';
CISM_DX_PERLFILES_ROOT = [CISM_DX_ROOT,'Perl'];
CISM_DX_CONVERT_PATH = '/usr/bin/convert';
CISM_DX_GS_PATH = '/usr/bin/gs';
CISM_DX_PS_PATH = '/usr/bin/ggv';
CISM_DX_ARX_PATH = [CISM_DX_ROOT,'required_packages/octave-rsw/filter_functions/arx/arx'];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set paths for Octave and Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (is_octave == 0)
addpath('.',...
CISM_DX_TEMPDIR,...
[CISM_DX_ROOT,'Octave/tutorials'],...
[CISM_DX_ROOT,'Octave/plot_functions'],...
[tempstr,'datafile_conversion_functions'],...
[tempstr,'load_functions'],...
[tempstr,'octave-matlab-compat/matlab'],...
[tempstr,'spectral_functions'],...
[tempstr,'statistics_functions'],...
[tempstr,'string_functions'],...
[tempstr2,'string_functions'],...
[tempstr2,'time_series_functions'],...
[tempstr2,'time_series_make_functions'],...
[CISM_DX_ROOT,'required_packages/libflag/libflag_matlab'],...
[CISM_DX_ROOT,'required_packages/epstk21-rsw/'],...
[CISM_DX_ROOT,'required_packages/epstk21/m']);
end
if (is_octave == 1)
path(LOADPATH,...
CISM_DX_TEMPDIR,...
[CISM_DX_ROOT,'Octave'],...
[CISM_DX_ROOT,'Octave/tutorials'],...
[CISM_DX_ROOT,'CISM_FMs'],...
[CISM_DX_ROOT,'Octave/plot_functions'],...
[CISM_DX_ROOT,'required_packages/tsds'],...
[CISM_DX_ROOT,'required_packages/octave-rsw//'],...
[CISM_DX_ROOT,'required_packages/libflag/libflag_octave'],...
[CISM_DX_ROOT,'required_packages/epstk21-rsw'],...
[CISM_DX_ROOT,'required_packages/epstk21/m'],...
[CISM_DX_ROOT,'OpenDX/modules'],...
[octave_forge_path,'main/strings'],...
[octave_forge_path,'main/time'],...
[octave_forge_path,'main/set'],...
[octave_forge_path,'main/general'],...
[octave_forge_path,'main/path'],...
[octave_forge_path,'extra/NaN']);
% rmpath([CISM_DX_ROOT,...
% 'required_packages/octave-rsw/octave-matlab-compat/matlab']);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (is_octave == 1)
if (is_unix == 0)
putenv('TMPDIR', system('echo -n `cygpath -wsm /tmp`') );
gnuplot_binary = 'gnuplot';
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save global variables (slight incompatabilities in Octave and Matlab
% .mat format forces different file names to be used).
if (is_octave)
CISM_DX_BASE_GLOBALS_FILE = 'CISM_DX_GLOBALS-Octave.mat';
else
CISM_DX_BASE_GLOBALS_FILE = 'CISM_DX_GLOBALS-Matlab.mat';
end
% Create a save file based on username to avoid multi-user clashes (EW)
CISM_DX_GLOBALS_FILE = sprintf('%s-%s',CISM_DX_USERNAME,CISM_DX_BASE_GLOBALS_FILE);
com0 = sprintf('''%s%s''',CISM_DX_TEMPDIR,CISM_DX_GLOBALS_FILE);
com = sprintf('save %s CISM_DX*',com0);
eval(com)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (is_octave == 0)
clear LOADPATH
end
cd(curr_dir);
clear com* errstr warnstr need2 BASE* I *dir *_path fid temp* warn_matlab_*
tsds;
under80 = repmat('_',1,80);
if (is_octave == 1)
% Only print this message if called with cismdx_octave (prevents appearance
% during Octave startup by, for example, OctaveOp.cpp.)
if exist('CISM_DX_GLOBALS.m')
fprintf('%s',under80);
fprintf('\n Starting Octave with CISM_DX version %s extensions\n',...
CISM_DX_VERSION);
fprintf('\n');
fprintf(' Type \"cism_dx_tutorial\" for CISM_DX demos.\n');
fprintf(' Type \"help cism_dx\" for CISM_DX info.\n');
fprintf(' Type \"help tsds\" info. on TSDS program\n');
fprintf(' Type \"help keyhelp\" command and key info.\n');
fprintf(' Use Shift-Page [Up/Down] - Scroll up or down\n');
fprintf('%s\n',under80);
end
else
fprintf('\n%s\n',under80);
fprintf('\n Matlab with CISM_DX extensions\n');
fprintf(' Type \"cism_dx_tutorial\" to get started \n');
fprintf('\n%s\n',under80);
end
clear FLAG CISM_DX* BASE2 under80 fs OCTVER
read_octaverc=1;