source: dynamico_lmdz/aquaplanet/LMDZ5/libf/phylmd/mod_grid_phy_lmdz.F90 @ 3983

Last change on this file since 3983 was 3825, checked in by ymipsl, 10 years ago

Reorganize geometry and grid modules. Prepare physics for unstructutured grid support. Simplify initialization of physics from dynamic.
Compiled only with dynd3dmem, but not tested for moment.

YM

File size: 11.8 KB
Line 
1MODULE mod_grid_phy_lmdz
2
3  PUBLIC
4  PRIVATE :: grid1dTo2d_glo_igen, grid1dTo2d_glo_rgen, grid1dTo2d_glo_lgen, &
5             grid2dTo1d_glo_igen, grid2dTo1d_glo_rgen, grid2dTo1d_glo_lgen
6 
7  INTEGER,PARAMETER :: unstructured=0
8  INTEGER,PARAMETER :: regular_lonlat=1
9
10  INTEGER,SAVE :: grid_type
11  INTEGER,SAVE :: nvertex
12  INTEGER,SAVE :: nbp_lon  ! == iim
13  INTEGER,SAVE :: nbp_lat  ! == jjmp1
14  INTEGER,SAVE :: nbp_lev  ! == llm
15  INTEGER,SAVE :: klon_glo
16
17
18  INTERFACE grid1dTo2d_glo
19    MODULE PROCEDURE grid1dTo2d_glo_i,grid1dTo2d_glo_i1,grid1dTo2d_glo_i2,grid1dTo2d_glo_i3, &
20                     grid1dTo2d_glo_r,grid1dTo2d_glo_r1,grid1dTo2d_glo_r2,grid1dTo2d_glo_r3, &
21                     grid1dTo2d_glo_l,grid1dTo2d_glo_l1,grid1dTo2d_glo_l2,grid1dTo2d_glo_l3
22   END INTERFACE
23
24   INTERFACE grid2dTo1d_glo
25    MODULE PROCEDURE grid2dTo1d_glo_i,grid2dTo1d_glo_i1,grid2dTo1d_glo_i2,grid2dTo1d_glo_i3, &
26                     grid2dTo1d_glo_r,grid2dTo1d_glo_r1,grid2dTo1d_glo_r2,grid2dTo1d_glo_r3, &
27                     grid2dTo1d_glo_l,grid2dTo1d_glo_l1,grid2dTo1d_glo_l2,grid2dTo1d_glo_l3
28   END INTERFACE
29 
30CONTAINS
31
32!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33!! SUBROUTINE grid1dTo2d  !! 
34!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
36
37  SUBROUTINE init_grid_phy_lmdz(grid_type_,nvertex_,nbp_lon_,nbp_lat_,nbp_lev_)
38  IMPLICIT NONE
39  INTEGER,INTENT(IN)  :: grid_type_
40  INTEGER,INTENT(IN)  :: nvertex_
41  INTEGER, INTENT(IN) :: nbp_lon_
42  INTEGER, INTENT(IN) :: nbp_lat_
43  INTEGER, INTENT(IN) :: nbp_lev_
44 
45    grid_type = grid_type_
46    nvertex   = nvertex_
47    nbp_lon   = nbp_lon_
48    nbp_lat   = nbp_lat_
49    nbp_lev   = nbp_lev_
50    klon_glo  = (nbp_lon*nbp_lat)-2*(nbp_lon-1)
51 
52  END SUBROUTINE init_grid_phy_lmdz
53 
54 
55  SUBROUTINE grid1dTo2d_glo_i(VarIn,VarOut) 
56  IMPLICIT NONE 
57    INTEGER,INTENT(IN),DIMENSION(:)     :: VarIn
58    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
59   
60    CALL grid1dTo2d_glo_igen(VarIn,VarOut,1)
61 
62  END SUBROUTINE grid1dTo2d_glo_i
63 
64
65  SUBROUTINE grid1dTo2d_glo_i1(VarIn,VarOut) 
66  IMPLICIT NONE 
67    INTEGER,INTENT(IN),DIMENSION(:,:)     :: VarIn
68    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
69   
70    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2))
71 
72  END SUBROUTINE grid1dTo2d_glo_i1
73
74  SUBROUTINE grid1dTo2d_glo_i2(VarIn,VarOut) 
75  IMPLICIT NONE 
76    INTEGER,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
77    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
78   
79    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
80 
81  END SUBROUTINE grid1dTo2d_glo_i2
82 
83  SUBROUTINE grid1dTo2d_glo_i3(VarIn,VarOut) 
84  IMPLICIT NONE 
85    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
86    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
87   
88    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
89 
90  END SUBROUTINE grid1dTo2d_glo_i3
91
92
93  SUBROUTINE grid1dTo2d_glo_r(VarIn,VarOut) 
94  IMPLICIT NONE 
95    REAL,INTENT(IN),DIMENSION(:)     :: VarIn
96    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
97   
98    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,1)
99 
100  END SUBROUTINE grid1dTo2d_glo_r
101 
102
103  SUBROUTINE grid1dTo2d_glo_r1(VarIn,VarOut) 
104  IMPLICIT NONE 
105    REAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
106    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
107   
108    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2))
109 
110  END SUBROUTINE grid1dTo2d_glo_r1
111
112  SUBROUTINE grid1dTo2d_glo_r2(VarIn,VarOut) 
113  IMPLICIT NONE 
114    REAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
115    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
116   
117    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
118 
119  END SUBROUTINE grid1dTo2d_glo_r2
120 
121  SUBROUTINE grid1dTo2d_glo_r3(VarIn,VarOut) 
122  IMPLICIT NONE 
123    REAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
124    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
125   
126    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
127 
128  END SUBROUTINE grid1dTo2d_glo_r3
129 
130 
131 
132  SUBROUTINE grid1dTo2d_glo_l(VarIn,VarOut) 
133  IMPLICIT NONE 
134    LOGICAL,INTENT(IN),DIMENSION(:)     :: VarIn
135    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
136   
137    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,1)
138 
139  END SUBROUTINE grid1dTo2d_glo_l
140 
141
142  SUBROUTINE grid1dTo2d_glo_l1(VarIn,VarOut) 
143  IMPLICIT NONE 
144    LOGICAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
145    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
146   
147    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2))
148 
149  END SUBROUTINE grid1dTo2d_glo_l1
150
151  SUBROUTINE grid1dTo2d_glo_l2(VarIn,VarOut) 
152  IMPLICIT NONE 
153    LOGICAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
154    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
155   
156    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
157 
158  END SUBROUTINE grid1dTo2d_glo_l2
159 
160  SUBROUTINE grid1dTo2d_glo_l3(VarIn,VarOut) 
161  IMPLICIT NONE 
162    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
163    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
164   
165    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
166 
167  END SUBROUTINE grid1dTo2d_glo_l3 
168 
169    SUBROUTINE grid2dTo1d_glo_i(VarIn,VarOut) 
170  IMPLICIT NONE 
171    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
172    INTEGER,INTENT(OUT),DIMENSION(:)  :: VarOut
173   
174    CALL grid2dTo1d_glo_igen(VarIn,VarOut,1)
175 
176  END SUBROUTINE grid2dTo1d_glo_i
177 
178
179  SUBROUTINE grid2dTo1d_glo_i1(VarIn,VarOut) 
180  IMPLICIT NONE 
181    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
182    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
183   
184    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3))
185 
186  END SUBROUTINE grid2dTo1d_glo_i1
187
188  SUBROUTINE grid2dTo1d_glo_i2(VarIn,VarOut) 
189  IMPLICIT NONE 
190    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
191    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
192   
193    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
194 
195  END SUBROUTINE grid2dTo1d_glo_i2
196 
197  SUBROUTINE grid2dTo1d_glo_i3(VarIn,VarOut) 
198  IMPLICIT NONE 
199    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
200    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
201   
202    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
203 
204  END SUBROUTINE grid2dTo1d_glo_i3
205 
206
207
208
209  SUBROUTINE grid2dTo1d_glo_r(VarIn,VarOut) 
210  IMPLICIT NONE 
211    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
212    REAL,INTENT(OUT),DIMENSION(:)  :: VarOut
213   
214    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,1)
215 
216  END SUBROUTINE grid2dTo1d_glo_r
217 
218
219  SUBROUTINE grid2dTo1d_glo_r1(VarIn,VarOut) 
220  IMPLICIT NONE 
221    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
222    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
223   
224    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3))
225 
226  END SUBROUTINE grid2dTo1d_glo_r1
227
228  SUBROUTINE grid2dTo1d_glo_r2(VarIn,VarOut) 
229  IMPLICIT NONE 
230    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
231    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
232   
233    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
234 
235  END SUBROUTINE grid2dTo1d_glo_r2
236 
237  SUBROUTINE grid2dTo1d_glo_r3(VarIn,VarOut) 
238  IMPLICIT NONE 
239    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
240    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
241   
242    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
243 
244  END SUBROUTINE grid2dTo1d_glo_r3
245
246
247
248  SUBROUTINE grid2dTo1d_glo_l(VarIn,VarOut) 
249  IMPLICIT NONE 
250    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
251    LOGICAL,INTENT(OUT),DIMENSION(:)  :: VarOut
252   
253    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,1)
254 
255  END SUBROUTINE grid2dTo1d_glo_l
256 
257
258  SUBROUTINE grid2dTo1d_glo_l1(VarIn,VarOut) 
259  IMPLICIT NONE 
260    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
261    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
262   
263    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3))
264 
265  END SUBROUTINE grid2dTo1d_glo_l1
266
267  SUBROUTINE grid2dTo1d_glo_l2(VarIn,VarOut) 
268  IMPLICIT NONE 
269    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
270    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
271   
272    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
273 
274  END SUBROUTINE grid2dTo1d_glo_l2
275 
276  SUBROUTINE grid2dTo1d_glo_l3(VarIn,VarOut) 
277  IMPLICIT NONE 
278    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
279    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
280   
281    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
282 
283  END SUBROUTINE grid2dTo1d_glo_l3
284
285!----------------------------------------------------------------
286!  Generic (private) fonctions
287!----------------------------------------------------------------
288 
289  SUBROUTINE grid1dTo2d_glo_igen(VarIn,VarOut,dimsize)
290
291    IMPLICIT NONE
292
293    INTEGER,INTENT(IN) :: dimsize
294    INTEGER,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
295    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
296    INTEGER :: i,ij,Offset
297
298   
299    Offset=nbp_lon
300       
301    DO i=1,dimsize
302      DO ij=1,klon_glo
303        VarOut(ij+offset-1,i)=VarIn(ij,i)
304      ENDDO
305    ENDDO
306   
307   
308    DO i=1,dimsize
309      DO ij=1,nbp_lon
310       VarOut(ij,i)=VarIn(1,i)
311      ENDDO
312    ENDDO
313   
314   
315    DO i=1,dimsize
316      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
317       VarOut(ij,i)=VarIn(klon_glo,i)
318      ENDDO
319    ENDDO
320
321  END SUBROUTINE grid1dTo2d_glo_igen   
322
323
324  SUBROUTINE grid1dTo2d_glo_rgen(VarIn,VarOut,dimsize)
325
326    IMPLICIT NONE
327
328    INTEGER,INTENT(IN) :: dimsize
329    REAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
330    REAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
331    INTEGER :: i,ij,Offset
332
333   
334    Offset=nbp_lon
335       
336    DO i=1,dimsize
337      DO ij=1,klon_glo
338        VarOut(ij+offset-1,i)=VarIn(ij,i)
339      ENDDO
340    ENDDO
341   
342   
343    DO i=1,dimsize
344      DO ij=1,nbp_lon
345       VarOut(ij,i)=VarIn(1,i)
346      ENDDO
347    ENDDO
348   
349   
350    DO i=1,dimsize
351      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
352       VarOut(ij,i)=VarIn(klon_glo,i)
353      ENDDO
354    ENDDO
355
356  END SUBROUTINE grid1dTo2d_glo_rgen   
357
358  SUBROUTINE grid1dTo2d_glo_lgen(VarIn,VarOut,dimsize)
359
360    IMPLICIT NONE
361   
362    INTEGER,INTENT(IN) :: dimsize
363    LOGICAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
364    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
365    INTEGER :: i,ij,Offset
366
367    Offset=nbp_lon
368       
369    DO i=1,dimsize
370      DO ij=1,klon_glo
371        VarOut(ij+offset-1,i)=VarIn(ij,i)
372      ENDDO
373    ENDDO
374   
375   
376    DO i=1,dimsize
377      DO ij=1,nbp_lon
378       VarOut(ij,i)=VarIn(1,i)
379      ENDDO
380    ENDDO
381   
382   
383    DO i=1,dimsize
384      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
385       VarOut(ij,i)=VarIn(klon_glo,i)
386      ENDDO
387    ENDDO
388
389  END SUBROUTINE grid1dTo2d_glo_lgen     
390 
391 
392  SUBROUTINE grid2dTo1d_glo_igen(VarIn,VarOut,dimsize)
393
394    IMPLICIT NONE
395
396    INTEGER,INTENT(IN) :: dimsize
397    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
398    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
399    INTEGER :: i,ij,offset
400
401    offset=nbp_lon
402
403    DO i=1,dimsize
404      DO ij=1,klon_glo
405        VarOut(ij,i)=VarIn(ij+offset-1,i)
406      ENDDO
407    ENDDO
408
409    DO i=1,dimsize
410      VarOut(1,i)=VarIn(1,i)
411    ENDDO
412   
413  END SUBROUTINE grid2dTo1d_glo_igen   
414 
415  SUBROUTINE grid2dTo1d_glo_rgen(VarIn,VarOut,dimsize)
416
417    IMPLICIT NONE
418
419    INTEGER,INTENT(IN) :: dimsize
420    REAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
421    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
422    INTEGER :: i,ij,offset
423
424    offset=nbp_lon
425
426    DO i=1,dimsize
427      DO ij=1,klon_glo
428        VarOut(ij,i)=VarIn(ij+offset-1,i)
429      ENDDO
430    ENDDO
431
432    DO i=1,dimsize
433      VarOut(1,i)=VarIn(1,i)
434    ENDDO
435   
436  END SUBROUTINE grid2dTo1d_glo_rgen
437   
438  SUBROUTINE grid2dTo1d_glo_lgen(VarIn,VarOut,dimsize)
439
440    IMPLICIT NONE
441
442    INTEGER,INTENT(IN) :: dimsize
443    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
444    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
445    INTEGER :: i,ij,offset
446
447    offset=nbp_lon
448
449    DO i=1,dimsize
450      DO ij=1,klon_glo
451        VarOut(ij,i)=VarIn(ij+offset-1,i)
452      ENDDO
453    ENDDO
454
455    DO i=1,dimsize
456      VarOut(1,i)=VarIn(1,i)
457    ENDDO
458   
459  END SUBROUTINE grid2dTo1d_glo_lgen   
460
461END MODULE mod_grid_phy_lmdz
Note: See TracBrowser for help on using the repository browser.