source: LMDZ6/branches/DYNAMICO-conv-GC/libf/phy_common/mod_grid_phy_lmdz.F90 @ 3626

Last change on this file since 3626 was 2351, checked in by Ehouarn Millour, 9 years ago

More on physics/dynamics separation and cleanup:

  • Set things up so that all physics-related initializations are done via iniphysiq.
  • Created a "geometry_mod.F90" module in phy_common to store information on the loacl grid (i.e. replaces comgeomphy) and moreover give these variables more obvious names (e.g.: rlond => longitude, rlatd => latitude, airephy => cell_area).
  • removed obsolete comgeomphy.h and comgeomphy.F90

EM

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