clear all
close all

%Pierson Moskowitz Spectrum
           H_S = [ -1.0  0.0 0.5   1.5  2.5  3.5  4.5  5.5  6.5  7.5  8.5  9.5   10.5  11.5  12.5  13.5  14.5  15.5];  
           PER = [ 10.0 10.0 4     6    8   10    12   13   14   15   16   16.5  17    18    19    20    21    22];
           SPD = [ 0.0 0.0 9     17   21  24    28   31  34   37   39   40    43    45    47   49     52    60];
               
               
CURRENT_FACTOR = [ 0.0 0.0 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.6 0.65 0.7 0.75  0.8  0.85   0.9   0.95   1.0];

AMP = H_S/2;   %height -> amp
SPD = 0.515*SPD;  %kts -> m/s



wave_amp = AMP(1)
wave_per = PER(1)
wind_spd = SPD(1)

for curr_fact = [0.05]
curr_fact

for i = [6 12]
wave_amp = AMP(i)
wave_per = PER(i)
wind_spd = SPD(i)

suffix = 'SeahorseLargeFloatSME';   

path = ['./',suffix,'/'];
  
if(exist(path) == 7)
    fprintf(['Directory ',path,' exists\n\n']);
else
    fprintf(['Directory ',path,' does not exist, will create\n\n']);
    mkdir(path);
end
  
suffix
path
  

layout

results_filenm = [path,'DynRes-',num2str(wave_amp),'A-',num2str(100*curr_fact),'c-',num2str(scope),'s-',suffix]
  

if (wave_amp > 0)
cmd = ['!c:/progra~1/WHOICA~1/cable.exe -in SeahorseMSEMooring.cab -out Res.crs -quit -sample .2 -connectors -first -last -snap_dt 2 -DDESIGN']    
else
cmd = ['!c:/progra~1/WHOICA~1/cable.exe -in SeahorseMSEMooring.cab -out Res.crs -quit -sample .5 -connectors -first -last -snap_dt 5 -DDEPLOY']   
end
eval(cmd);

    
cmd = ['!mv Res.crs ',results_filenm,'.crs'];
eval(cmd);

%if (exist([results_filenm,'.mat']) == 0)
cmd = ['!res2mat.exe -in ',results_filenm,'.crs -out ',results_filenm,'.mat -totals -lbs'];
eval(cmd);
%end
load([results_filenm,'.mat']);


end
end
