function [filenm] = make_layout(ENV,LAYOUT)


fid = fopen('ESP.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 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 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);

n_nodes = round(LAYOUT.poly_length/LAYOUT.poly_nodespace);
str = ['#define POLY_LENGTH ' num2str(LAYOUT.poly_length) '\n'];   fprintf(fid,str);
str = ['#define POLY_NODES (' num2str(n_nodes) ', 1.0)\n'];   fprintf(fid,str);

n_nodes = round(LAYOUT.shockle_length/LAYOUT.shockle_nodespace);
str = ['#define SHOCKLE_LENGTH ' num2str(LAYOUT.shockle_length) '\n'];   fprintf(fid,str);
str = ['#define SHOCKLE_NODES (' num2str(n_nodes) ', 1.0)\n'];   fprintf(fid,str);

str = ['#define EM_LENGTH ' num2str(LAYOUT.em_length) '\n'];   fprintf(fid,str);
str = ['#define EM_NODES (' num2str(2*LAYOUT.em_length) ', 1.0)\n'];   fprintf(fid,str);

fclose(fid);

filenm = make_filename(ENV,LAYOUT);
