source: trunk/LMDZ.GENERIC/libf/dynlonlat_phylonlat/mod_grid_phy_lmdz.F90 @ 1470

Last change on this file since 1470 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

File size: 11.7 KB
Line 
1!
2!$Header$
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,SAVE :: nbp_lon  ! == iim
11  INTEGER,SAVE :: nbp_lat  ! == jjmp1
12  INTEGER,SAVE :: nbp_lev  ! == llm
13  INTEGER,SAVE :: klon_glo
14!$OMP THREADPRIVATE(nbp_lon,nbp_lat,nbp_lev,klon_glo)
15
16  INTERFACE grid1dTo2d_glo
17    MODULE PROCEDURE grid1dTo2d_glo_i,grid1dTo2d_glo_i1,grid1dTo2d_glo_i2,grid1dTo2d_glo_i3, &
18                     grid1dTo2d_glo_r,grid1dTo2d_glo_r1,grid1dTo2d_glo_r2,grid1dTo2d_glo_r3, &
19                     grid1dTo2d_glo_l,grid1dTo2d_glo_l1,grid1dTo2d_glo_l2,grid1dTo2d_glo_l3
20   END INTERFACE
21
22   INTERFACE grid2dTo1d_glo
23    MODULE PROCEDURE grid2dTo1d_glo_i,grid2dTo1d_glo_i1,grid2dTo1d_glo_i2,grid2dTo1d_glo_i3, &
24                     grid2dTo1d_glo_r,grid2dTo1d_glo_r1,grid2dTo1d_glo_r2,grid2dTo1d_glo_r3, &
25                     grid2dTo1d_glo_l,grid2dTo1d_glo_l1,grid2dTo1d_glo_l2,grid2dTo1d_glo_l3
26   END INTERFACE
27 
28CONTAINS
29
30!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31!! SUBROUTINE grid1dTo2d  !! 
32!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
34
35  SUBROUTINE init_grid_phy_lmdz(iim,jjp1,llm)
36  IMPLICIT NONE
37  INTEGER, INTENT(in) :: iim
38  INTEGER, INTENT(in) :: jjp1
39  INTEGER, INTENT(in) :: llm
40 
41    nbp_lon=iim
42    nbp_lat=jjp1
43    nbp_lev=llm
44    klon_glo=(iim*jjp1)-2*(iim-1)
45 
46  ! Ehouarn: handle 1D case:
47  if ((iim.eq.1).and.(jjp1.eq.2)) then
48    nbp_lat=1
49    klon_glo=1
50  endif
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!  fonctions generiques (privees)
287!----------------------------------------------------------------
288  SUBROUTINE grid1dTo2d_glo_igen(VarIn,VarOut,dimsize)
289    IMPLICIT NONE
290
291    INTEGER,INTENT(IN) :: dimsize
292    INTEGER,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
293    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
294    INTEGER :: i,ij,Offset
295
296   
297    Offset=nbp_lon
298       
299    DO i=1,dimsize
300      DO ij=1,klon_glo
301        VarOut(ij+offset-1,i)=VarIn(ij,i)
302      ENDDO
303    ENDDO
304   
305   
306    DO i=1,dimsize
307      DO ij=1,nbp_lon
308       VarOut(ij,i)=VarIn(1,i)
309      ENDDO
310    ENDDO
311   
312   
313    DO i=1,dimsize
314      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
315       VarOut(ij,i)=VarIn(klon_glo,i)
316      ENDDO
317    ENDDO
318
319  END SUBROUTINE grid1dTo2d_glo_igen   
320
321
322  SUBROUTINE grid1dTo2d_glo_rgen(VarIn,VarOut,dimsize)
323    IMPLICIT NONE
324
325    INTEGER,INTENT(IN) :: dimsize
326    REAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
327    REAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
328    INTEGER :: i,ij,Offset
329
330   
331    Offset=nbp_lon
332       
333    DO i=1,dimsize
334      DO ij=1,klon_glo
335        VarOut(ij+offset-1,i)=VarIn(ij,i)
336      ENDDO
337    ENDDO
338   
339   
340    DO i=1,dimsize
341      DO ij=1,nbp_lon
342       VarOut(ij,i)=VarIn(1,i)
343      ENDDO
344    ENDDO
345   
346   
347    DO i=1,dimsize
348      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
349       VarOut(ij,i)=VarIn(klon_glo,i)
350      ENDDO
351    ENDDO
352
353  END SUBROUTINE grid1dTo2d_glo_rgen   
354
355  SUBROUTINE grid1dTo2d_glo_lgen(VarIn,VarOut,dimsize)
356    IMPLICIT NONE
357   
358    INTEGER,INTENT(IN) :: dimsize
359    LOGICAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
360    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
361    INTEGER :: i,ij,Offset
362
363    Offset=nbp_lon
364       
365    DO i=1,dimsize
366      DO ij=1,klon_glo
367        VarOut(ij+offset-1,i)=VarIn(ij,i)
368      ENDDO
369    ENDDO
370   
371   
372    DO i=1,dimsize
373      DO ij=1,nbp_lon
374       VarOut(ij,i)=VarIn(1,i)
375      ENDDO
376    ENDDO
377   
378   
379    DO i=1,dimsize
380      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
381       VarOut(ij,i)=VarIn(klon_glo,i)
382      ENDDO
383    ENDDO
384
385  END SUBROUTINE grid1dTo2d_glo_lgen     
386 
387 
388  SUBROUTINE grid2dTo1d_glo_igen(VarIn,VarOut,dimsize)
389    IMPLICIT NONE
390
391    INTEGER,INTENT(IN) :: dimsize
392    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
393    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
394    INTEGER :: i,ij,offset
395
396    offset=nbp_lon
397
398    DO i=1,dimsize
399      DO ij=1,klon_glo
400        VarOut(ij,i)=VarIn(ij+offset-1,i)
401      ENDDO
402    ENDDO
403
404    DO i=1,dimsize
405      VarOut(1,i)=VarIn(1,i)
406    ENDDO
407   
408  END SUBROUTINE grid2dTo1d_glo_igen   
409 
410  SUBROUTINE grid2dTo1d_glo_rgen(VarIn,VarOut,dimsize)
411    IMPLICIT NONE
412
413    INTEGER,INTENT(IN) :: dimsize
414    REAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
415    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
416    INTEGER :: i,ij,offset
417
418    offset=nbp_lon
419
420    DO i=1,dimsize
421      DO ij=1,klon_glo
422        VarOut(ij,i)=VarIn(ij+offset-1,i)
423      ENDDO
424    ENDDO
425
426    DO i=1,dimsize
427      VarOut(1,i)=VarIn(1,i)
428    ENDDO
429   
430  END SUBROUTINE grid2dTo1d_glo_rgen
431   
432  SUBROUTINE grid2dTo1d_glo_lgen(VarIn,VarOut,dimsize)
433    IMPLICIT NONE
434
435    INTEGER,INTENT(IN) :: dimsize
436    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
437    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
438    INTEGER :: i,ij,offset
439
440    offset=nbp_lon
441
442    DO i=1,dimsize
443      DO ij=1,klon_glo
444        VarOut(ij,i)=VarIn(ij+offset-1,i)
445      ENDDO
446    ENDDO
447
448    DO i=1,dimsize
449      VarOut(1,i)=VarIn(1,i)
450    ENDDO
451   
452  END SUBROUTINE grid2dTo1d_glo_lgen   
453
454END MODULE mod_grid_phy_lmdz
Note: See TracBrowser for help on using the repository browser.