Hello,
We have been using Roms_tools to generate forcing and initial
files. It appears that the make_clim.m is unable to create
files larger than about 2GB. If one keep on
increasing the horizontal resolution, the make_clim script
returns a netcdf error. We are using netcdf4 with matlab 7
on Fedore core 9. The error does not seem to be with mexnc;
the test_lfs.m in mexnc is able to create files of any size.
Has anyone has created files > 2GB using make_clim?
I would appreciate your suggestions.
Best regards
vinay
Error in make_clim
Re: Error in make_clim
Vinay,
I am not sure, but I think the error is actually because make_clim.m uses the Chuck Denham set of tools, as I have noticed some similar limitations in the past with them. One solution is the following. Where there is a line such as
var=nf{'wind'}(:);
replace it with the new netcdf commands available in matlab (assuming you have R2008b or later). Below, I will paste in a script (ncload_var.m) that does that. But first,
AN IMPORTANT NOTE:
The new Matlab commands will reverse the row order in the array. So after running ncload_var.m, run permute_all.m (see below) if you want the the rest of make_clim.m to work. You can still use the same write command, such as nw{'sustr'}(t,:,:)=tauy to write the processed variable.
ncload_var.m:
function varout=ncload_var(ncfile,varname)
% Loads a single variable named "varname" in netcdf file into varout
% Works for strings as well - unlike the Denham netcdf tool.
% example...to read variable wind:
%ncfile='example.nc';
%wind=ncload_var(ncfile,'wind');
%wind=permute_all(wind);
%J Luick and C. James, July09
N=netcdf.open(ncfile,'nowrite');
[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(N);
for i=0:nvars-1
vname=netcdf.inqVar(N,i);
vdata=netcdf.getVar(N,i);
if strcmp(vname,varname)
varout=vdata;
netcdf.close(N)
return
end
end
disp([varname,' not found in ncfile'])
netcdf.close(N)
end
permute_all.m:
function varout=permute_all(array)
%Quick and dirty!
n=ndims(array);
if n==1; varout=array; return; end;
if n==2; varout=permute(array,[2 1]); return; end;
if n==3; varout=permute(array,[3 2 1]); return; end;
if n==4; varout=permute(array,[4 3 2 1]); return; end;
if n>=5; disp('permute_all only does up to 4 dims'); end;
end
I am not sure, but I think the error is actually because make_clim.m uses the Chuck Denham set of tools, as I have noticed some similar limitations in the past with them. One solution is the following. Where there is a line such as
var=nf{'wind'}(:);
replace it with the new netcdf commands available in matlab (assuming you have R2008b or later). Below, I will paste in a script (ncload_var.m) that does that. But first,
AN IMPORTANT NOTE:
The new Matlab commands will reverse the row order in the array. So after running ncload_var.m, run permute_all.m (see below) if you want the the rest of make_clim.m to work. You can still use the same write command, such as nw{'sustr'}(t,:,:)=tauy to write the processed variable.
ncload_var.m:
function varout=ncload_var(ncfile,varname)
% Loads a single variable named "varname" in netcdf file into varout
% Works for strings as well - unlike the Denham netcdf tool.
% example...to read variable wind:
%ncfile='example.nc';
%wind=ncload_var(ncfile,'wind');
%wind=permute_all(wind);
%J Luick and C. James, July09
N=netcdf.open(ncfile,'nowrite');
[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(N);
for i=0:nvars-1
vname=netcdf.inqVar(N,i);
vdata=netcdf.getVar(N,i);
if strcmp(vname,varname)
varout=vdata;
netcdf.close(N)
return
end
end
disp([varname,' not found in ncfile'])
netcdf.close(N)
end
permute_all.m:
function varout=permute_all(array)
%Quick and dirty!
n=ndims(array);
if n==1; varout=array; return; end;
if n==2; varout=permute(array,[2 1]); return; end;
if n==3; varout=permute(array,[3 2 1]); return; end;
if n==4; varout=permute(array,[4 3 2 1]); return; end;
if n>=5; disp('permute_all only does up to 4 dims'); end;
end
Re: Error in make_clim
John,
Thanks very much for your suggestions. The script works now
with certain changes in the netcdf attributes.
Your script to permute is very useful. Thanks much.
Vinay & Sivaprasad
Thanks very much for your suggestions. The script works now
with certain changes in the netcdf attributes.
Your script to permute is very useful. Thanks much.
Vinay & Sivaprasad