Bug when write the values into forcing.ncfile

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
hpd14thu
Posts: 68
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Bug when write the values into forcing.ncfile

#1 Unread post by hpd14thu »

I'm a beginner at computer programming. I use the frc_uvstress.cdl file in ".../trunk/Data/ROMS/CDL" , and I transfered it into forcing netcdf file.

Then I use a matlab file(which named str_cdl_nc.m) to write values(sms time, sustr, svstr) into the ncfile.

But when I check the forcing.nc file. The value of sms time is very strange, and the dimension of it is incorrect.( I just want to calculate in 2 days since 0:00:00 0)

So I wonder if there is anything wrong in my matlab file(which used to write value into ncfile) ? Thank you so much!


Paddy
Attachments
frc_uvstress.nc
(15.15 MiB) Downloaded 314 times
str_cdl_nc.m
(1.64 KiB) Downloaded 310 times

User avatar
hpd14thu
Posts: 68
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: Bug when write the values into forcing.ncfile

#2 Unread post by hpd14thu »

And here is my frc_uvstress.cdl

netcdf frc_uvstress {

dimensions:
xi_rho = 100 ;
xi_u = 99 ;
xi_v = 100 ;
eta_rho = 200 ;
eta_u = 200 ;
eta_v = 199 ;
sms_time = UNLIMITED ; // (0 currently)

variables:
float sms_time(sms_time) ;
sms_time:long_name = "surface momentum stress time" ;
sms_time:units = "days since 1992-01-01 00:00:00" ;
sms_time:interval = "367 daily data" ;
sms_time:start_date = "01-Jan-1993" ;
sms_time:end_date = "07-Jan-1994" ;
short sustr(sms_time, eta_u, xi_u) ;
sustr:long_name = "surface u-momentum stress" ;
sustr:units = "Newton meter-2" ;
sustr:time = "sms_time" ;
sustr:scale_factor = 0.0005 ;
short svstr(sms_time, eta_v, xi_v) ;
svstr:long_name = "surface v-momentum stress" ;
svstr:units = "Newton meter-2 * 1000" ;
svstr:time = "sms_time" ;
svstr:scale_factor = 0.0005 ;

// global attributes:
:type = "ROMS FORCING file" ;
:title = "NCEP/NCAR Global Atmospheric Re-analyses v4/97" ;
:grd_file = "afirst_grid.nc" ;
:source_file = "../natl/ncepflx1_NATL1993.nc" ;
:source_file_history = "extraction from grib files using NCEP_GRBdaily - 27-Mar-2002 17:08:28" ;
}

User avatar
hpd14thu
Posts: 68
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: Bug when write the values into forcing.ncfile

#3 Unread post by hpd14thu »

And here is my matlab file which used to write values into forcing.nc file:

%1) Enter start time of forcing file, in seconds.
% This time needs to be consistent with model time (ie dstart and time_ref).
% See *.in files for more detail.
time = [0 1 2];
sms_time = [0 1 2];


%4) Obtain grid information.
grid_file='/home/hpd14/Documents/COAWST_V3.2/Projects/afirst/afirst_grid.nc' %<-enter name of grid here
lon_rho=ncread(grid_file,'lon_rho');
lat_rho=ncread(grid_file,'lat_rho');
[ix iy]=size(lon_rho);
t=length(sms_time);
xrho = ix;
yrho = iy;


%5) Forcing sustr, svstr.

% Forcing values for sustr, svstr.
display('Forcing sustr, svstr')
%
sustr(1:length(sms_time),1:xrho,1:yrho) = 0.15;
svstr(1:length(sms_time),1:xrho,1:yrho) = 0;


%now write the data from the arrays to the netcdf file
disp(' ## Filling Variables in netcdf file with data...')

ncwrite('frc_uvstress.nc','sms_time',sms_time);
ncwrite('frc_uvstress.nc','sustr',sustr);
ncwrite('frc_uvstress.nc','svstr',svstr);


%close file
disp(['created ', 'frc_uvstress.nc'])

Post Reply