1 MODULE module_init_utilities
5 real function interp_0( v_in, &
9 real v_in(nz_in), z_in(nz_in)
13 logical interp, increasing_z
16 parameter ( debug = .false. )
18 ! does vertical coordinate increase or decrease with increasing k?
19 ! set offset appropriately
23 if(debug) write(6,*) ' height in interp_0 ',height
25 if (z_in(nz_in) .gt. z_in(1)) then
27 if(debug) write(6,*) ' monotonic increase in z in interp_0 '
28 IF (height > z_in(nz_in)) then
29 if(debug) write(6,*) ' point 1 in interp_0 '
30 w2 = (z_in(nz_in)-height)/(z_in(nz_in)-z_in(nz_in-1))
32 interp_0 = w1*v_in(nz_in) + w2*v_in(nz_in-1)
33 ELSE IF (height < z_in(1)) then
34 if(debug) write(6,*) ' point 2 in interp_0 '
35 w2 = (z_in(2)-height)/(z_in(2)-z_in(1))
37 interp_0 = w1*v_in(2) + w2*v_in(1)
39 if(debug) write(6,*) ' point 3 in interp_0 '
42 DO WHILE ( (interp .eqv. .false.) .and. (kp .ge. 2) )
43 IF( ((z_in(kp) .ge. height) .and. &
44 (z_in(kp-1) .le. height)) ) THEN
45 w2 = (height-z_in(kp))/(z_in(kp-1)-z_in(kp))
47 interp_0 = w1*v_in(kp) + w2*v_in(kp-1)
48 if(debug) write(6,*) ' interp data, kp, w1, w2 ',kp, w1, w2
49 if(debug) write(6,*) ' interp data, v_in(kp), v_in(kp-1), interp_0 ', &
50 v_in(kp), v_in(kp-1), interp_0
59 if(debug) write(6,*) ' monotonic decrease in z in interp_0 '
61 IF (height < z_in(nz_in)) then
62 if(debug) write(6,*) ' point 1 in interp_0 '
63 w2 = (z_in(nz_in)-height)/(z_in(nz_in)-z_in(nz_in-1))
65 interp_0 = w1*v_in(nz_in) + w2*v_in(nz_in-1)
66 ELSE IF (height > z_in(1)) then
67 if(debug) write(6,*) ' point 2 in interp_0 '
68 w2 = (z_in(2)-height)/(z_in(2)-z_in(1))
70 interp_0 = w1*v_in(2) + w2*v_in(1)
72 if(debug) write(6,*) ' point 3 in interp_0 '
76 DO WHILE ( (interp .eqv. .false.) .and. (kp .ge. 2) )
77 IF( ((z_in(kp) .le. height) .and. &
78 (z_in(kp-1) .ge. height)) ) THEN
79 w2 = (height-z_in(kp))/(z_in(kp-1)-z_in(kp))
81 interp_0 = w1*v_in(kp) + w2*v_in(kp-1)
93 END MODULE module_init_utilities