clear all
close all

filename=['ecco_radtrans9_size163_forseth.nc'];

ncid1=netcdf.open(filename);

   [ndim,nvar,natt,unlim]=netcdf.inq(ncid1);
     for i=0:ndim-1,
      [dimname, dimlength]=netcdf.inqDim(ncid1,i);
      diml(i+1)=dimlength;
     end % for i

     for i=0:nvar-1;
      [varname, xtype,dimid,natt]=netcdf.inqVar(ncid1,i);
      if (length(dimid)==1),
        eval([varname,'=netcdf.getVar(ncid1,i,0,diml(dimid+1));']);
      end % if
      if (length(dimid)==2),
        eval([varname,'=netcdf.getVar(ncid1,i,[0 0],[diml(dimid(1)+1) diml(dimid(2)+1)] );']);
      end % if
      if (length(dimid)==3),
        eval([varname,'=netcdf.getVar(ncid1,i,[0 0 0],[diml(dimid(1)+1) diml(dimid(2)+1) diml(dimid(3)+1)] );']);
      end % if
      if (length(dimid)==4),
         eval([varname,'=netcdf.getVar(ncid1,i,[0 0 0 0],[diml(dimid(1)+1) diml(dimid(2)+1) diml(dimid(3)+1)  diml(dimid(4)+1)] );']);
       end % if
        eval([varname,'=double(',varname,');']);
     end % for i
   netcdf.close(ncid1);
%%
%%% plot biomass
   figure
   colormap default, cmap=colormap; colormap(cmap([18:4:59],:))
   for ip=1:7,
     if (ip==1), tmp=Diatom; tstr='Diatom'; end
     if (ip==2), tmp=Coccolithophore; tstr='Coccolithophore'; end
     if (ip==3), tmp=PicoEukaryote; tstr='PicoEukaryote'; end
     if (ip==4), tmp=Synecococcus; tstr='Synecococcus'; end
     if (ip==5), tmp=Prochlorococcus; tstr='Prochlorococcus'; end
     if (ip==6), tmp=Tricho; tstr='Tricho'; end
     if (ip==7), tmp=UnicellDiaz; tstr='UnicellDiaz'; end
     
     tmp=log10(tmp);
     clear fi, fi=find(LandMask==1); tmp(fi)=NaN;

     subplot(4,2,ip),  pcolor(longitude,latitude,tmp'); caxis([-2 1.8]); shading flat, colorbar
        hp = gca ; hc = colorbar; axes(hc);
        bolder, set(gca,'Ytick',[-2 -1 0 1] );
        set(gca,'YTickLabel',['0.01';'0.1 ';'1.  ';'10. ']); 
        axes(hp),
     title([tstr]);
   end % for ip

%%% plot limitation
   figure
   colormap default, cmap=colormap; colormap(cmap([18 30 40 50],:))
   for ip=1:7,
     if (ip==1), tmp=DiatomLim; tstr='Diatom'; end
     if (ip==2), tmp=CoccolithophoreLim; tstr='Coccolithophore'; end
     if (ip==3), tmp=PicoEukaryoteLim; tstr='PicoEukaryote'; end
     if (ip==4), tmp=SynecococcusLim; tstr='Synecococcus'; end
     if (ip==5), tmp=ProchlorococcusLim; tstr='Prochlorococcus'; end
     if (ip==6), tmp=TrichoLim; tstr='Tricho'; end
     if (ip==7), tmp=UnicellDiazLim; tstr='UnicellDiaz'; end

     clear fi, fi=find(LandMask==1); tmp(fi)=NaN;

     subplot(4,2,ip),  pcolor(longitude,latitude,tmp'); caxis([.5 4.5]); shading flat, colorbar
     colorbar;
         hp = gca ; hc = colorbar; axes(hc);
         bolder, set(gca,'Ytick',[1 2 3 4] );
         set(gca,'YTickLabel',['Fe ';'DIN';'PO4';'Si ']); 
         axes(hp),
     title([tstr]);
   end % for ip



