Caffery wrote:

**Code:**

if (F(n).scale < 0),

step = rem(frc_time,0.5)*24;

if step == 3

fieldfinal = field;

elseif step == 0

fieldfinal = field - field_previous; % At other steps subtract

end % the previous accumulation

frc_time = frc_time - 1.5/24; % Center forcing time on the

% accumulation interval

field_previous = field; % Save this accumulation

% to on the next step

end

i met this question. when i run this script ,it showed that

** Processing: sustr for 01-Jan-2015 **

Undefined function or variable 'field_previous'.

Error in d_ecmwf2roms (line 509)

fieldfinal = field - field_previous; % At other steps subtract

i want to know how to correct it .

thank you in advance.

I added another judgement to it, that is:

**Code:**

if ( F(n).scale < 0 )

step = rem(frc_time,0.5)*24; % remainder after division

if step == 3

fieldfinal = field;

frc_time = frc_time - 1.5/24; % Center forcing time on the

% accumulation interval

% we don't know what the 1st time record is (maybe 6, 9 ...)

% then admit it as appropriate data despite some mistakes

% introduced

elseif MyRec(n) == 1

fieldfinal = field;

frc_time = frc_time - step/48; % at center: step/2 hours

% step/48 days

else

fieldfinal = field - field_previous; % Other steps subtract

% the previous accumulation

frc_time = mean([time( indx(MyRec(n) - 1)), frc_time]); % average

end

field_previous = field; % Save this accumulation

% to on the next step

end