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

## D_ECMWF2ROMS Matlab scripts

### Re: D_ECMWF2ROMS Matlab scripts

I don't use that tool, but I can answer some of these:

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.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?

At least as big as your domain. We fetch the global grid to use for multiple domains.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?

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.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?

The order doesn't matter, though if you have both 2011 and 2012 in separate files, they have to be listed in chronological order.5. Last, what is the rule to arrange the forcing files in ocean*.in? if I use this script to prepare the forcing data.

### Re: D_ECMWF2ROMS Matlab scripts

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

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

Regards

Barack

**Barack**

### Re: D_ECMWF2ROMS Matlab scripts

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 ...

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.

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:

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
```

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

71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

### Re: D_ECMWF2ROMS Matlab scripts

Thanks John for your clarification.

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

Best,

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

Best,

**Barack**

### Re: D_ECMWF2ROMS Matlab scripts

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

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);
```

### Re: D_ECMWF2ROMS Matlab scripts

I think it is a little bug in the function of "nc_read", line 430.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);

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;
```

Code: Select all

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

### Re: D_ECMWF2ROMS Matlab scripts

Thank you, the suggested action solved the error.