D_ECMWF2ROMS Matlab scripts

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
barack99
Posts: 17
Joined: Thu Aug 31, 2017 4:33 pm

D_ECMWF2ROMS Matlab scripts

#1 Post by barack99 » Fri Sep 22, 2017 8:42 am

Dear all,

I am using D_ECMWF2ROMS to prepare the forcing ECMWF data for ROMS, but I still need to understand it clearly. I am a new ROMS user, so would you mind to help with the questions below:

1/ Why do we use F( 3).scale=? for each variable? Is it compulsory for ROMS?

2/ How do I select the mybasedate? should I select = datenum(1858,11,17,0,0,0) if I use HYCOM for initial/boundary conditions?

3/ How about LonMin LonMax LatMin LatMax ? Could I select these numbers to be larger than my grid domain? or these need to be same as the domain?

4/ Do I need to use the same time interval (e.g. every 3-hours) for all variables? or Could I use both 6 hours and 12 hours-interval? Does ROMS accepts it?

5. Last, what is the rule to arrange the forcing files in ocean*.in? if I use this script to prepare the forcing data.

Many thanks in advance!

Regards
Barack
Barack

User avatar
kate
Posts: 3699
Joined: Wed Jul 02, 2003 5:29 pm
Location: IMS/UAF, USA

Re: D_ECMWF2ROMS Matlab scripts

#2 Post by kate » Fri Sep 22, 2017 4:50 pm

I don't use that tool, but I can answer some of these:
2/ How do I select the mybasedate? should I select = datenum(1858,11,17,0,0,0) if I use HYCOM for initial/boundary conditions?
Just be consistent across everything from initial to boundary to forcing files. We chose 1900,1,1 some time ago and are sticking with it.
3/ How about LonMin LonMax LatMin LatMax ? Could I select these numbers to be larger than my grid domain? or these need to be same as the domain?
At least as big as your domain. We fetch the global grid to use for multiple domains.
4/ Do I need to use the same time interval (e.g. every 3-hours) for all variables? or Could I use both 6 hours and 12 hours-interval? Does ROMS accepts it?
ROMS will read the time variable for each forcing variable independently. Note that to resolve diurnal variations in shortwave, for instance, three hours does better than 12 hours. We average three of the hourly MERRA records into one for 3-hourly fields.
5. Last, what is the rule to arrange the forcing files in ocean*.in? if I use this script to prepare the forcing data.
The order doesn't matter, though if you have both 2011 and 2012 in separate files, they have to be listed in chronological order.

barack99
Posts: 17
Joined: Thu Aug 31, 2017 4:33 pm

Re: D_ECMWF2ROMS Matlab scripts

#3 Post by barack99 » Sat Sep 23, 2017 5:05 am

Thanks Kate, actually I use this tool because I read this: viewtopic.php?f=30&t=3003

My first question is important because it relates to the scale, and time interval.. Any further help would always be appreciated!

Regards
Barack
Barack

User avatar
wilkin
Posts: 509
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: D_ECMWF2ROMS Matlab scripts

#4 Post by wilkin » Sat Sep 23, 2017 11:56 am

I wrote this code a long time ago so my memory of the details is a biz fuzzy, but it required some awkward programming to get the ECMWF results into the form ROMS expects.

The challenging thing is that several of the values in the ECMWF raw data files are reported as a cumulative sum over the forecast interval. This is noted in comments in the Matlab routine ...

Code: Select all

% If the scale F(n).scale is set to negative, the input ECMWF data is a
% cumulative integral in forecast cycle from hour zero.
% For steps at 6, 9 and 12 hours we must separate last 3 hours of 
% integration from previous accumulation.
% At 3 hour step don't change anything
ROMS wants forcing data in some units per time, e.g. Joules per second (i.e. Watts) but ECMWF have integrated this over time. You can't just divide by 3 hours because the value at hour 6 is the integral from hours 0 through 6, not from hour 3 to 6.

There is a table in the comments in the preamble to the routine noting the translations between ECMWF variables and ROMS forcing variables.

Code: Select all

