function [filenm] = make_layout(ENV,LAYOUT,name)


filenm = make_filename(ENV,LAYOUT,name);

fid = fopen([name '.spec'],'w');
str = ['#define TITLE "' LAYOUT.title '"\n'];   fprintf(fid,str);
str = ['#define DEPTH ' num2str(ENV.depth) '\n'];   fprintf(fid,str);
str = ['#define TF ' num2str(ENV.tf) '\n'];   fprintf(fid,str);
str = ['#define DT ' num2str(ENV.dt) '\n'];   fprintf(fid,str);
str = ['#define RAMPTIME ' num2str(ENV.ramptime) '\n'];   fprintf(fid,str);
str = ['#define INPUT_TYPE ' ENV.input_type '\n'];   fprintf(fid,str);
str = ['#define XWAVEAMP ' num2str(ENV.xwaveamp) '\n'];   fprintf(fid,str);
str = ['#define XWAVEPERIOD ' num2str(ENV.xwaveperiod) '\n'];   fprintf(fid,str);
str = ['#define XWAVEDIR ' num2str(ENV.xwavephase) '\n'];   fprintf(fid,str);
str = ['#define XWIND ' num2str(ENV.xwind) '\n'];   fprintf(fid,str);
str = ['#define PIG_MASS ' num2str(LAYOUT.pigmass) '\n'];   fprintf(fid,str);
str = ['#define ESP_WETWEIGHT ' num2str(LAYOUT.ESP_wetweight) '\n'];   fprintf(fid,str);


str = ['#define DYNAMICLAMBDA ' num2str(ENV.dynamiclambda) '\n'];   fprintf(fid,str);

str = ['#define XCURRENT ']; 

for i = 1:length(ENV.xcurrent)
  curr_depth = ENV.xcurrent(i,1);
  curr = ENV.currentscale*ENV.xcurrent(i,2);
  str = [str '(' num2str(curr_depth) ', ' num2str(curr) ') '];
end
  str = [str '\n'];
  fprintf(fid,str);


if strcmp(ENV.forcing_type,'velocity')
str = ['#define VELOCITY_FORCING \n'];   fprintf(fid,str);
end
if strcmp(ENV.forcing_type,'wave-follower')
str = ['#define WAVE_FOLLOWING \n'];   fprintf(fid,str);
end

str = ['#define HOSE' num2str(LAYOUT.hose) ' \n']; fprintf(fid,str);

str = ['#define STRETCH_HOSE_LENGTH ' num2str(LAYOUT.stretch_hose_length) ' \n']; fprintf(fid,str);
str = ['#define STRAIN_FACTOR ' num2str(LAYOUT.strain_factor) ' \n']; fprintf(fid,str);

fclose(fid);

cmd = ['cp ' name '.spec ' filenm '.spec'];
system(cmd);

