clear all

 gridname=['grid_igsm.nc'];
 X=ncread(gridname,'X');
 Y=ncread(gridname,'Y');
 nx=length(X); ny=length(Y);
 nlam=13;
  
for ityp=1:2,

 if (ityp==1), dirinstr=['igsm_oasim_edp_below.bin'], diroutstr=['igsm_oasim_edp']; end
 if (ityp==2), dirinstr=['igsm_oasim_esp_below.bin'], diroutstr=['igsm_oasim_esp']; end 

 fid=fopen(dirinstr,'r','b'); 
 field=fread(fid,'float32'); fclose(fid);
 field=reshape(field,nx,ny,12,nlam);

 for ilam=1:nlam,
   clear tmp,
   tmp=squeeze(field(:,:,:,ilam));
%
   if (ilam<10), lamstr=['0',num2str(ilam)]; else lamstr=num2str(ilam); end
   fid=fopen([diroutstr,lamstr,'_below.bin'],'w','b');
   fwrite(fid,tmp,'float32'); fclose(fid),
 end % for

end % for ityp
 