% This dataset is written in compact way (short numbers). We need to
% convert to floating-point data and scale to ROMS units:
%
%   Uwind       (m s-1)         v10u
%   Vwind       (m s-1)         v10v
%   sustr       (N m-2)         ewss / (3*3600);   3-hour step
%   svstr       (N m-2)         nsss / (3*3600);   3-hour step
%   shflux      (W m-2)         (ssr+str+sshf+slhf) / (3*3600)
%   swrad       (W m-2)         ssr  / (3*3600);   3-hour step
%   lwrad_down  (W m-2)         strd / (3*3600);   3-hour step
%   latent      (W m-2)         slhf / (3*3600);   3-hour step
%   sensible    (W m-2)         sshf / (3*3600):   3-hour step
%   rain        (kg m-2 s-1)    tp * Rho_w / (3*3600)
%   evaporation (kg m-2 s-1)    e  * Rho_w / (3*3600)
%   swflux      (cm day-1)      (-e - tp) * 100 / (3/24);  0.125 day step
%   cloud       (nondimesional) tcc
%   Pair        (mb)            msl / 100;   (1 mb = 100 Pa)
%   Tair        (Celsius)       t2m - 273.15;   (1 C = 273.15 K)
%   Qair        (percentage)    100 * (E/Es)

Unless ECMWF have changed how these data are stored, the code works provided you download all 3-hour interval data. That's why the instructions say:

Code: Select all

% The following parameters are used to extract ERA-Interim fields:
% Select time:   00:00:00     12:00:00
% Select step:   0  3  6  9  12
If you skip some data in your download from ECMWF, say only downloading 0, 6, 12 time-steps, you almost certainly break the logic for unraveling the cumulative summations and will have incorrect heat fluxes.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

barack99
Posts: 17
Joined: Thu Aug 31, 2017 4:33 pm

Re: D_ECMWF2ROMS Matlab scripts

#5 Post by barack99 » Sat Sep 23, 2017 12:32 pm

Thanks John for your clarification.

Is there any updated/easier scripts to prepare the forcing data I could look at?

Best,
Barack

bkresning
Posts: 2
Joined: Wed Jul 15, 2015 8:59 pm
Location: University of Rhode Island

Re: D_ECMWF2ROMS Matlab scripts

#6 Post by bkresning » Wed Jul 11, 2018 4:12 pm

Hi All,

I am trying to use d_ecmwf2roms (I check out the file at revision 914) to generate a forcing file and I encountered the problem below. Am I missing some files/toolboxes? Any suggestion would be helpful. Thank you

Code: Select all

** Creating ROMS NetCDF forcing file: gom_Tair_era.nc **
 
Wrote lon                 into record: , Min=-1.79250e+02 Max= 1.80000e+02
Wrote lat                 into record: , Min=-9.00000e+01 Max= 9.00000e+01
 
** Creating ROMS NetCDF forcing file: gom_Qair_era.nc **
 
Wrote lon                 into record: , Min=-1.79250e+02 Max= 1.80000e+02
Wrote lat                 into record: , Min=-9.00000e+01 Max= 9.00000e+01
 
** Processing: sustr  for  01-Oct-2012 03:00:00 **
Undefined function or variable 'nc_int'.

Error in nc_read>nc_read_matlab (line 430)
        case {nc_int, nc_short, nc_byte}

Error in nc_read (line 95)
    f =
    nc_read_matlab(ncfile,Vname,Tindex,ReplaceValue,PreserveType,Info);
    
Error in d_ecmwf2roms_na (line 476)
          field = nc_read(InpFile, Vecmwf, Rec);

mjfconan
Posts: 15
Joined: Mon Mar 03, 2014 1:57 pm
Location: SKLEC, ECNU, China

Re: D_ECMWF2ROMS Matlab scripts

#7 Post by mjfconan » Thu Jul 12, 2018 12:23 pm

bkresning wrote: Undefined function or variable 'nc_int'.

Error in nc_read>nc_read_matlab (line 430)
case {nc_int, nc_short, nc_byte}

Error in nc_read (line 95)
f = nc_read_matlab(ncfile,Vname,Tindex,ReplaceValue,PreserveType,Info);

Error in d_ecmwf2roms_na (line 476)
field = nc_read(InpFile, Vecmwf, Rec);
I think it is a little bug in the function of "nc_read", line 430.
It should be similar to the next "switch" block, means,

Code: Select all

        case {netcdf.getConstant('nc_int'),                             ...
              netcdf.getConstant('nc_short'),                           ...
              netcdf.getConstant('nc_byte')}
              f = double(f).*scale+offset;
NOT

Code: Select all

        case {nc_int, nc_short, nc_byte}
              f = double(f).*scale+offset;

bkresning
Posts: 2
Joined: Wed Jul 15, 2015 8:59 pm
Location: University of Rhode Island

Re: D_ECMWF2ROMS Matlab scripts

#8 Post by bkresning » Thu Jul 12, 2018 2:02 pm

Thank you, the suggested action solved the error.

Post Reply