1 |
C $Header: /u/gcmpack/models/MITgcmUV/pkg/zonal_filt/zonal_filter.F,v 1.4 2001/04/10 22:35:27 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ZONAL_FILT_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE ZONAL_FILTER( |
7 |
U field, fieldMask, |
8 |
I jMin, jMax, kMin, kMax, bi, bj, gridLoc, myThid ) |
9 |
C /==========================================================\ |
10 |
C | S/R ZONAL_FILTER | |
11 |
C | o Apply FFT filter to a latitude circle. | |
12 |
C \==========================================================/ |
13 |
IMPLICIT NONE |
14 |
|
15 |
C == Global data == |
16 |
#include "SIZE.h" |
17 |
#include "EEPARAMS.h" |
18 |
#include "PARAMS.h" |
19 |
#include "GRID.h" |
20 |
#include "ZONAL_FILT.h" |
21 |
#include "FFTPACK.h" |
22 |
|
23 |
C == Routine arguments == |
24 |
C jMin - Range of points to filter |
25 |
C jMax |
26 |
C kMin |
27 |
C kMax |
28 |
C bi |
29 |
C bj |
30 |
C myThid - Thread number of this instance of FILTER_LATCIRC_FFT_APPLY |
31 |
C field - Field to filter |
32 |
C gridLoc - Orientation (U or V) of field. |
33 |
INTEGER myThid |
34 |
INTEGER gridLoc |
35 |
Real*8 field(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
36 |
Real*8 fieldMask(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
37 |
INTEGER jMin, jMax, kMin, kMax, bi, bj |
38 |
|
39 |
#ifdef ALLOW_ZONAL_FILT |
40 |
|
41 |
C == Local data == |
42 |
Real*8 phi(Nx) |
43 |
Real*8 phiMask(Nx) |
44 |
Real*8 avPhi |
45 |
INTEGER I, J, K |
46 |
|
47 |
DO k=kMin, kMax |
48 |
DO j=jMin, jMax |
49 |
IF ( (gridLoc.EQ.1 .AND.ABS(yC(1,j,bi,bj)).GE.zonal_filt_lat) |
50 |
& .OR.(gridLoc.EQ.2 .AND.ABS(yG(2,j,bi,bj)).GE.zonal_filt_lat) |
51 |
& .OR. zonal_filt_mode2dx.EQ.2 ) THEN |
52 |
|
53 |
C o Copy zonal line of field into local workspace |
54 |
DO i=1,sNx |
55 |
phi(I) = field(i,j,k,bi,bj) |
56 |
phiMask(I) = fieldMask(i,j,k,bi,bj) |
57 |
ENDDO |
58 |
|
59 |
C Interpolate through land |
60 |
CALL ZONAL_FILT_PRESMOOTH( phiMask,phi,avPhi,sNx,myThid ) |
61 |
|
62 |
C o Forward transform (using specific FFT package) |
63 |
C CALL R8FFTF( Nx, phi, FFTPACKWS(1,bj) ) |
64 |
CALL R8FFTF1( Nx, phi, |
65 |
& FFTPACKWS1(1,bj), FFTPACKWS2(1,bj),FFTPACKWS3(1,bj) ) |
66 |
|
67 |
C o Apply amplitude filter and normalize |
68 |
IF (gridLoc .EQ. 1) THEN |
69 |
DO i=1, Nx |
70 |
phi(i)=phi(i)*ampFactor(i,j,bi,bj)/float(Nx) |
71 |
ENDDO |
72 |
ELSEIF (gridLoc .EQ. 2) THEN |
73 |
DO i=1, Nx |
74 |
phi(i)=phi(i)*ampFactorV(i,j,bi,bj)/float(Nx) |
75 |
ENDDO |
76 |
ELSE |
77 |
WRITE(*,*) 'Error: gridLoc = ',gridLoc |
78 |
STOP 'Error: gridLoc has illegal value' |
79 |
ENDIF |
80 |
|
81 |
C o Backward transform (using specific FFT package) |
82 |
C CALL R8FFTB( Nx, phi, FFTPACKWS(1,bj) ) |
83 |
CALL R8FFTB1( Nx, phi, |
84 |
& FFTPACKWS1(1,bj), FFTPACKWS2(1,bj),FFTPACKWS3(1,bj) ) |
85 |
|
86 |
C De-interpolate through land |
87 |
CALL ZONAL_FILT_POSTSMOOTH(phiMask,phi,avPhi,sNx,myThid) |
88 |
|
89 |
C o Do periodic wrap around by hand |
90 |
DO i=1-OLx,0 |
91 |
field(i,j,k,bi,bj) = phi(sNx+i) |
92 |
ENDDO |
93 |
DO i=1,sNx |
94 |
field(i,j,k,bi,bj) = phi(I) |
95 |
ENDDO |
96 |
DO i=sNx+1,sNx+OLx |
97 |
field(i,j,k,bi,bj) = phi(i-sNx) |
98 |
ENDDO |
99 |
|
100 |
ENDIF |
101 |
ENDDO |
102 |
ENDDO |
103 |
|
104 |
#endif /* ALLOW_ZONAL_FILT */ |
105 |
|
106 |
RETURN |
107 |
END |