# SUBROUTINE DLNEXTRP in uv2dv_cfd

From: Wei-Jen Tseng <tseng.weijen_at_nyahnyahspammersnyahnyah>
Date: Sat Apr 27 2013 - 19:12:20 MDT

Dear all,

I feel confused when I read the code about the linear extrapolation used in
the uv2dv_cfd.

The subroutine shows the way to calculate the divergence of 4 corner points.
I have two questions.

First, the calculations of 2 points [NL=1&ML=1, NL=1&ML=MLON] look fine
because they use 4 another points to get the answer.
But, the others [NL=NLAT&ML=1, NL=NLAT&ML=MLON] only use 3 points to
calculate the divergence.!?
Second, the if-statement and the calculation are not consistent in the
SUBROUTINE DLNEXTRP.

For example, it is the original code in NCL:

IF (NL.EQ.NLAT .AND. ML.EQ.MLON) THEN
IF (X(ML,NL-1).NE.XMSG .AND.
+ X(ML,NL-2).NE.XMSG .AND.
+ X(ML-1,NL).NE.XMSG .AND.
+ X(ML-1,NL).NE.XMSG) THEN
X(ML,NL) =
(2.D0*X(ML,NL-2)-X(ML,NL-2)+2.D0*X(ML-1,NL)-X(ML-2,NL))*0.5D0
END IF
END IF

The corrected code maybe look like this….?

IF (NL.EQ.NLAT .AND. ML.EQ.MLON) THEN
IF (X(ML,NL-1).NE.XMSG .AND.
+ X(ML,NL-2).NE.XMSG .AND.
+ X(ML-1,NL).NE.XMSG .AND.
+ X(ML-2,NL).NE.XMSG) THEN
X(ML,NL) =
(2.D0*X(ML,NL-1)-X(ML,NL-2)+2.D0*X(ML-1,NL)-X(ML-2,NL))*0.5D0
END IF
END IF

I would like to know just the misunderstanding of the code or it's a bug.