1 |
C $Header: /u/gcmpack/MITgcm_contrib/gael/pkg/smooth2/smooth_correl2D.F,v 1.1 2009/10/25 21:24:03 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "SMOOTH_OPTIONS.h" |
5 |
|
6 |
subroutine smooth_correl2D ( |
7 |
U fld_in,mask_in,smoothOpNb,mythid) |
8 |
|
9 |
C *==========================================================* |
10 |
C | SUBROUTINE smooth_correl2D |
11 |
C | o Routine that applies spatial correlation |
12 |
C | operator to a 2D control field |
13 |
C *==========================================================* |
14 |
|
15 |
IMPLICIT NONE |
16 |
#include "SIZE.h" |
17 |
#include "EEPARAMS.h" |
18 |
#include "GRID.h" |
19 |
#include "PARAMS.h" |
20 |
c#include "tamc.h" |
21 |
#include "SMOOTH.h" |
22 |
|
23 |
_RL mask_in(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nR,nSx,nSy) |
24 |
_RL fld_in(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
25 |
integer smoothOpNb |
26 |
integer nbt_in |
27 |
character*( 80) fnamegeneric |
28 |
integer i,j,bi,bj |
29 |
integer itlo,ithi |
30 |
integer jtlo,jthi |
31 |
integer myThid |
32 |
|
33 |
|
34 |
jtlo = mybylo(mythid) |
35 |
jthi = mybyhi(mythid) |
36 |
itlo = mybxlo(mythid) |
37 |
ithi = mybxhi(mythid) |
38 |
|
39 |
|
40 |
c read smoothing [i.e diffusion] operator: |
41 |
write(fnamegeneric(1:80),'(1a,i3.3)') |
42 |
& 'smooth2Doperator',smoothOpNb |
43 |
CALL READ_REC_3D_RL(fnamegeneric,smoothprec, |
44 |
& 1, smooth2D_Kux,1,1,mythid) |
45 |
CALL READ_REC_3D_RL(fnamegeneric,smoothprec, |
46 |
& 1, smooth2D_Kvy,2,1,mythid) |
47 |
_EXCH_XY_RL ( smooth2D_Kux, myThid ) |
48 |
_EXCH_XY_RL ( smooth2D_Kvy, myThid ) |
49 |
|
50 |
c read normalization field [i.e. 1/sqrt(var(filter))]: |
51 |
write(fnamegeneric(1:80),'(1a,i3.3)') |
52 |
& 'smooth2Dnorm',smoothOpNb |
53 |
CALL READ_REC_3D_RL(fnamegeneric,smoothprec, |
54 |
& 1, smooth2Dnorm,1,1,mythid) |
55 |
_EXCH_XY_RL ( smooth2Dnorm, myThid ) |
56 |
|
57 |
c division by ~sqrt(area): |
58 |
DO bj = jtlo,jthi |
59 |
DO bi = itlo,ithi |
60 |
DO j = 1,sNy |
61 |
DO i = 1,sNx |
62 |
fld_in(i,j,bi,bj)=fld_in(i,j,bi,bj) |
63 |
& *sqrt(recip_rA(i,j,bi,bj)) |
64 |
ENDDO |
65 |
ENDDO |
66 |
ENDDO |
67 |
ENDDO |
68 |
_EXCH_XY_RL ( fld_in , myThid ) |
69 |
|
70 |
c do the smoothing: |
71 |
nbt_in=smooth2Dnbt(smoothOpNb)/2 |
72 |
call smooth_diff2D(fld_in,mask_in,nbt_in,mythid) |
73 |
|
74 |
c division by ~sqrt(var(filter)): |
75 |
do bj = jtlo,jthi |
76 |
do bi = itlo,ithi |
77 |
DO j = 1,sNy |
78 |
DO i = 1,sNx |
79 |
fld_in(i,j,bi,bj)=fld_in(i,j,bi,bj) |
80 |
& *smooth2Dnorm(i,j,bi,bj) |
81 |
ENDDO |
82 |
ENDDO |
83 |
ENDDO |
84 |
ENDDO |
85 |
_EXCH_XY_RL ( fld_in , myThid ) |
86 |
|
87 |
end |