close all
clear 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

 
node_sp = 2;
 
suffix = 'IFREMER-528lbs-300d';   
 
  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
  
  fprintf('Hit any key to continue');
  %pause
  
  
SCOPES = [1.2];
CURRENTS = [.5];

for cat_bot = [300];  %Distance from seafloor for bottom of catenary.

last_current = 0;

for scope = SCOPES
for curr_fact = CURRENTS
wind_spd = 5;  %light winds
wave_per = 10
wave_amp = 0;
static_results_filenm = [path,'StatRes-',num2str(100*curr_fact),'c-',num2str(scope),'s-',num2str(cat_bot),'d-',suffix]
results_filenm = static_results_filenm;

layout

static_config
results_filenm_last = [static_results_filenm,'-static'];

for run_num = [12]
    
wave_amp = AMP(run_num);
wave_per = PER(run_num);
wind_spd = SPD(run_num);


%curr_fact = CURRENT_FACTOR(run_num);
%curr_fact = 0.1;
%scope = SCOPE;

close all

clear results_filenm;

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

layout


dynamic_config


if (exist([results_filenm,'.mat']) == 0) 
cmd = ['!c:/progra~1/WHOICA~1/res2mat.exe -in ',results_filenm,'.crs -out ',results_filenm,'.mat -totals -lbs'];
eval(cmd);
else 
    file1 = dir([results_filenm,'.mat']);
    file2 = dir([results_filenm,'.crs']);
    if (datenum(file1.date) < datenum(file2.date))
      cmd = ['!c:/progra~1/WHOICA~1/res2mat.exe -in ',results_filenm,'.crs -out ',results_filenm,'.mat -totals -lbs'];
      eval(cmd);  
    end
end

%make_movies
last_current = curr_fact;
last_current = 0;  %Compute static solution from scratch each time.
end
end
end
end

