the problem about MAIN_ncfiles.m

Discussion of how to use ROMS on different regional and basin scale applications.

Moderators: arango, robertson

Post Reply
Message
Author
slvester
Posts: 32
Joined: Mon Jun 01, 2009 12:59 pm
Location: second institution of oceanography,state oceanic administration China

the problem about MAIN_ncfiles.m

#1 Post by slvester » Mon Nov 30, 2009 8:02 am

Hello,I just follow the ROMS Tutorials(http://eros.eas.gatech.edu/ROMS-Tutorial/tutorials.html)(MAIN_grid.m)and generate the grid file 'nwpacific-grid.nc'
---------------------------------------------------------------
nwpacific-grid.nc
gridindi.id = 'nwpacific'
gridindo.name = 'northwestern pacific';
gridindo.grdfile = '/dcfs2/users/slvester/roms/roms-grid/nwpacific-grid.nc';
gridindo.N = 45;
gridindo.thetas = 5;
gridindo.thetab = 0.4;
gridindi.hc = 20;
gridindo.tcline = 200;
gridindo.cstfile = '/dcfs2/users/slvester/roms/roms-grid/World_coast.mat';
lonr:[136*84 double]
latr:[136*84 double]
xr:[136*84 double]
yr:[136*84 double]
h:[136*84 double]
grd_pos:[]
Lp:136
Mp:84
lonu:[135*84 double]
latu:[135*84 double]
lonv:[136*83 double]
latv:[136*83 double]
lonp:[135*83 double]
latp:[135*83 double]
xu:[135*84 double]
yu:[135*84 double]
xv:[136*83 double]
yv:[136*83 double]
xp:[135*83 double]
yp:[135*83 double]
angle:[136*84 double]
f:[136*84 double]
maskr:[136*84 double]
masku:[135*84 double]
maskv:[136*83 double]
maskp:[135*83 double]
pm:[136*84 double]
pn:[136*84 double]
hraw:[1*136*84 double]
L:135
M:83
Lm:134
Mm:82
dndx:[135*83 double]
dmde:[135*83 double]
-------------------------------------------------------------------------------
my domin is 9.0796°N-46.7972°N,105.3868°E-178.9976°E,lever resolution is 50km,84*136;the minimum depth is 20m,the max depth is 6500m.
the qustion is:
I use this grid file to generate the ncfiles(initial,boundary,forcing,et al)

------------------------------------------------------------------------------
MAIN_ncfiles.m:
tic;
nameit='nwpacific';
grd=rnt_gridload(nameit);

outdir='./';

% the following file will be made if it does not exist.
levfile= [outdir,'Levitus.mat'];

clmfile=[outdir,nameit,'-clim.nc'];
bryfile=[outdir,nameit,'-bry.nc'];
initfile=[outdir,nameit,'-init.nc'];
forcfile=[outdir,nameit,'-forc.nc'];

disp('Current Settings:');
setng.nameit=nameit;
setng.outputdir=outdir;
setng
input('Return to continue ... (CTRL-C to stop) ');

%==========================================================
% % create files
%==========================================================

disp (' ----------STAGE 1: Creating NC files ----------');
if exist(bryfile) == 0
disp(' Creating bry ..');
rnc_CreateBryFile(grd,bryfile)
end
if exist(clmfile) == 0
disp(' Creating clim ..');
rnc_CreateClimFile(grd,clmfile)

end
if exist(forcfile) == 0
disp(' Creating forc ..');
rnc_CreateForcFile(grd,forcfile)
end
if exist(initfile) == 0
disp(' Creating init ..');
rnc_CreateIniFile(grd,initfile);
end

input('Continue with climatology interpolation ... (CTRL-C to stop) ');

%==========================================================
% do the CLIMATOLOGY
%==========================================================

rnc_SetClimaConst(grd,clmfile);
MAIN_ncfiles_clima_TS %MAIN_ncfiles_clima_TS.m

% now that you extracted levitus verify that the resolution
% of the extracted data is adeguate for the grid you are
% preparing.
% load Levitus
% rnt_plc(grd.h*nan,grd,0,5,0,0);
% pcolor(levitus.lon,levitus.lat,levitus.mask(:,:,1,1))
% shading interp;

MAIN_ncfiles_clima_UV %MAIN_ncfiles_clima_UV.m

% The following run by hand interactively first use.

%==========================================================
% do the FORCING (MAIN_ncfiles_forc.m)
%==========================================================
rnc_SetForcZero(grd,forcfile);
MAIN_ncfiles_clima_forc

% need to add SST and SSS to forcing
rnc_AddSSTfromClima(clmfile,forcfile); % touch AddSSTfromClima.m
rnc_AddSSSfromClima(clmfile,forcfile); % AddSSSfromClima.m


%==========================================================
% % Add time indices in climatology
%==========================================================
nc=netcdf(clmfile,'w');
vars = { 'tclm_time' 'sclm_time' 'ssh_time' 'uclm_time' 'vclm_time'};
climatime=15:30:360;
for i=1:length(vars)
nc{vars{i}}(:) = climatime;
end
close(nc);

vars = { 'sms_time' 'shf_time' 'swf_time' 'sst_time' 'sss_time' 'srf_time'};
nc=netcdf(forcfile,'w');
climatime=15:30:360;
for i=1:length(vars)
nc{vars{i}}(:) = climatime;
end
close(nc);

%==========================================================
% do the INITIAL CONDITION and BOUNDARY FILE
%==========================================================

timeindex=1; % put timelevel 5 as initial condition
rnc_SetInitFromClim(grd,clmfile,initfile,timeindex);
rnc_SetBryFromClim(grd,clmfile,bryfile);

% plotting stuff ...

disp('Plotting NC Files using function PlotNCfiles(nameit, outdir)');
rnc_PlotNCfiles(nameit, outdir)

ctli=rnt_timectl({initfile},'ocean_time');
ctlc=rnt_timectl({clmfile},'tclm_time');
ctlf=rnt_timectl({forcfile},'sms_time');

save CTLs.mat ctli ctlc ctlf grd
clear
load CTLs
whos
% now add dQdSST
toc;
-----------------------------------------------------------------------
and in matlab
>>MAIN_ncfiles
Current Setting

setng=
nameit:'nwpacific'
outdir:'./'
Rrturn to continue...(CTRL-C to stop)
---------------------------STAGE 1:Creating NC files----------
Creating bry...
Creating clim..
Creating forc
Creating init...
Continue with climatology interpolation...(CTRL-C to stop)
Looks like climatology time index array.
vclm_time
tclm_time
sclm_time
ssh_time
uclm_time
temp
salt
zeta
ubar
vbar
u
v
Make Clim DONE.
-----------------------STAGE 3---------------
Do Levitus Clima...
HC set from minumum dept WARNING!0
Warning:Divide by zero.
>In rnt_setdepth at 97
In rnc_LevitusClima at 7
In MAIN_ncfiles_clima_TS at 15
In MAIN_ncfiles at 54[/color]--time level 1
--vert level 1
--vert level 2
.........................
HC set from minumum dept WARNING!0
Warning:Divide by zero.
>In rnt_setdepth at 97
In rnc_LevitusClima at 7
In MAIN_ncfiles_clima_TS at 15
In MAIN_ncfiles at 54
Updating...
NAN values found in Sn
NAN values found in Sn
..................
DONE .
Looks like climatology time index array.
sustr
svstr
shflux
SST
SSS
dQdSST
swrad
Make Forc DONE
year=
0
??? Attempted to access k(1);index out of bounds because nume(k)=0;
Error in==>ncvar.subsref at 243
start(i)=k(1)-1;
Error in==>netcdf.subsref at 74
result=subsref(reslut,s);
Error in==>rnc_Extract_UVwinds_NCEP at 110
ncep.svstr(:,:,TIMEINDEX)=-nc{'svstr'}(i,j,in);
..........

why the year=0,and the trouble is come frome ncvar/subsref.m?
How can I resolve it?
thanks!

slvester
Posts: 32
Joined: Mon Jun 01, 2009 12:59 pm
Location: second institution of oceanography,state oceanic administration China

Re: the problem about MAIN_ncfiles.m

#2 Post by slvester » Tue Dec 01, 2009 9:05 am

Could anyone can help me?This is my first application,and I have struggled it for some days.
Thanke you!

Post Reply