SURFEX v8.1
General documentation of Surfex
prep_grib_grid.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE prep_grib_grid(HGRIB,KLUOUT,HINMODEL,HGRIDTYPE,HINTERP_TYPE,TPTIME_GRIB)
7 ! ##########################################################################
8 !
9 !!**** *PREP_GRIB_GRID* - reads GRIB grid.
10 !!
11 !! PURPOSE
12 !! -------
13 !!
14 !!** METHOD
15 !! ------
16 !!
17 !! EXTERNAL
18 !! --------
19 !!
20 !! IMPLICIT ARGUMENTS
21 !! ------------------
22 !!
23 !!
24 !! REFERENCE
25 !! ---------
26 !!
27 !!
28 !! AUTHOR
29 !! ------
30 !!
31 !! V. Masson (from read_all_data_grib_case)
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 06/2003
36 !! S. Faroux 01/2011 : to use library GRIB_API instead of GRIBEX (from
37 !! read_all_data_grib_case)
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
44 !
45 USE modd_surfex_mpi, ONLY : nrank, npio, ncomm, nproc
46 !
48 !
50  xla, xola, xolo, np, xloph
51 !
52 USE modd_prep, ONLY : xlat_out, xlon_out, linterp
53 !
56  xlat, xlon
57 USE modd_grid_arome, ONLY : xx, xy, nx, ny, xlat0, xlon0, xlator, xlonor, xrpk, xbeta, xzx, xzy, nix
58 USE modd_grid_grib, ONLY : nni, cgrib_file
59 USE modd_surf_par, ONLY : xundef, nundef
60 USE modd_csts, ONLY : xpi
61 !
63 USE modi_horibl_surf_init
64 USE modi_horibl_surf_coef
65 USE modi_arpege_stretch_a
66 !
67 USE yomhook ,ONLY : lhook, dr_hook
68 USE parkind1 ,ONLY : jprb
69 !
70 USE modi_abor1_sfx
71 !
72 IMPLICIT NONE
73 !
74 #ifdef SFX_MPI
75 include "mpif.h"
76 #endif
77 !
78 !* 0.1. Declaration of arguments
79 ! ------------------------
80 !
81  CHARACTER(LEN=*), INTENT(IN) :: HGRIB ! Grib file name
82 INTEGER, INTENT(IN) :: KLUOUT ! logical unit of output listing
83  CHARACTER(LEN=6), INTENT(OUT) :: HINMODEL ! Grib originating model
84  CHARACTER(LEN=10), INTENT(OUT) :: HGRIDTYPE ! Grid type
85  CHARACTER(LEN=6), INTENT(OUT) :: HINTERP_TYPE ! Grid type
86 type(date_time) :: tptime_grib ! current date and time
87 
88 !
89 !* 0.2 Declaration of local variables
90 ! ------------------------------
91 !
92  CHARACTER(LEN=50) :: HGRID ! type of grid
93 ! General purpose variables
94 INTEGER(KIND=kindOfInt), DIMENSION(:), ALLOCATABLE :: ININLO_GRIB
95 INTEGER(KIND=kindOfInt) :: IMISSING
96 INTEGER(KIND=kindOfInt) :: IUNIT
97 INTEGER(KIND=kindOfInt) :: IGRIB
98 INTEGER(KIND=kindOfInt) :: IRET ! Return code from subroutines
99 !
100 ! Variable involved in the task of reading the grib file
101 INTEGER :: ICENTER ! number of center
102 INTEGER :: ISCAN, JSCAN
103 INTEGER :: ILENX ! nb points in X
104 INTEGER :: ILENY ! nb points in Y
105 INTEGER :: ITIME, IYEAR, IMONTH, IDAY
106 INTEGER :: IUNITTIME,IP1
107 INTEGER :: INO, IINLA ! output number of points
108 REAL :: ZTIME
109 !
110 ! Grib Grid definition variables
111 INTEGER :: JLOOP1 ! Dummy counter
112 !JUAN
113 !JUAN
114 INTEGER :: INFOMPI, J
115 REAL(KIND=JPRB) :: ZHOOK_HANDLE
116 !
117 !---------------------------------------------------------------------------------------
118 !
119 IF (lhook) CALL dr_hook('PREP_GRIB_GRID_1',0,zhook_handle)
120 !
121 IF (nrank==npio) THEN
122 !
123 WRITE (kluout,'(A)') ' -- Grib reader started'
124 !
125 ! open grib file
126  CALL grib_open_file(iunit,hgrib,'R',iret)
127 IF (iret /= 0) THEN
128  CALL abor1_sfx('PREP_GRIB_GRID: Error opening the grib file '//hgrib)
129 END IF
130 !
131  CALL grib_new_from_file(iunit,igrib,iret)
132 ! needed for HIRLAM ROTLATLON (infos in the second record)
133  CALL grib_new_from_file(iunit,igrib,iret)
134 !
135 IF (iret /= 0) THEN
136  CALL abor1_sfx('PREP_GRIB_GRID: Error in reading the grib file')
137 END IF
138 !
139 ! close the grib file
140  CALL grib_close_file(iunit)
141 !
142 !
143 !---------------------------------------------------------------------------------------
144 !* 2. Fix originating center
145 !---------------------------------------------------------------------------------------
146 !
147  CALL grib_get(igrib,'centre',icenter,iret)
148 IF (iret /= 0) THEN
149  CALL abor1_sfx('PREP_GRIB_GRID: Error in reading center')
150 END IF
151 !
152  CALL grib_get(igrib,'typeOfGrid',hgrid,iret)
153 IF (iret /= 0) THEN
154  CALL abor1_sfx('PREP_GRIB_GRID: Error in reading type of grid')
155 END IF
156 !
157 SELECT CASE (icenter)
158 
159  CASE (96)
160  SELECT CASE (hgrid)
161 
162  CASE('rotated_ll')
163  WRITE (kluout,'(A)') ' | Grib file from HIRLAM - regular latlon grid '
164  hinmodel='HIRLAM'
165  hgridtype='ROTLATLON '
166 
167  CASE DEFAULT
168  WRITE (kluout,'(A)') ' | Grib file from HARMONY'
169  hinmodel='ALADIN'
170  hgridtype='AROME '
171 
172  END SELECT
173 
174  CASE (82)
175  WRITE (kluout,'(A)') ' | Grib file from HIRLAM'
176  hinmodel='HIRLAM'
177  hgridtype='ROTLATLON '
178 
179  CASE (98)
180  WRITE (kluout,'(A)') ' | Grib file from European Center for Medium-range Weather Forecast'
181  hinmodel = 'ECMWF '
182  hgridtype= 'GAUSS '
183 
184  CASE (85)
185  SELECT CASE (hgrid)
186 
187  CASE('regular_gg')
188  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Arpege model'
189  WRITE (kluout,'(A)') 'but same grid as ECMWF model (unstretched)'
190  hinmodel = 'ARPEGE'
191  hgridtype= 'GAUSS '
192 
193  CASE('reduced_gg')
194  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Arpege model'
195  WRITE (kluout,'(A)') 'but reduced grid'
196  hinmodel = 'ARPEGE'
197  hgridtype= 'GAUSS '
198 
199  CASE('regular_ll')
200  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Mocage model'
201  hinmodel = 'MOCAGE'
202  hgridtype= 'LATLON '
203 
204  CASE('unknown_PLPresent')
205  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Arpege model'
206  hinmodel = 'ARPEGE'
207  hgridtype= 'ROTGAUSS '
208 
209  CASE('reduced_stretched_rotated_gg')
210  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Arpege model'
211  WRITE (kluout,'(A)') 'but reduced grid'
212  hinmodel = 'ARPEGE'
213  hgridtype= 'ROTGAUSS '
214 
215  CASE('lambert')
216  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Aladin france model'
217  hinmodel = 'ALADIN'
218  hgridtype= 'AROME '
219 
220  CASE('mercator')
221  WRITE (kluout,'(A)') ' | Grib file from French Weather Service - Aladin reunion model'
222  hinmodel = 'ALADIN'
223  hgridtype= 'MERCATOR '
224 
225  END SELECT
226 
227  CASE DEFAULT
228  CALL abor1_sfx('PREP_GRIB_GRID: GRIB FILE FORMAT NOT SUPPORTED')
229 
230 END SELECT
231 ENDIF
232 !
233 IF (nproc>1) THEN
234 #ifdef SFX_MPI
235  CALL mpi_bcast(igrib,kind(igrib)/4,mpi_integer,npio,ncomm,infompi)
236  CALL mpi_bcast(hinmodel,len(hinmodel),mpi_character,npio,ncomm,infompi)
237  CALL mpi_bcast(hgridtype,len(hgridtype),mpi_character,npio,ncomm,infompi)
238 #endif
239 ENDIF
240 !
241 !---------------------------------------------------------------------------------------
242 !* 3. Number of points
243 !---------------------------------------------------------------------------------------
244 !
245 nx = nundef
246 ny = nundef
247 ninla = nundef
248 nilen = nundef
249 IF (ALLOCATED(ninlo)) DEALLOCATE(ninlo)
250 !
251 SELECT CASE (hgridtype)
252 
253  CASE ('AROME ','MERCATOR ')
254  ! 3.1 lambert conformal projection(aladin files)
255  ! or mercator projection(aladin reunion files)
256  IF (nrank==npio) THEN
257  CALL grib_get(igrib,'Nj',ny,iret)
258  CALL grib_get(igrib,'Ni',nx,iret)
259  ENDIF
260  IF (nproc>1) THEN
261 #ifdef SFX_MPI
262  CALL mpi_bcast(ny,kind(ny)/4,mpi_integer,npio,ncomm,infompi)
263  CALL mpi_bcast(nx,kind(nx)/4,mpi_integer,npio,ncomm,infompi)
264 #endif
265  ENDIF
266  nni= nx * ny
267  !
268  !
269  CASE ('GAUSS ','ROTGAUSS ','LATLON ')
270  ! 3.2 usual or gaussian lat,lon grid(ecmwf files)
271  !
272 
273  IF (nrank==npio) CALL grib_get(igrib,'Nj',ninla,iret)
274  IF (nproc>1) THEN
275 #ifdef SFX_MPI
276  CALL mpi_bcast(ninla,kind(ninla)/4,mpi_integer,npio,ncomm,infompi)
277 #endif
278  ENDIF
279  ALLOCATE (ninlo(ninla))
280  nilen = 0
281  IF (nrank==npio) THEN
282  ALLOCATE (ininlo_grib(ninla))
283  CALL grib_is_missing(igrib,'pl',imissing,iret)
284  IF (iret /= 0 .OR. imissing==1) THEN ! regular
285  CALL grib_get(igrib,'Ni',ininlo_grib(1),iret)
286  ininlo_grib(2:ninla)=ininlo_grib(1)
287  nilen=ninla*ininlo_grib(1)
288  ELSE ! quasi-regular
289  CALL grib_get(igrib,'pl',ininlo_grib)
290  DO jloop1=1 ,ninla
291  nilen = nilen + ininlo_grib(jloop1)
292  ENDDO
293  ENDIF
294  ninlo = ininlo_grib !JUAN
295  DEALLOCATE(ininlo_grib)
296  ENDIF
297  IF (nproc>1) THEN
298 #ifdef SFX_MPI
299  CALL mpi_bcast(nilen,kind(nilen)/4,mpi_integer,npio,ncomm,infompi)
300  CALL mpi_bcast(ninlo,SIZE(ninlo)*kind(ninlo)/4,mpi_integer,npio,ncomm,infompi)
301 #endif
302  ENDIF
303  nni = nilen
304  CASE ('ROTLATLON ')
305  IF (nrank==npio) THEN
306  CALL grib_get(igrib,'Nj',nry,iret)
307  CALL grib_get(igrib,'Ni',nrx,iret)
308  ENDIF
309  IF (nproc>1) THEN
310 #ifdef SFX_MPI
311  CALL mpi_bcast(nry,kind(nry)/4,mpi_integer,npio,ncomm,infompi)
312  CALL mpi_bcast(nrx,kind(nrx)/4,mpi_integer,npio,ncomm,infompi)
313 #endif
314  ENDIF
315  nni = nrx * nry
316 
317  CASE DEFAULT
318  CALL abor1_sfx('PREP_GRIB_GRID: GRID PROJECTION NOT SUPPORTED')
319  !
320 END SELECT
321 !
322 !---------------------------------------------------------------------------------------
323 !* 4. Updates grid information
324 !---------------------------------------------------------------------------------------
325 !
326 xx = xundef
327 xy = xundef
328 xila1 = xundef
329 xilo1 = xundef
330 xila2 = xundef
331 xilo2 = xundef
332 lrotpole = .false.
333 xcoef = xundef
334 xlap = xundef
335 xlop = xundef
336 
337 SELECT CASE (hgridtype)
338 
339  CASE ('AROME ')
340  ! 4.1 lambert conformal projection(aladin files)
341  !
342  IF (nrank==npio) THEN
343  CALL grib_get(igrib,'xDirectionGridLength',ilenx)
344  CALL grib_get(igrib,'yDirectionGridLength',ileny)
345  xy = (ny-1)*ileny
346  xx = (nx-1)*ilenx
347  ENDIF
348  IF (nproc>1) THEN
349 #ifdef SFX_MPI
350  CALL mpi_bcast(xy,kind(xy)/4,mpi_real,npio,ncomm,infompi)
351  CALL mpi_bcast(xx,kind(xx)/4,mpi_real,npio,ncomm,infompi)
352 #endif
353  ENDIF
354 
355  IF (nrank==npio) THEN
356  CALL grib_get(igrib,'Latin1InDegrees',xlat0)
357  CALL grib_get(igrib,'LoVInDegrees',xlon0)
358  IF (xlon0 > 180.) xlon0 = xlon0 - 360.
359  ENDIF
360  IF (nproc>1) THEN
361 #ifdef SFX_MPI
362  CALL mpi_bcast(xlat0,kind(xlat0)/4,mpi_real,npio,ncomm,infompi)
363  CALL mpi_bcast(xlon0,kind(xlon0)/4,mpi_real,npio,ncomm,infompi)
364 #endif
365  ENDIF
366 
367  IF (nrank==npio) THEN
368  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xlator)
369  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xlonor)
370  IF (xlonor > 180.) xlonor = xlonor - 360.
371  ENDIF
372  IF (nproc>1) THEN
373 #ifdef SFX_MPI
374  CALL mpi_bcast(xlator,kind(xlator)/4,mpi_real,npio,ncomm,infompi)
375  CALL mpi_bcast(xlonor,kind(xlonor)/4,mpi_real,npio,ncomm,infompi)
376 #endif
377  ENDIF
378 
379  xrpk = sin(xlat0/180.*xpi)
380  xbeta = 0.
381  !
382  CASE ('GAUSS ','LATLON ')
383  hgridtype = 'GAUSS '
384  ! 4.2 usual or gaussian lat,lon grid(ecmwf files)
385  ! no projection - just stores the grid definition
386  !
387  IF (nrank==npio) THEN
388  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xila1)
389  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xilo1)
390  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xila2)
391  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xilo2)
392  ENDIF
393  IF (nproc>1) THEN
394 #ifdef SFX_MPI
395  CALL mpi_bcast(xila1,kind(xila1)/4,mpi_real,npio,ncomm,infompi)
396  CALL mpi_bcast(xilo1,kind(xilo1)/4,mpi_real,npio,ncomm,infompi)
397  CALL mpi_bcast(xila2,kind(xila2)/4,mpi_real,npio,ncomm,infompi)
398  CALL mpi_bcast(xilo2,kind(xilo2)/4,mpi_real,npio,ncomm,infompi)
399 #endif
400  ENDIF
401 
402  lrotpole = .false.
403  !
404  CASE ('ROTLATLON ')
405  !
406  ! 4.2.5 rotated lat/lon grid(hirlam)
407  !
408  IF (nrank==npio) THEN
409  CALL grib_get(igrib,'iScansNegatively',iscan)
410  CALL grib_get(igrib,'jScansPositively',jscan)
411 
412  IF (iscan+jscan == 0 ) THEN !lon (i) positive, lat (j) negative
413  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xrila2)
414  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xrilo1)
415  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xrila1)
416  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xrilo2)
417  ELSEIF (iscan+jscan == 2) THEN ! lon (i) negative, lat (j) positive
418  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xrila1)
419  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xrilo2)
420  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xrila2)
421  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xrilo1)
422  ELSEIF (iscan == 1) THEN ! lon (i) negative, lat (j) negative)
423  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xrila2)
424  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xrilo2)
425  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xrila1)
426  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xrilo1)
427  ELSEIF (jscan == 1) THEN ! lon (i) positive, lat (j) positive
428  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xrila1)
429  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xrilo1)
430  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xrila2)
431  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xrilo2)
432  ENDIF
433 
434  CALL grib_get(igrib,'latitudeOfSouthernPoleInDegrees',xrlap)
435  CALL grib_get(igrib,'longitudeOfSouthernPoleInDegrees',xrlop)
436 
437  CALL grib_get(igrib,'iDirectionIncrementInDegrees',xrdx)
438  CALL grib_get(igrib,'jDirectionIncrementInDegrees',xrdy)
439  WRITE(kluout,*)'XRILA1,XRILO1',xrila1,xrilo1
440  WRITE(kluout,*)'XRILA2,XRILO2',xrila2,xrilo2
441  WRITE(kluout,*)'XRLAP,XRLOP',xrlap,xrlop
442  WRITE(kluout,*)'XRDX,XRDY',xrdx,xrdy
443  ENDIF
444  IF (nproc>1) THEN
445 #ifdef SFX_MPI
446  CALL mpi_bcast(xrila1,kind(xrila1)/4,mpi_real,npio,ncomm,infompi)
447  CALL mpi_bcast(xrilo1,kind(xrilo1)/4,mpi_real,npio,ncomm,infompi)
448  CALL mpi_bcast(xrila2,kind(xrila2)/4,mpi_real,npio,ncomm,infompi)
449  CALL mpi_bcast(xrilo2,kind(xrilo2)/4,mpi_real,npio,ncomm,infompi)
450  CALL mpi_bcast(xrlap,kind(xrlap)/4,mpi_real,npio,ncomm,infompi)
451  CALL mpi_bcast(xrlop,kind(xrlop)/4,mpi_real,npio,ncomm,infompi)
452  CALL mpi_bcast(xrdx,kind(xrdx)/4,mpi_real,npio,ncomm,infompi)
453  CALL mpi_bcast(xrdy,kind(xrdy)/4,mpi_real,npio,ncomm,infompi)
454 #endif
455  ENDIF
456 
457  !
458  CASE ('ROTGAUSS ')
459  ! 4.3 stretched lat,lon grid(arpege files)
460  !
461  hgridtype = 'GAUSS '
462  IF (nrank==npio) THEN
463  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xila1)
464  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xilo1)
465  CALL grib_get(igrib,'latitudeOfLastGridPointInDegrees',xila2)
466  CALL grib_get(igrib,'longitudeOfLastGridPointInDegrees',xilo2)
467 
468  CALL grib_get(igrib,'stretchingFactor',xcoef)
469  CALL grib_get(igrib,'latitudeOfStretchingPoleInDegrees',xlap)
470  CALL grib_get(igrib,'longitudeOfStretchingPoleInDegrees',xlop)
471  ENDIF
472  lrotpole = .true.
473  IF (nproc>1) THEN
474 #ifdef SFX_MPI
475  CALL mpi_bcast(xila1,kind(xila1)/4,mpi_real,npio,ncomm,infompi)
476  CALL mpi_bcast(xilo1,kind(xilo1)/4,mpi_real,npio,ncomm,infompi)
477  CALL mpi_bcast(xila2,kind(xila2)/4,mpi_real,npio,ncomm,infompi)
478  CALL mpi_bcast(xilo2,kind(xilo2)/4,mpi_real,npio,ncomm,infompi)
479  CALL mpi_bcast(xcoef,kind(xcoef)/4,mpi_real,npio,ncomm,infompi)
480  CALL mpi_bcast(xlap,kind(xlap)/4,mpi_real,npio,ncomm,infompi)
481  CALL mpi_bcast(xlop,kind(xlop)/4,mpi_real,npio,ncomm,infompi)
482 #endif
483  ENDIF
484 
485  !
486 
487  CASE ('MERCATOR ')
488  ! 4.4 mercator projection(aladin reunion files)
489  !
490  hgridtype = 'AROME '
491  IF (nrank==npio) THEN
492  CALL grib_get(igrib,'Dj',ileny)
493  CALL grib_get(igrib,'Di',ilenx)
494  xy = (ny-1)*ileny
495  xx = (nx-1)*ilenx
496 
497  CALL grib_get(igrib,'LaDInDegrees',xlat0)
498 
499  CALL grib_get(igrib,'latitudeOfFirstGridPointInDegrees',xlator)
500  CALL grib_get(igrib,'longitudeOfFirstGridPointInDegrees',xlonor)
501  IF (xlonor > 180.) xlonor = xlonor - 360.
502  ENDIF
503  IF (nproc>1) THEN
504 #ifdef SFX_MPI
505  CALL mpi_bcast(xy,kind(xy)/4,mpi_real,npio,ncomm,infompi)
506  CALL mpi_bcast(xx,kind(xx)/4,mpi_real,npio,ncomm,infompi)
507  CALL mpi_bcast(xlat0,kind(xlat0)/4,mpi_real,npio,ncomm,infompi)
508  CALL mpi_bcast(xlator,kind(xlator)/4,mpi_real,npio,ncomm,infompi)
509  CALL mpi_bcast(xlonor,kind(xlonor)/4,mpi_real,npio,ncomm,infompi)
510 #endif
511  ENDIF
512  xlon0 = 0.
513  xrpk = 0.
514  xbeta = 0.
515 
516  CASE DEFAULT
517  IF (nrank==npio) WRITE (kluout,'(A)') 'No such projection implemented in prep_grib_grid ',hgrid
518  CALL abor1_sfx('PREP_GRIB_GRID: UNKNOWN PROJECTION')
519  !
520 END SELECT
521 !---------------------------------------------------------------------------------------
522 !* 2.4 Read date
523 !---------------------------------------------------------------------------------------
524 !
525 WRITE (kluout,'(A)') ' | Reading date'
526 !
527 IF (nrank==npio) THEN
528  CALL grib_get(igrib,'year',iyear,iret)
529  CALL grib_get(igrib,'month',imonth,iret)
530  CALL grib_get(igrib,'day',iday,iret)
531  CALL grib_get(igrib,'time',itime,iret)
532 ztime=int(itime/100)*3600+(itime-int(itime/100)*100)*60
533 !
534  CALL grib_get(igrib,'P1',ip1,iret)
535 IF ( ip1>0 ) THEN
536  CALL grib_get(igrib,'unitOfTimeRange',iunittime,iret)
537  SELECT CASE (iunittime) ! Time unit indicator
538  CASE (1) !hour
539  ztime = ztime + ip1*3600.
540  CASE (0) !minute
541  ztime = ztime + ip1*60.
542  END SELECT
543 ENDIF
544 ENDIF
545 !
546 IF (nproc>1) THEN
547 #ifdef SFX_MPI
548  CALL mpi_bcast(iyear,kind(iyear)/4,mpi_integer,npio,ncomm,infompi)
549  CALL mpi_bcast(imonth,kind(imonth)/4,mpi_integer,npio,ncomm,infompi)
550  CALL mpi_bcast(iday,kind(iday)/4,mpi_integer,npio,ncomm,infompi)
551  CALL mpi_bcast(ztime,kind(ztime)/4,mpi_real,npio,ncomm,infompi)
552 #endif
553 ENDIF
554 
555 tptime_grib%TDATE%YEAR = iyear
556 tptime_grib%TDATE%MONTH = imonth
557 tptime_grib%TDATE%DAY = iday
558 tptime_grib%TIME = ztime
559 !
560 !---------------------------------------------------------------------------------------
561 !
562 IF (nrank==npio) THEN
563  CALL grib_release(igrib,iret)
564 IF (iret /= 0) THEN
565  CALL abor1_sfx('PREP_GRIB_GRID: Error in releasing the grib message memory')
566 END IF
567 ENDIF
568 !
569 IF (lhook) CALL dr_hook('PREP_GRIB_GRID_1',1,zhook_handle)
570 IF (lhook) CALL dr_hook('PREP_GRIB_GRID_2',0,zhook_handle)
571 !
572 IF (ALLOCATED(xlat_out)) THEN
573 
574  ino = SIZE(xlat_out)
575 
576  IF (hgridtype=='GAUSS ') THEN
577  IF (ALLOCATED(xlat)) DEALLOCATE(xlat)
578  IF (ALLOCATED(xlon)) DEALLOCATE(xlon)
579  ALLOCATE(xlat(ino))
580  ALLOCATE(xlon(ino))
581  IF (lrotpole) THEN
582 !* transformation of output latitudes, longitudes into rotated coordinates
584  ELSE
585  xlat = xlat_out
586  xlon = xlon_out
587  END IF
588  ELSEIF (hgridtype=='AROME ') THEN
589  IF (ALLOCATED(xzx)) DEALLOCATE(xzx)
590  IF (ALLOCATED(xzy)) DEALLOCATE(xzy)
591  IF (ALLOCATED(nix)) DEALLOCATE(nix)
592  ALLOCATE(xzx(ino))
593  ALLOCATE(xzy(ino))
594  ALLOCATE(nix(ny))
595  nix=nx
597  ELSEIF (hgridtype=='ROTLATLON ') THEN
598  ENDIF
599 !
600  IF (ALLOCATED(no)) DEALLOCATE(no)
601  IF (ALLOCATED(xla)) DEALLOCATE(xla)
602  IF (ALLOCATED(xola)) DEALLOCATE(xola)
603  IF (ALLOCATED(xolo)) DEALLOCATE(xolo)
604  IF (ALLOCATED(ninloh)) DEALLOCATE(ninloh)
605 
606  ALLOCATE(no(ino,4))
607  ALLOCATE(xola(ino),xolo(ino))
608  ALLOCATE(xla(ino,4))
609 !
610 
611  !
612  IF (hgridtype=='GAUSS ') THEN
613  iinla = ninla
614  ALLOCATE(ninloh(iinla+4))
618  ELSEIF (hgridtype=='AROME ') THEN
619  iinla = ny
620  ALLOCATE(ninloh(iinla+4))
621  CALL horibl_surf_init(0.,0.,xy,xx,ny,nix,ino,xzx,xzy, &
624  ENDIF
625 !
626  IF (ALLOCATED(np)) DEALLOCATE(np)
627  IF (ALLOCATED(xloph)) DEALLOCATE(xloph)
628  ALLOCATE(np(ino,12))
629  ALLOCATE(xloph(ino,12))
630 
631  IF (lglobs) iinla = iinla + 2
632  IF (lglobn) iinla = iinla + 2
633 
634  IF (hgridtype=='GAUSS '.OR.hgridtype=='AROME ') THEN
636  no,ninloh(1:iinla),np,xloph)
637  ENDIF
638 !
639 ENDIF
640 !
641 hinterp_type = "HORIBL"
642 !
643 IF (lhook) CALL dr_hook('PREP_GRIB_GRID_2',1,zhook_handle)
644 !
645 END SUBROUTINE prep_grib_grid
subroutine horibl_surf_coef(KOLEN, OINTERP, OGLOBLON, PILO1, PILO2, POLO, KO, KINLO, KP, PLOP)
integer, dimension(:), allocatable ninloh
Definition: modd_horibl.F90:39
character(len=28) cgrib_file
subroutine prep_grib_grid(HGRIB, KLUOUT, HINMODEL, HGRIDTYPE, HINTERP_
real, dimension(:), allocatable xlat
real, dimension(:), allocatable xzy
real, dimension(:), allocatable xola
Definition: modd_horibl.F90:41
integer, dimension(:,:), allocatable np
Definition: modd_horibl.F90:42
real, dimension(:), allocatable xlon_out
Definition: modd_prep.F90:48
subroutine xy_conf_proj(PLAT0, PLON0, PRPK, PBETA, PLATOR, PLONOR, PX, PY, PLAT, PLON)
real, save xpi
Definition: modd_csts.F90:43
logical lgloblon
Definition: modd_horibl.F90:35
integer, dimension(:,:), allocatable no
Definition: modd_horibl.F90:38
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
real, parameter xundef
logical, dimension(:), allocatable linterp
Definition: modd_prep.F90:43
integer, parameter jprb
Definition: parkind1.F90:32
real, dimension(:), allocatable xzx
real, dimension(:), allocatable xlon
integer, dimension(:), allocatable ninlo
real, dimension(:), allocatable xlat_out
Definition: modd_prep.F90:47
integer, parameter nundef
integer, dimension(:), allocatable nix
logical lglobs
Definition: modd_horibl.F90:35
real, dimension(:), allocatable xolo
Definition: modd_horibl.F90:41
logical lhook
Definition: yomhook.F90:15
subroutine horibl_surf_init(PILA1, PILO1, PILA2, PILO2, KINLA, KINLO, KOLEN, PXOUT, PYOUT, OINTERP, OGLOBLON, OGLOBN, OGLOBS, KO, KINLO_OUT, POLA, POLO, PILO1_OUT, PILO2_OUT, PLA, PILATARRAY)
logical lglobn
Definition: modd_horibl.F90:35
subroutine arpege_stretch_a(KN, PLAP, PLOP, PCOEF, PLAR, PLOR, PLAC, PLOC)
real, dimension(:,:), allocatable xla
Definition: modd_horibl.F90:40
real, dimension(:,:), allocatable xloph
Definition: modd_horibl.F90:43