Home > functions > internal > dsCheckHostPaths.m

dsCheckHostPaths

PURPOSE ^

CHECKHOSTPATHS - Compare paths on host to those set in studyinfo when batch was created

SYNOPSIS ^

function [matched,error_message] = dsCheckHostPaths(studyinfo, varargin)

DESCRIPTION ^

CHECKHOSTPATHS - Compare paths on host to those set in studyinfo when batch was created

 Call dsCheckHostPaths() in job.m before first simulation to make sure the
 paths on the compute matchine match those in studyinfo created when the
 study was began.

 If paths do not match, an informative error message is added to
 .error_log (see dsCreateBatch() or any jobX.m script).

 Usage:
   dsCheckHostPaths(studyinfo)

 Inputs:
   - studyinfo: DynaSim studyinfo structure

 Outputs:
   - matched: {0 or 1} (whether the paths match or not)

 Paths compared:
 - path to DynaSim functions
 - path to model files
 
 Author: Jason Sherfey, PhD <jssherfey@gmail.com>
 Copyright (C) 2016 Jason Sherfey, Boston University, USA

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [matched,error_message] = dsCheckHostPaths(studyinfo, varargin)
0002 %CHECKHOSTPATHS - Compare paths on host to those set in studyinfo when batch was created
0003 %
0004 % Call dsCheckHostPaths() in job.m before first simulation to make sure the
0005 % paths on the compute matchine match those in studyinfo created when the
0006 % study was began.
0007 %
0008 % If paths do not match, an informative error message is added to
0009 % .error_log (see dsCreateBatch() or any jobX.m script).
0010 %
0011 % Usage:
0012 %   dsCheckHostPaths(studyinfo)
0013 %
0014 % Inputs:
0015 %   - studyinfo: DynaSim studyinfo structure
0016 %
0017 % Outputs:
0018 %   - matched: {0 or 1} (whether the paths match or not)
0019 %
0020 % Paths compared:
0021 % - path to DynaSim functions
0022 % - path to model files
0023 %
0024 % Author: Jason Sherfey, PhD <jssherfey@gmail.com>
0025 % Copyright (C) 2016 Jason Sherfey, Boston University, USA
0026 
0027 %% auto_gen_test_data_flag argin
0028 options = dsCheckOptions(varargin,{'auto_gen_test_data_flag',0,{0,1}},false);
0029 if options.auto_gen_test_data_flag
0030   varargs = varargin;
0031   varargs{find(strcmp(varargs, 'auto_gen_test_data_flag'))+1} = 0;
0032   varargs(end+1:end+2) = {'unit_test_flag',1};
0033   argin = [{studyinfo}, varargs]; % specific to this function
0034 end
0035 
0036 matched=1;
0037 error_message='';
0038 
0039 % locate DynaSim toolbox
0040 dynasim_path = dsGetRootPath(); % root is one level up from directory containing this function
0041 
0042 % locate mechanism files
0043 [mech_paths,mech_files]=dsLocateModelFiles(studyinfo.base_model);
0044 
0045 % compare DynaSim toolbox paths
0046 if ~isequal(fullfile(dynasim_path,'functions'), studyinfo.paths.dynasim_functions)
0047   matched=0;
0048   error_message=sprintf('%sPath changed to DynaSim functions (expected: %s, found: %s). ',error_message,studyinfo.paths.dynasim_functions,dynasim_path);
0049 end
0050 
0051 % compare model paths
0052 if ~isequal(unique(mech_paths),unique(studyinfo.paths.mechanisms))
0053   matched=0; mech_paths, studyinfo.paths.mechanisms
0054   error_message=sprintf('%sPath changed to model files (expected: %s, found: %s). ',error_message,[studyinfo.paths.mechanisms{:}],[mech_paths{:}]);
0055 end
0056 
0057 %% auto_gen_test_data_flag argout
0058 if options.auto_gen_test_data_flag
0059   argout = {matched, error_message}; % specific to this function
0060 
0061   dsUnitSaveAutoGenTestData(argin, argout);
0062 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005