My Project
sinter.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40 !==============================================================================|
41 ! |
42 ! this subroutine linearly interpolates and extrapolates an |
43 ! array b. |
44 ! |
45 ! x(m1) must be descending |
46 ! a(x) given function |
47 ! b(y) found by linear interpolation and extrapolation |
48 ! y(n1) the desired depths |
49 ! m1 the number of points in x and a |
50 ! n1 the number of points in y and b |
51 ! |
52 !==============================================================================|
53 
54 MODULE sinter
55  IMPLICIT NONE
56 
57  CONTAINS
58 
59  SUBROUTINE sinter_extrp_up(X,A,Y,B,M1,N1)
60 
61 !==============================================================================|
62  USE mod_prec
63  IMPLICIT NONE
64  INTEGER, INTENT(IN) :: M1,N1
65  REAL(SP), INTENT(IN) :: X(M1),A(M1),Y(N1)
66  REAL(SP), INTENT(OUT) :: B(N1)
67  INTEGER I,J,NM
68 !==============================================================================|
69 
70 !
71 ! EXTRAPOLATION
72 !
73  DO i=1,n1
74  IF (y(i) > x(1 )) b(i) = a(1) + ((a(1)-a(2))/(x(1)-x(2))) * (y(i)-x(1))
75  IF (y(i) < x(m1)) b(i) = a(m1)
76  END DO
77 
78 !
79 ! INTERPOLATION
80 !
81  nm = m1 - 1
82  DO i=1,n1
83  DO j=1,nm
84  IF (y(i) <= x(j) .AND. y(i) >= x(j+1)) &
85  b(i) = a(j) - (a(j)- a(j+1)) * (x(j)-y(i)) / (x(j)-x(j+1))
86  END DO
87  END DO
88 
89  RETURN
90  END SUBROUTINE sinter_extrp_up
91 !==============================================================================|
92 
93 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 
96 !==============================================================================|
97  SUBROUTINE sinter_extrp_down(X,A,Y,B,M1,N1)
98 ! for baroclinic interpolation |
99 !==============================================================================|
100 
101 
102 !==============================================================================|
103  USE mod_prec
104  IMPLICIT NONE
105  INTEGER, INTENT(IN) :: M1,N1
106  REAL(SP), INTENT(IN) :: X(M1),A(M1),Y(N1)
107  REAL(SP), INTENT(OUT) :: B(N1)
108  INTEGER :: I,J,NM
109 !==============================================================================|
110 
111 !
112 ! EXTRAPOLATION
113 !
114  DO i=1,n1
115  IF(y(i) > x(1 )) b(i) = a(1)
116  IF(y(i) < x(m1)) b(i)=a(m1)+(a(m1-1)-a(m1))*(y(i)-x(m1))/(x(m1-1)-x(m1))
117  END DO
118 
119 !
120 ! INTERPOLATION
121 !
122  nm = m1 - 1
123  DO i=1,n1
124  DO j=1,nm
125  IF (y(i)<=x(j).AND.y(i)>=x(j+1)) &
126  b(i) = a(j) - (a(j)- a(j+1)) *(x(j)-y(i)) / (x(j)-x(j+1))
127  END DO
128  END DO
129 
130  RETURN
131  END SUBROUTINE sinter_extrp_down
132 !==============================================================================|
133 
134 
135 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 
138 !==============================================================================|
139  SUBROUTINE sinter_extrp_none(X,A,Y,B,M1,N1)
140 ! for t&s obc interpolation |
141 !==============================================================================|
142 
143 
144  USE mod_prec
145  IMPLICIT NONE
146  INTEGER, INTENT(IN) :: M1,N1
147  REAL(SP), INTENT(IN) :: X(M1),A(M1),Y(N1)
148  REAL(SP), INTENT(OUT) :: B(N1)
149  INTEGER :: I,J,NM
150 !==============================================================================|
151 
152 
153 !
154 ! EXTRAPOLATION
155 !
156  DO i=1,n1
157  IF (y(i) > x(1 )) b(i) = a(1)
158  IF (y(i) < x(m1)) b(i) = a(m1)
159  END DO
160 
161 !
162 ! INTERPOLATION
163 !
164  nm = m1 - 1
165  DO i=1,n1
166  DO j=1,nm
167  IF (y(i) <= x(j).AND.y(i) >= x(j+1)) &
168  b(i) = a(j) - (a(j)- a(j+1)) * (x(j)-y(i)) / (x(j)-x(j+1))
169  END DO
170  END DO
171 
172  RETURN
173  END SUBROUTINE sinter_extrp_none
174 !==============================================================================|
175 
176 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 
179 !==============================================================================|
180  SUBROUTINE sinter_extrp_both(X,A,Y,B,M1,N1)
181 !==============================================================================|
182 
183 
184 !==============================================================================|
185  USE mod_prec
186  IMPLICIT NONE
187  INTEGER, INTENT(IN) :: M1,N1
188  REAL(SP), INTENT(IN) :: X(M1),A(M1),Y(N1)
189  REAL(SP), INTENT(OUT) :: B(N1)
190  INTEGER :: I,J,NM
191 !==============================================================================|
192 
193 !
194 ! EXTRAPOLATION
195 !
196  DO i=1,n1
197  IF(y(i) > x(1 )) b(i) = a(1) + ((a(1)-a(2))/(x(1)-x(2))) * (y(i)-x(1))
198  IF(y(i) < x(m1)) b(i)=a(m1)+(a(m1-1)-a(m1))*(y(i)-x(m1))/(x(m1-1)-x(m1))
199  END DO
200 
201 !
202 ! INTERPOLATION
203 !
204  nm = m1 - 1
205  DO i=1,n1
206  DO j=1,nm
207  IF (y(i)<=x(j).AND.y(i)>=x(j+1)) &
208  b(i) = a(j) - (a(j)- a(j+1)) *(x(j)-y(i)) / (x(j)-x(j+1))
209  END DO
210  END DO
211 
212  RETURN
213  END SUBROUTINE sinter_extrp_both
214 !==============================================================================|
215 
216 END MODULE sinter
subroutine sinter_extrp_both(X, A, Y, B, M1, N1)
Definition: sinter.f90:181
subroutine sinter_extrp_none(X, A, Y, B, M1, N1)
Definition: sinter.f90:140
subroutine sinter_extrp_down(X, A, Y, B, M1, N1)
Definition: sinter.f90:98
subroutine sinter_extrp_up(X, A, Y, B, M1, N1)
Definition: sinter.f90:60