clear;clc;
models = ["BCC-CSM2-MR","CanESM5","CESM2","CNRM-ESM2-1","IPSL-CM6A-LR","MPI-ESM1-2-LR","UKESM1-0-LL"];
rank = ["(a)","(b)","(c)","(d)","(e)","(f)","(g)","(h)","(i)","(j)","(k)"];

for m = 1:length(models)
figure('units','inches','outerposition',[2 3 9 7]);
[ha, pos] = tight_subplot(2,3,[.04 0.07],[.04 .1],[.08 .04]);
 
CTRL_fn = ['2D_' convertStringsToChars(models(m)) '_piControl.nc'];
fn = ['2D_' convertStringsToChars(models(m)) '_deforest-globe.nc'];
 
start = [1 38];
step = [inf 66];
lon     = ncread(CTRL_fn,'lon');
lat     = ncread(CTRL_fn,'lat',38,66); 
landfrac     = ncread(CTRL_fn,'landfrac',start(1:2),step(1:2));
landmask = ones(size(landfrac,1),size(landfrac,2));landmask(landfrac<50)=nan;

SH        = ncread(fn,'SH',start,step);
CTRL_SH   = ncread(CTRL_fn,'SH',start,step);
LH        = ncread(fn,'LH',start,step);
CTRL_LH   = ncread(CTRL_fn,'LH',start,step);
 
print_unit = ' W/m^2';
color_ticks = -6:2:6;
color_bounds = [-8 8];
 
res_SH = (SH-CTRL_SH).*landmask;
res_LH = (LH-CTRL_LH).*landmask;
alpha = 0.05;
axes(ha(1))
hold on
map_plot(lat,lon,res_SH,275,325,-32,18,0:20:360,-20:10:20)

cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
ylabel('∆SH','fontsize',18)
text(0,1.13,convertStringsToChars(rank(m)),'units','normalized','fontsize',20,'fontweight','bold')

axes(ha(4))
hold on
map_plot(lat,lon,res_LH,275,325,-32,18,0:20:360,-20:10:20)

cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
ylabel('∆LH','fontsize',18)
 
axes(ha(2))
hold on
map_plot(lat,lon,res_SH,0,60,-30,30,0:20:50,-20:10:20)

cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
 
axes(ha(5))
hold on
map_plot(lat,lon,res_LH,0,60,-30,30,0:20:50,-20:10:20)

cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
 
axes(ha(3))
hold on
map_plot(lat,lon,res_SH,108,120,-4,8,0:5:360,-5:5:5)
cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
 
axes(ha(6))
hold on
map_plot(lat,lon,res_LH,108,120,-4,8,0:5:360,-5:5:5)

cb = colorbar('Ticks',color_ticks,'fontsize',10,'location','east', ...,
    'Position',[pos{6}(1)+pos{6}(3)*1.1 pos{6}(2)*1.5 0.02 3*pos{3}(3)]); 
caxis(color_bounds);colormap(turbo);set(cb,'visible','off')
set(gca,'linewidth',1.2,'fontsize',12,'fontweight','bold')
 
 
sgtitle(['\fontsize{26}' convertStringsToChars(models(m))],'fontweight','bold')
end
