0001 function [newPath] = make_cruise_dir(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 newPath = '';
0057
0058
0059 msg = nargchk(1,2,nargin);
0060 if ~isempty(msg)
0061 lasterror(struct('message',msg,'identifier','CTD:IncorrectNargin'));
0062 return
0063 end
0064
0065 if nargin == 1
0066 parent_dir = pwd;
0067 calibration_dir = varargin{1};
0068 elseif nargin == 2
0069 parent_dir = varargin{1};
0070 calibration_dir = varargin{2};
0071 else
0072 lasterror(struct('message','Error parsing input arguments.',...
0073 'identifier','CTD:UnknownAssertion'));
0074 return
0075 end
0076
0077
0078
0079
0080 namedir = fullfile(parent_dir,calibration_dir);
0081 fprintf('Creating directory %s...\n',namedir);
0082 [status,msg,msgid] = mkdir(parent_dir,calibration_dir);
0083 if ~status
0084 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0085 fprintf('Unable to create the directory %s ...\n',namedir);
0086 return
0087 end
0088 fprintf('%s successfully created.\n',namedir);
0089
0090
0091
0092 calibration_dir = namedir;
0093
0094
0095
0096 [status, msg, msgid] = mkdir(calibration_dir, 'mfiles');
0097 if ~status
0098 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0099 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0100 return
0101 end
0102 [status, msg, msgid] = mkdir(calibration_dir, 'bottle');
0103 if ~status
0104 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0105 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0106 return
0107 end
0108 [status, msg, msgid] = mkdir(calibration_dir, 'salts');
0109 if ~status
0110 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0111 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0112 return
0113 end
0114 [status, msg, msgid] = mkdir(calibration_dir, 'oxy');
0115 if ~status
0116 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0117 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0118 return
0119 end
0120 [status, msg, msgid] = mkdir(calibration_dir, 'proc_data');
0121 if ~status
0122 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0123 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0124 return
0125 end
0126 [status, msg, msgid] = mkdir(calibration_dir, 'raw_data');
0127 if ~status
0128 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0129 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0130 return
0131 end
0132 [status, msg, msgid] = mkdir(calibration_dir, 'calibrated');
0133 if ~status
0134 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0135 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0136 return
0137 end
0138 [status, msg, msgid] = mkdir(calibration_dir, 'log');
0139 if ~status
0140 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0141 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0142 return
0143 end
0144 [status, msg, msgid] = mkdir(calibration_dir, 'tmp');
0145 if ~status
0146 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0147 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0148 return
0149 end
0150 [status, msg, msgid] = mkdir(calibration_dir, 'figures');
0151 if ~status
0152 lasterror(struct('message',msg,'identifier',['CTD:' msgid]));
0153 fprintf('Unable to create the directory %s ...\n',calibration_dir);
0154 return
0155 end
0156
0157
0158
0159
0160 inst_dir = ctdcal('path');
0161 [status,msg,msgid] = copyfile(fullfile(inst_dir,'demos','register_cruise.m'),...
0162 fullfile(calibration_dir,'mfiles',['register_cruise.m']) );
0163 if ~status
0164 warning(msgid,msg)
0165 fprintf('Unable to copy register_cruise.m from %s to %s.\n',fullfile(inst_dir,'demos'),calibration_dir);
0166 end
0167
0168
0169 [fid,msg] = fopen(fullfile(calibration_dir,'ctdcalpath.m'),'wt');
0170 if fid < 0
0171 fprintf('Unable to create %s. \n',fullfile(calibration_dir,'ctdcalpath.m'));
0172 else
0173 fprintf(fid,'%% ctdcalpath - Add ctdcal and current cruise calibration directories to matlabpath.\n',' ');
0174 fprintf(fid,'%% \n',' ');
0175 fprintf(fid,'%% \n',' ');
0176 fprintf(fid,' \n',' ');
0177 fprintf(fid,'addpath %s \n',inst_dir);
0178 fprintf(fid,'addpath %s \n',calibration_dir);
0179 fprintf(fid,'addpath %s \n',fullfile(calibration_dir,'mfiles'));
0180 fprintf(fid,' \n',' ');
0181 fclose (fid);
0182 end
0183
0184
0185 if nargout > 0
0186 newPath = calibration_dir;
0187 else
0188 assignin('caller', 'ans', calibration_dir);
0189 end
0190 return
0191