source: trunk/LMDZ.GENERIC/libf/phystd/mod_grid_phy_lmdz.F90 @ 1255

Last change on this file since 1255 was 1216, checked in by emillour, 11 years ago

Generic model:
Major cleanup, in order to ease the use of LMDZ.GENERIC with (parallel) dynamics
in LMDZ.COMMON: (NB: this will break LMDZ.UNIVERSAL, which should be thrashed
in the near future)

  • Updated makegcm_* scripts (and makdim) and added the "-full" (to enforce full recomputation of the model) option
  • In dyn3d: converted control.h to module control_mod.F90 and converted iniadvtrac.F to module infotrac.F90
  • Added module mod_const_mpi.F90 in dyn3d (not used in serial mode)
  • Rearanged input/outputs routines everywhere to handle serial/MPI cases. physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write routines for startfi files are gathered in module iostart.F90
  • added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, mod_phys_lmdz_transfert_para.F90 in phymars and mod_const_mpi.F90 in dyn3d (for compliance with parallelism)
  • added created generic routines 'planetwide_maxval' and 'planetwide_minval', in module "planetwide_mod", that enable obtaining the max and min of a field over the whole planet. This should be further imroved with computation of means (possibly area weighed), etc.

EM

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