1 |
C $Header: /u/gcmpack/MITgcm/pkg/profiles/profiles_interp_gg.F,v 1.2 2012/06/22 22:07:34 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PROFILES_OPTIONS.h" |
5 |
|
6 |
C o==========================================================o |
7 |
C | subroutine profiles_interp | |
8 |
C | o 3D interpolation of model counterparts | |
9 |
C | for netcdf profiles data | |
10 |
C | started: Gael Forget 15-March-2006 | |
11 |
C o==========================================================o |
12 |
|
13 |
SUBROUTINE profiles_interp_gg( |
14 |
O traj_cur_out, |
15 |
I i_cur, |
16 |
I j_cur, |
17 |
I weights_cur, |
18 |
I type_cur, |
19 |
I file_cur, |
20 |
I mytime, |
21 |
I bi, |
22 |
I bj, |
23 |
I myThid |
24 |
& ) |
25 |
|
26 |
implicit none |
27 |
|
28 |
C ==================== Global Variables =========================== |
29 |
#include "EEPARAMS.h" |
30 |
#include "SIZE.h" |
31 |
#include "GRID.h" |
32 |
#include "DYNVARS.h" |
33 |
#include "PARAMS.h" |
34 |
#ifdef ALLOW_CAL |
35 |
#include "cal.h" |
36 |
#endif |
37 |
#ifdef ALLOW_PROFILES |
38 |
# include "profiles.h" |
39 |
#else |
40 |
integer NLEVELMAX |
41 |
parameter (NLEVELMAX=1) |
42 |
#endif |
43 |
#ifdef ALLOW_PTRACERS |
44 |
#include "PTRACERS_SIZE.h" |
45 |
#include "PTRACERS_FIELDS.h" |
46 |
#endif |
47 |
C ==================== Routine Variables ========================== |
48 |
_RL mytime |
49 |
integer mythid |
50 |
integer type_cur,file_cur |
51 |
_RL traj_cur_out(NLEVELMAX) |
52 |
_RL weights_cur(NUM_INTERP_POINTS) |
53 |
integer i_cur(NUM_INTERP_POINTS) |
54 |
integer j_cur(NUM_INTERP_POINTS) |
55 |
|
56 |
#ifdef ALLOW_PROFILES |
57 |
|
58 |
C ==================== Local Variables ========================== |
59 |
_RL tab_coeffs1(NUM_INTERP_POINTS) |
60 |
_RL tab_coeffs3(NUM_INTERP_POINTS) |
61 |
_RL ponderations(NUM_INTERP_POINTS) |
62 |
_RL pondsSUM |
63 |
integer q,k,kk,kcur,bi,bj |
64 |
_RL traj_cur(nR),mask_cur(nR) |
65 |
_RL tmp_coeff |
66 |
c-- == end of interface == |
67 |
|
68 |
do k=1,nr |
69 |
|
70 |
pondsSUM=0 |
71 |
do q=1,NUM_INTERP_POINTS |
72 |
|
73 |
if (type_cur.EQ.1) then |
74 |
tab_coeffs1(q)=theta(i_cur(q),j_cur(q),k,bi,bj) |
75 |
tab_coeffs3(q)=maskC(i_cur(q),j_cur(q),k,bi,bj) |
76 |
elseif (type_cur.EQ.2) then |
77 |
tab_coeffs1(q)=salt(i_cur(q),j_cur(q),k,bi,bj) |
78 |
tab_coeffs3(q)=maskC(i_cur(q),j_cur(q),k,bi,bj) |
79 |
elseif (type_cur.EQ.3) then |
80 |
tab_coeffs1(q)=uVel(i_cur(q),j_cur(q),k,bi,bj) |
81 |
tab_coeffs3(q)=maskW(i_cur(q),j_cur(q),k,bi,bj) |
82 |
elseif (type_cur.EQ.4) then |
83 |
tab_coeffs1(q)=vVel(i_cur(q),j_cur(q),k,bi,bj) |
84 |
tab_coeffs3(q)=maskS(i_cur(q),j_cur(q),k,bi,bj) |
85 |
elseif (type_cur.EQ.5) then |
86 |
#ifdef ALLOW_PTRACERS |
87 |
cgf if this gets used, an additional common block could be defined, containing |
88 |
cgf the pTracer number (now 1, hard-coded), that would be read from the .nc input file |
89 |
tab_coeffs1(q)=pTracer(i_cur(q),j_cur(q),k,bi,bj,1) |
90 |
#else |
91 |
tab_coeffs1(q)=0 |
92 |
#endif |
93 |
tab_coeffs3(q)=maskC(i_cur(q),j_cur(q),k,bi,bj) |
94 |
elseif (type_cur.EQ.6) then |
95 |
tab_coeffs1(q)=etan(i_cur(q),j_cur(q),bi,bj) |
96 |
tab_coeffs3(q)=maskC(i_cur(q),j_cur(q),1,bi,bj) |
97 |
else |
98 |
tab_coeffs1(q)=0. |
99 |
tab_coeffs3(q)=0. |
100 |
endif |
101 |
|
102 |
ponderations(q)=tab_coeffs3(q)*weights_cur(q) |
103 |
pondsSUM=pondsSUM+ponderations(q) |
104 |
enddo |
105 |
|
106 |
if (pondsSUM.GT.0) then |
107 |
mask_cur(k)=1 |
108 |
traj_cur(k)=0 |
109 |
do q=1,NUM_INTERP_POINTS |
110 |
traj_cur(k)=traj_cur(k)+tab_coeffs1(q)*ponderations(q)/pondsSUM |
111 |
enddo |
112 |
else |
113 |
traj_cur(k)=0 |
114 |
mask_cur(k)=0 |
115 |
endif |
116 |
|
117 |
enddo |
118 |
|
119 |
cgf vertical interpolation: |
120 |
do kk=1,NLEVELMAX |
121 |
traj_cur_out(kk)=0 |
122 |
prof_mask1D_cur(kk,bi,bj)=0 |
123 |
enddo |
124 |
do kk=1,ProfDepthNo(file_cur,bi,bj) |
125 |
c case 1: above first grid center=> first grid center value |
126 |
if (prof_depth(file_cur,kk,bi,bj).LT.-rC(1)) then |
127 |
traj_cur_out(kk)=traj_cur(1) |
128 |
prof_mask1D_cur(kk,bi,bj)=mask_cur(1) |
129 |
c case 2: just below last grid center=> last cell value |
130 |
elseif (prof_depth(file_cur,kk,bi,bj).GE.-rC(nr)) then |
131 |
if ( prof_depth(file_cur,kk,bi,bj) .LT. |
132 |
& (-rC(nr)+drC(nr)/2) ) then |
133 |
traj_cur_out(kk)=traj_cur(nr) |
134 |
prof_mask1D_cur(kk,bi,bj)=mask_cur(nr) |
135 |
endif |
136 |
c case 3: between two grid centers |
137 |
else |
138 |
kcur=0 |
139 |
do k=1,nr-1 |
140 |
if ((prof_depth(file_cur,kk,bi,bj).GE.-rC(k)).AND. |
141 |
& (prof_depth(file_cur,kk,bi,bj).LT.-rC(k+1))) then |
142 |
kcur=k |
143 |
endif |
144 |
enddo |
145 |
if (kcur.EQ.0) then |
146 |
WRITE(errorMessageUnit,'(A)') |
147 |
& 'ERROR in PROFILES_INTERP: unexpected case 1' |
148 |
STOP 'ABNORMAL END: S/R PROFILES_INTERP' |
149 |
endif |
150 |
if (mask_cur(kcur+1).EQ.1.) then |
151 |
c subcase 1: 2 wet points=>linear interpolation |
152 |
tmp_coeff=(prof_depth(file_cur,kk,bi,bj)+rC(kcur))/ |
153 |
& (-rC(kcur+1)+rC(kcur)) |
154 |
traj_cur_out(kk)=(1-tmp_coeff)*traj_cur(kcur) |
155 |
& +tmp_coeff*traj_cur(kcur+1) |
156 |
prof_mask1D_cur(kk,bi,bj)=1 |
157 |
if (mask_cur(kcur).EQ.0.) then |
158 |
WRITE(errorMessageUnit,'(A)') |
159 |
& 'ERROR in PROFILES_INTERP: unexpected case 2' |
160 |
STOP 'ABNORMAL END: S/R PROFILES_INTERP' |
161 |
endif |
162 |
elseif (prof_depth(file_cur,kk,bi,bj).LT.-rF(kcur+1)) then |
163 |
c subcase 2: only 1 wet point just above=>upper cell value |
164 |
traj_cur_out(kk)=traj_cur(kcur) |
165 |
prof_mask1D_cur(kk,bi,bj)=mask_cur(kcur) |
166 |
endif |
167 |
endif |
168 |
enddo |
169 |
|
170 |
|
171 |
#endif |
172 |
|
173 |
end |
174 |
|