source: CPL/oasis3/trunk/src/mod/oasis3/src/subgrid.f @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 6.9 KB
Line 
1      SUBROUTINE subgrid (pfldn, pfldo, ksizn, ksizo,
2     $                    pcoar, pfine, pdqdt,
3     $                    cdfic, kunit, knumb, cdname,
4     $                    pwork, kwork, knbor, ldread, cdtype)
5C****
6C               *****************************
7C               * OASIS ROUTINE  -  LEVEL 3 *
8C               * -------------     ------- *
9C               *****************************
10C
11C**** *subgrid* - submesh variabiity
12C
13C     Purpose:
14C     -------
15C     Interpolate with subgrid linear technique. This is  rigorously
16C     conservative if the models exchange fields at every timestep
17C     and if sea-land mismatch is accounted for.
18C
19C**   Interface:
20C     ---------
21C       *CALL*  *subgrid (pfild, ksize, pcoar, pfine, pdqdt)*
22C
23C     Input:
24C     -----
25C                pfldo  : initial field on source grid (real 1D)
26C                ksizn  : size of final field array (integer)
27C                ksizo  : size of initial field array (integer)
28C                pcoar  : coarse grid additional field (real 1D)
29C                pfine  : fine grid additional field (real 1D)
30C                pdqdt  : coarse grid coupling ratio (real 1D)
31C                kunit  : logical unit numbers for subgrid file (integer)
32C                cdfic  : filename for subgrid data (character)
33C                knumb  : subgrid dataset identity number (integer)
34C                cdname : name of final field on target grid (character)
35C                pwork  : temporary array to read subgrid weights (real 1D)
36C                kwork  : temporary array to read subgrid array (integer 1D)
37C                knbor  : maximum number of source grid neighbors with non zero
38C                         intersection with a target grid-square (integer)
39C                         The source grid is here the coarse grid while the
40C                         target grid is the fine one.
41C                ldread : logical flag to read subgrid data (logical)
42C                cdtype : type of subgrid interpolation (character)
43C
44C     Output:
45C     ------
46C                pfldn  : final field on target grid (real 1D)
47C
48C     Workspace:
49C     ---------
50C     None
51C
52C     Externals:
53C     ---------
54C     None
55C
56C     Reference:
57C     ---------
58C     See OASIS manual (1995)
59C
60C     History:
61C     -------
62C       Version   Programmer     Date      Description
63C       -------   ----------     ----      ----------- 
64C       2.0       L. Terray      96/02/01  created
65C       2.1       L. Terray      96/08/05  modified: new structure
66C       2.3       S. Valcke      99/04/30  added: printing levels
67C
68C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69C
70C* ---------------------------- Include files ---------------------------
71C
72      USE mod_kinds_oasis
73      USE mod_unit
74      USE mod_printing
75C
76C* ---------------------------- Argument declarations -------------------
77C
78      REAL (kind=ip_realwp_p) pfldn(ksizn), pfldo(ksizo)
79      REAL (kind=ip_realwp_p) pcoar(ksizo), pfine(ksizn), pdqdt(ksizo)
80      REAL (kind=ip_realwp_p) pwork(knbor,ksizn)
81      INTEGER (kind=ip_intwp_p) kwork(knbor,ksizn)
82      CHARACTER*8 cdfic, cdname, cdtype
83      LOGICAL ldread
84C
85C* ---------------------------- Local declarations ----------------------
86C
87      CHARACTER*8 clweight, cladress
88C
89C* ---------------------------- Poema verses ----------------------------
90C
91C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92C
93C*    1. Initialization
94C        --------------
95C
96      IF (nlogprt .GE. 2) THEN
97          WRITE (UNIT = nulou,FMT = *) ' '
98          WRITE (UNIT = nulou,FMT = *) ' '
99          WRITE (UNIT = nulou,FMT = *) 
100     $    '           ROUTINE subgrid  -  Level 3'
101          WRITE (UNIT = nulou,FMT = *) 
102     $    '           ***************     *******'
103          WRITE (UNIT = nulou,FMT = *) ' '
104          WRITE (UNIT = nulou,FMT = *) ' Linear subgrid interpolation'
105          WRITE (UNIT = nulou,FMT = *) ' '
106          WRITE (UNIT = nulou,FMT = *) ' '
107      ENDIF
108C
109C* initialize error flag for I/O routine
110C
111      iflag = 0
112C
113C
114C*    2. Read subgrid data the first time
115C        --------------------------------
116C
117      IF (ldread) THEN
118C
119C* Initialize locators and array sizes
120C
121          WRITE(clweight,'(''WEIGHTS'',I1)') knumb
122          WRITE(cladress,'(''ADRESSE'',I1)') knumb
123          isize = ksizn * knbor
124C
125C* Adress of overlapped points on source grid
126C
127          CALL locrint (cladress, kwork, isize, kunit, iflag)
128C
129C* Checking
130C
131          IF (iflag .NE. 0) THEN
132              CALL prcout
133     $            ('WARNING: problem in reading
134     $            subgrid data for field',
135     $            cdname, 1)
136              CALL prcout
137     $            ('Could not get adress array', cladress, 1)
138              CALL prtout
139     $            ('Error reading logical unit', kunit, 1)
140              CALL prcout
141     $            ('It is connected to file', cdfic, 1)
142              CALL HALTE ('STOP in subgrid') 
143          ENDIF
144C
145C* Weights of overlapped points on source grid
146C
147          CALL locread (clweight, pwork, isize, kunit, iflag)
148C
149C* Checking
150C
151          IF (iflag .NE. 0) THEN
152              CALL prcout
153     $            ('WARNING: problem in reading
154     $            subgrid data for field',
155     $            cdname, 1)
156              CALL prcout
157     $            ('Could not get weight array', clweight, 1)
158              CALL prtout
159     $            ('Error reading logical unit', kunit, 1)
160              CALL prcout
161     $            ('It is connected to file', cdfic, 1)
162              CALL HALTE ('STOP in subgrid') 
163          ENDIF
164          ldread = .FALSE. 
165      ENDIF
166C
167C
168C*    3. Modify main field according to type of subgrid interpolation
169C        ------------------------------------------------------------
170C* Case of non solar flux
171C
172      IF (cdtype .EQ. 'NONSOLAR') THEN
173C
174C* Loop on all target points
175C
176          DO 310 ji = 1, ksizn
177            zsum = 0.0
178C
179C* Loop on active neighbors
180C
181            DO 320 jk = 1, knbor
182              IF (kwork(jk,ji) .gt. 0) then
183              zsum = zsum + pwork(jk,ji) *
184     $            ( pfldo(kwork(jk,ji)) + pdqdt(kwork(jk,ji)) 
185     $            * ( pfine(ji) - pcoar(kwork(jk,ji)) ) )
186              ENDIF
187 320        CONTINUE
188            pfldn(ji) = zsum
189 310      CONTINUE
190C
191C* Case of solar flux
192C
193        ELSE IF (cdtype .EQ. 'SOLAR') THEN
194          DO 330 ji = 1, ksizn
195            zsum = 0.0
196C
197C* Loop on active neighbors
198C
199            DO 340 jk = 1, knbor
200              IF (kwork(jk,ji) .gt. 0) then
201              zsum = zsum + pwork(jk,ji) * pfldo(kwork(jk,ji)) *
202     $            ( 1. - pfine(ji)) / ( 1. - pcoar(kwork(jk,ji)))
203              ENDIF
204 340        CONTINUE
205            pfldn(ji) = zsum
206 330      CONTINUE
207      ENDIF
208C
209C
210C*    4. End of routine
211C        --------------
212C
213      IF (nlogprt .GE. 2) THEN
214          WRITE (UNIT = nulou,FMT = *) ' '
215          WRITE (UNIT = nulou,FMT = *) 
216     $    '          --------- End of routine subgrid ---------'
217          CALL FLUSH (nulou)
218      ENDIF
219      RETURN
220      END
221
222
223
224
Note: See TracBrowser for help on using the repository browser.