Update version info for release v4.6.1 (#2122)
[WRF.git] / var / obsproc / MAP_plot / Dir_map / fbint.F
blobe798efcd3dffff0865e5aa05a8858af7bc10a189
1 C                                                                               
2       FUNCTION FBINT(XX,YY,LIST,III,JJJ,IBINT)                                   
3 C                                                                               
4 C-----BILINEAR INTERPOLATION AMONG FOUR GRID VALUES                             
5 C                                                                               
6       REAL LIST(III,JJJ),STL(4,4)                                               
7 C                                                                               
8       IB = III-IBINT                                                            
9       JB = JJJ-IBINT                                                            
10       FBINT = 0.0                                                                
11       N    = 0                                                                  
12       I    = INT(XX+0.00001)                                                    
13       J    = INT(YY+0.00001)                                                    
14       X    = XX-I                                                               
15       Y    = YY-J                                                               
16       IF (ABS(X).GT.0.0001.OR.ABS(Y).GT.0.0001) GOTO 10                         
17       FBINT = LIST(I,J)                                                          
18       RETURN                                                                    
19    10 CONTINUE                                                                  
20       DO 20 K=1,4                                                               
21       KK = I+K-2                                                                
22       DO 20 L=1,4                                                               
23       STL(K,L) = 0.                                                             
24       LL = J+L-2                                                                
25       IF (KK.LT.1.OR.KK.GT.IB) GOTO 20                                          
26       IF (LL.GT.JB.OR.LL.LT.1) GOTO 20                                          
27       STL(K,L) = LIST(KK,LL)                                                    
28       N = N+1                                                                   
29       IF (STL(K,L).EQ.0.0) STL(K,L) = 1.E-25                                    
30    20 CONTINUE                                                                  
31 C                                                                               
32 C-----FIND INDEX OF CLOSEST POINT TO XX,YY.                                     
33 C                                                                               
34       A = FONED(X,STL(1,1),STL(2,1),STL(3,1),STL(4,1))                           
35       B = FONED(X,STL(1,2),STL(2,2),STL(3,2),STL(4,2))                           
36       C = FONED(X,STL(1,3),STL(2,3),STL(3,3),STL(4,3))                           
37       D = FONED(X,STL(1,4),STL(2,4),STL(3,4),STL(4,4))                           
38       FBINT = FONED(Y,A,B,C,D)                                                    
39 C                                                                               
40       IF (N.EQ.16) RETURN                                                       
41       E = FONED(Y,STL(1,1),STL(1,2),STL(1,3),STL(1,4))                           
42       F = FONED(Y,STL(2,1),STL(2,2),STL(2,3),STL(2,4))                           
43       G = FONED(Y,STL(3,1),STL(3,2),STL(3,3),STL(3,4))                           
44       H = FONED(Y,STL(4,1),STL(4,2),STL(4,3),STL(4,4))                           
45       FBINT = (FBINT+FONED(X,E,F,G,H))/2.                                          
46       RETURN                                                                    
47       END