creatboundry错误代码.docx
《creatboundry错误代码.docx》由会员分享,可在线阅读,更多相关《creatboundry错误代码.docx(17页珍藏版)》请在冰豆网上搜索。
creatboundry错误代码
>>creat_bohaisea_bry_without_v2d
Subscriptedassignmentdimensionmismatch.
Errorinread_bohaisea_tidal_bry(line22)
E(j,:
)=D{2};
Errorincreat_bohaisea_bry_without_v2d(line31)
read_bohaisea_tidal_bry
>>
错误1
%从bohaisea_grid.nc读取数据
ncid=netcdf.open('bohaisea_grid.nc','NC_NOWRITE');(只读)
var1=netcdf.inqVarID(ncid,'lon_rho');(netcdf.inqVarID返回nc文件的字符串)
lon_rho=netcdf.getVar(ncid,var1);
netcdf.close(ncid);
nuy=size(lon_rho,2);
%读取水位
address=['OpenBoundry\\\\P_01.dat'];
fid=fopen(address);
D=textscan(fid,'%f%f%f%f%f%f%f%f%f%f','headerlines',3);
fclose(fid);
ntide=length(D{2});
E=zeros(nuy,ntide);
UBAR=zeros(nuy,ntide);
VBAR=zeros(nuy,ntide);
fori=1:
46;
j=i+42;
address=['OpenBoundry\\\\P_'num2str(i,'%02d')'.dat'];
fid=fopen(address);
D=textscan(fid,'%f%f%f%f%f%f%f%f%f%f','headerlines',3);
fclose(fid);
E(j,:
)=D{2};
UBAR(j,:
)=D{5};
VBAR(j,:
)=D{6};
end
错误2
clear;
%从bohaisea_grid.nc读取数据
ncid=netcdf.open('bohaisea_grid.nc','NC_NOWRITE');
var1=netcdf.inqVarID(ncid,'lon_rho');
var2=netcdf.inqVarID(ncid,'lat_rho');
var3=netcdf.inqVarID(ncid,'lon_u');
var4=netcdf.inqVarID(ncid,'lat_u');
var5=netcdf.inqVarID(ncid,'lon_v');
var6=netcdf.inqVarID(ncid,'lat_v');
var7=netcdf.inqVarID(ncid,'spherical');
var8=netcdf.inqVarID(ncid,'h');
lon_rho=netcdf.getVar(ncid,var1);
lat_rho=netcdf.getVar(ncid,var2);
lon_u=netcdf.getVar(ncid,var3);
lat_u=netcdf.getVar(ncid,var4);
lon_v=netcdf.getVar(ncid,var5);
lat_v=netcdf.getVar(ncid,var6);
spherical=netcdf.getVar(ncid,var7);
h=netcdf.getVar(ncid,var8);
netcdf.close(ncid);
filename='bohaisea_bry.nc';
%维度部分的数值
nux=size(lon_rho,1);
nuy=size(lon_rho,2);
layer=30;
layers=layer+1;
one=1;
ktide=1;
%------------------------------------读取潮边界(需要read_bohaisea_tidal_bry.m)--------------------------------------
read_bohaisea_tidal_bry
%ntide=3000;%111111*********11111111111111111111111111111111111111111111111111111111111111111111111111111
%其他变量
%--------------------------------------------------------------------------
fori=1:
ntide;
zeta_time(i)=300*i;
%v2d_time(i)=300*i;
%v3d_time(i)=300*i;
%temp_time(i)=300*i;
%salt_time(i)=300*i;
end
v2d_time
(1)=300;
v3d_time
(1)=300;
temp_time
(1)=300;
salt_time
(1)=300;
%--------------------------------------------------------------------------
zeta_east=zeros(nuy,ntide);
zeta_west=zeros(nuy,ntide);
zeta_north=zeros(nux,ntide);
zeta_south=zeros(nux,ntide);
fori=1:
nuy;
forj=1:
ntide;
zeta_east(i,j)=E(i,j);
end
end
ubar_east=zeros(nuy,ktide);
ubar_west=zeros(nuy,ktide);
ubar_north=zeros(nux-1,ktide);
ubar_south=zeros(nux-1,ktide);
%fori=1:
nuy;
%forj=1:
ntide;
%ubar_east(i,j)=UBAR(i,j);
%end
%end
vbar_east=zeros(nuy-1,ktide);
vbar_west=zeros(nuy-1,ktide);
vbar_north=zeros(nux,ktide);
vbar_south=zeros(nux,ktide);
%fori=1:
nuy-1;
%forj=1:
ntide;
%vbar_east(i,j)=VBAR(i,j);
%end
%end
u_east=zeros(nuy,layer,ktide);
u_west=zeros(nuy,layer,ktide);
u_north=zeros(nux-1,layer,ktide);
u_south=zeros(nux-1,layer,ktide);
v_east=zeros(nuy-1,layer,ktide);
v_west=zeros(nuy-1,layer,ktide);
v_north=zeros(nux,layer,ktide);
v_south=zeros(nux,layer,ktide);
temp_east=zeros(nuy,layer,ktide);
temp_west=zeros(nuy,layer,ktide);
temp_north=zeros(nux,layer,ktide);
temp_south=zeros(nux,layer,ktide);
salt_east=zeros(nuy,layer,ktide);
salt_west=zeros(nuy,layer,ktide);
salt_north=zeros(nux,layer,ktide);
salt_south=zeros(nux,layer,ktide);
fori=1:
nuy;
forj=1:
layer;
fork=1:
ktide;
temp_east(i,j,k)=14;
temp_west(i,j,k)=14;
salt_east(i,j,k)=35;
salt_west(i,j,k)=35;
end
end
end
fori=1:
nux;
forj=1:
layer;
fork=1:
ktide;
temp_north(i,j,k)=14;
temp_south(i,j,k)=14;
salt_north(i,j,k)=35;
salt_south(i,j,k)=35;
end
end
end
%----------------------------------------------写入------------------------------------------------
%添加维度
ncid=netcdf.create(filename,'NC_WRITE');
xi_rho_dimID=netcdf.defDim(ncid,'xi_rho',nux);
eta_rho_dimID=netcdf.defDim(ncid,'eta_rho',nuy);
xi_u_dimID=netcdf.defDim(ncid,'xi_u',nux-1);
eta_u_dimID=netcdf.defDim(ncid,'eta_u',nuy);
xi_v_dimID=netcdf.defDim(ncid,'xi_v',nux);
eta_v_dimID=netcdf.defDim(ncid,'eta_v',nuy-1);
s_rho_dimID=netcdf.defDim(ncid,'s_rho',layer);
s_w_dimID=netcdf.defDim(ncid,'s_w',layers);
zeta_time_dimID=netcdf.defDim(ncid,'zeta_time',ntide);
v2d_time_dimID=netcdf.defDim(ncid,'v2d_time',ktide);
v3d_time_dimID=netcdf.defDim(ncid,'v3d_time',ktide);
temp_time_dimID=netcdf.defDim(ncid,'temp_time',ktide);
salt_time_dimID=netcdf.defDim(ncid,'salt_time',ktide);
netcdf.close(ncid)
%创建变量
nccreate(filename,'spherical','Dimensions','','Format','classic','Datatype','int32');
ncwrite(filename,'spherical',spherical);
nccreate(filename,'h','Dimensions',{'xi_rho'nux'eta_rho'nuy},'Format','classic','Datatype','double');
ncwrite(filename,'h',h);
nccreate(filename,'lon_rho','Dimensions',{'xi_rho'nux'eta_rho'nuy},'Format','classic','Datatype','double');
ncwrite(filename,'lon_rho',lon_rho);
nccreate(filename,'lat_rho','Dimensions',{'xi_rho'nux'eta_rho'nuy},'Format','classic','Datatype','double');
ncwrite(filename,'lat_rho',lat_rho);
nccreate(filename,'lon_u','Dimensions',{'xi_u'nux-1'eta_u'nuy},'Format','classic','Datatype','double');
ncwrite(filename,'lon_u',lon_u);
nccreate(filename,'lat_u','Dimensions',{'xi_u'nux-1'eta_u'nuy},'Format','classic','Datatype','double');
ncwrite(filename,'lat_u',lat_u);
nccreate(filename,'lon_v','Dimensions',{'xi_v'nux'eta_v'nuy-1},'Format','classic','Datatype','double');
ncwrite(filename,'lon_v',lon_v);
nccreate(filename,'lat_v','Dimensions',{'xi_v'nux'eta_v'nuy-1},'Format','classic','Datatype','double');
ncwrite(filename,'lat_v',lat_v);
nccreate(filename,'zeta_time','Dimensions',{'zeta_time'ntide},'Format','classic','Datatype','double');
ncwrite(filename,'zeta_time',zeta_time);
nccreate(filename,'v2d_time','Dimensions',{'v2d_time'ktide},'Format','classic','Datatype','double');
ncwrite(filename,'v2d_time',v2d_time);
nccreate(filename,'v3d_time','Dimensions',{'v3d_time'ktide},'Format','classic','Datatype','double');
ncwrite(filename,'v3d_time',v3d_time);
nccreate(filename,'temp_time','Dimensions',{'temp_time'ktide},'Format','classic','Datatype','double');
ncwrite(filename,'temp_time',temp_time);
nccreate(filename,'salt_time','Dimensions',{'salt_time'ktide},'Format','classic','Datatype','double');
ncwrite(filename,'salt_time',salt_time);
nccreate(filename,'zeta_west','Dimensions',{'eta_rho'nuy'zeta_time'ntide},'Format','classic','Datatype','single');
ncwrite(filename,'zeta_west',zeta_west);
nccreate(filename,'zeta_east','Dimensions',{'eta_rho'nuy'zeta_time'ntide},'Format','classic','Datatype','single');
ncwrite(filename,'zeta_east',zeta_east);
nccreate(filename,'zeta_south','Dimensions',{'xi_rho'nux'zeta_time'ntide},'Format','classic','Datatype','single');
ncwrite(filename,'zeta_south',zeta_south);
nccreate(filename,'zeta_north','Dimensions',{'xi_rho'nux'zeta_time'ntide},'Format','classic','Datatype','single');
ncwrite(filename,'zeta_north',zeta_north);
nccreate(filename,'ubar_west','Dimensions',{'eta_u'nuy'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'ubar_west',ubar_west);
nccreate(filename,'ubar_east','Dimensions',{'eta_u'nuy'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'ubar_east',ubar_east);
nccreate(filename,'ubar_south','Dimensions',{'xi_u'nux-1'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'ubar_south',ubar_south);
nccreate(filename,'ubar_north','Dimensions',{'xi_u'nux-1'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'ubar_north',ubar_north);
nccreate(filename,'vbar_west','Dimensions',{'eta_v'nuy-1'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'vbar_west',vbar_west);
nccreate(filename,'vbar_east','Dimensions',{'eta_v'nuy-1'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'vbar_east',vbar_east);
nccreate(filename,'vbar_south','Dimensions',{'xi_v'nux'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'vbar_south',vbar_south);
nccreate(filename,'vbar_north','Dimensions',{'xi_v'nux'v2d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'vbar_north',vbar_north);
nccreate(filename,'u_west','Dimensions',{'eta_u'nuy's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'u_west',u_west);
nccreate(filename,'u_east','Dimensions',{'eta_u'nuy's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'u_east',u_east);
nccreate(filename,'u_south','Dimensions',{'xi_u'nux-1's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'u_south',u_south);
nccreate(filename,'u_north','Dimensions',{'xi_u'nux-1's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'u_north',u_north);
nccreate(filename,'v_west','Dimensions',{'eta_v'nuy-1's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'v_west',v_west);
nccreate(filename,'v_east','Dimensions',{'eta_v'nuy-1's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'v_east',v_east);
nccreate(filename,'v_south','Dimensions',{'xi_v'nux's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(filename,'v_south',v_south);
nccreate(filename,'v_north','Dimensions',{'xi_v'nux's_rho'layer'v3d_time'ktide},'Format','classic','Datatype','single');
ncwrite(fil