source: tags/LIM1D_v3.20/SOURCES/source_3.20/ice_phy_relay.f @ 6

Last change on this file since 6 was 6, checked in by vancop, 8 years ago

initial import of v3.20 /Users/ioulianikolskaia/Boulot/CODES/LIM1D/ARCHIVE/TMP/LIM1D_v3.20/

File size: 4.8 KB
Line 
1      SUBROUTINE ice_phy_relay( nbot0 , nbot1 , ntop0 , ntop1 , !zl0,zl1,
2     &                          hl0, hl1, ql0, ql1 )
3
4      !!------------------------------------------------------------------
5      !!                ***         ROUTINE ice_phy_relay     ***
6      !!
7      !! ** Purpose :
8      !! This routine redistributes the scalar quantity ql0 - distributed on layers of
9      !! lower boundary limit zl0 - onto new scalars ql1 on a new grid - described by
10      !! zl1.
11      !!       rl01(i,j) represents linear weights of old layers into the new ones.
12      !!       index of top layer --> ntop0/1
13      !!       index of bottom layer --> nbot0/1
14      !!
15      !! ** Method  : Relayering
16      !!           
17      !! ** Steps
18      !!
19      !! ** Arguments
20      !!
21      !! ** Inputs / Outputs
22      !!
23      !! ** External
24      !!
25      !! ** References : Vancop. et al., 2007
26      !!
27      !! ** History  :
28      !!    (12-2002) Martin Vancop. First test
29      !!    (06-2003) Martin Vancop. LIM1D
30      !!    (06-2008) Martin Vancop. BIO-LIM
31      !!    (09-2008) Martin Vancop. Explicit gravity drainage
32      !!
33      !!------------------------------------------------------------------
34
35      INCLUDE 'para.com'
36      INCLUDE 'type.com'
37      INCLUDE 'const.com'
38      INCLUDE 'ice.com'
39      INCLUDE 'thermo.com'
40 
41      REAL(8), DIMENSION ( maxnlay ) ::
42     &  ql0         !: old scalar
43
44      REAL(8), DIMENSION ( maxnlay + 2 ) ::
45     &  hl0         !: old layer thickness
46
47      REAL(8), DIMENSION ( maxnlay ) ::
48     &  ql1      ,  !: new scalar
49     &  hl1         !: old layer thickness
50
51      REAL(8), DIMENSION ( 0:maxnlay ) ::
52     &  zl0      ,  !: old layer interfaces
53     &  zl1         !: new layer interfaces
54
55      REAL(8), DIMENSION ( nbot1, nbot0 ) ::
56     &  rl01        !: relayering matrix
57
58      INTEGER ::
59     &  layer1   ,  !: first layer index
60     &  layer2      !: second layer index
61
62      LOGICAL ::
63     &  ln_write
64      zlimit = 1.0e-10   !: limiting factor to avoid divisions per 0
65      ln_write = .FALSE.
66      ql1(:) = 0.0
67!
68!==============================================================================!
69
70        zl0(0)     = 0.0
71        zl0(ntop0) = hl0(ntop0)
72        DO layer0 = ntop0+1, nbot0
73           zl0(layer0) = zl0(layer0-1) + hl0(layer0)
74        END DO
75
76        zl1(0)     = 0.0
77        zl1(ntop1) = hl1(ntop1)
78        DO layer1 = ntop1+1, nbot1
79           zl1(layer1) = zl1(layer1-1) + hl1(layer1)
80        END DO
81
82      IF ( ln_write ) THEN
83         WRITE(numout,*) ' ** ice_phy_relay : '
84         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~ '
85         WRITE(numout,*) 
86         WRITE(numout,*) ' Input... '
87         WRITE(numout,*) ' ql0 : ', ( ql0(jk), jk = 1, nbot0 )
88         WRITE(numout,*) ' nbot0 : ', nbot0 
89         WRITE(numout,*) ' nbot1 : ', nbot1 
90         WRITE(numout,*) ' ntop0 : ', ntop0
91         WRITE(numout,*) ' ntop1 : ', ntop1
92         WRITE(numout,*) ' zl0   : ', ( zl0(jk), jk = ntop0, nbot0 )
93         WRITE(numout,*) ' zl1   : ', ( zl1(jk), jk = ntop1, nbot1 )
94         WRITE(numout,*) ' hl0   : ', ( hl0(layer0), 
95     &                                layer0 = ntop0, nbot0 )
96         WRITE(numout,*) ' hl1   : ', ( hl1(layer1), 
97     &                                layer1 = ntop1, nbot1 )
98      ENDIF
99!
100!------------------------------------------------------------------------------|
101!  1) Relayering procedure                                                     |
102!------------------------------------------------------------------------------|
103!
104        !---------
105        ! weights
106        !---------
107        DO layer1 = ntop1, nbot1
108           DO layer0 = ntop0, nbot0
109               rl01(layer1,layer0) = MAX( 0.0 , ( MIN(zl0(layer0), 
110     &         zl1(layer1)) - MAX(zl0(layer0-1), zl1(layer1-1) ) ) / 
111     &         MAX( hl0(layer0) , zlimit ) ) 
112               IF (ln_write) WRITE(numout,*) ' Weight : ', 
113     &                       layer0, layer1, rl01(layer1,layer0)
114           END DO
115        END DO
116
117        !-------------
118        ! new scalars
119        !-------------
120        IF (ln_write) WRITE(numout,*) ' Redistribution of the scalar '
121        DO layer1 = ntop1, nbot1
122           ql1(layer1) = 0.0
123           DO layer0 = ntop0, nbot0
124     
125              ql1(layer1) = ql1(layer1) + 
126     &                         rl01(layer1,layer0) * ql0(layer0)
127              IF (ln_write) WRITE(numout,*) ' ql1 : ', ql1(layer1)
128              IF (ln_write) WRITE(numout,*) ' ql0 : ', ql0(layer0)
129              IF (ln_write) WRITE(numout,*) ' rl01: ', 
130     &                      rl01(layer1,layer0)
131           END DO
132        END DO
133
134        IF (ln_write) WRITE(numout,*) ' ql1 : ', 
135     &                ( ql1(jk), jk = ntop1, nbot1 )
136
137        RETURN
138!------------------------------------------------------------------------------!
139      END SUBROUTINE
Note: See TracBrowser for help on using the repository browser.