FLEXPART CTBTO WO8
 All Classes Files Functions Variables
readwind_nests.F90
Go to the documentation of this file.
1 !**********************************************************************
2 ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 *
3 ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, *
4 ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann *
5 ! *
6 ! This file is part of FLEXPART. *
7 ! *
8 ! FLEXPART is free software: you can redistribute it and/or modify *
9 ! it under the terms of the GNU General Public License as published by*
10 ! the Free Software Foundation, either version 3 of the License, or *
11 ! (at your option) any later version. *
12 ! *
13 ! FLEXPART is distributed in the hope that it will be useful, *
14 ! but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 ! GNU General Public License for more details. *
17 ! *
18 ! You should have received a copy of the GNU General Public License *
19 ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. *
20 !**********************************************************************
21 
22 subroutine readwind_nests(indj,n,uuhn,vvhn,wwhn)
23  ! i i o o o
24  !*****************************************************************************
25  ! *
26  ! This routine reads the wind fields for the nested model domains. *
27  ! It is similar to subroutine readwind, which reads the mother domain. *
28  ! *
29  ! Authors: A. Stohl, G. Wotawa *
30  ! *
31  ! 8 February 1999 *
32  ! *
33  ! Last update: 17 October 2000, A. Stohl *
34  ! *
35  !*****************************************************************************
36  ! Changes, Bernd C. Krueger, Feb. 2001: *
37  ! Variables tthn and qvhn (on eta coordinates) in common block *
38  ! CHANGE: 11/01/2008, Harald Sodemann, GRIB1/2 input with ECMWF grib_api *
39  ! CHANGE: 03/12/2008, Harald Sodemann, update to f90 with ECMWF grib_api *
40  !*****************************************************************************
41  ! Changes Arnold, D. and Morton, D. (2015): *
42  ! -- description of local and common variables *
43  !*****************************************************************************
44 
45  use grib_api
46  use par_mod
47  use com_mod
48  use class_vtable
49 
50  implicit none
51 
52  !***********************************************************************
53  ! Subroutine Parameters: *
54  ! input *
55  ! indj indicates number of the wind field to be read in *
56  ! n temporal index for meteorological fields (1 to 3)*
57  ! uuhn,vvhn, wwhn wind components for the input nest in ECMWF *
58  ! model levels *
59  integer :: indj,n
60  real :: uuhn(0:nxmaxn-1,0:nymaxn-1,nuvzmax,maxnests)
61  real :: vvhn(0:nxmaxn-1,0:nymaxn-1,nuvzmax,maxnests)
62  real :: wwhn(0:nxmaxn-1,0:nymaxn-1,nwzmax,maxnests)
63  !***********************************************************************
64 
65  !***********************************************************************
66  ! Local variables *
67  ! *
68  ! HSO variables for grib_api: *
69  ! ifile grib file to be opened and read in *
70  ! iret is a return code for successful or not open *
71  ! igrib grib edition number (whether GRIB1 or GRIB2) *
72  ! gribVer where info on igrib is kept, 1 for GRIB1 and *
73  ! 2 for GRIB2 *
74  ! parCat parameter category ( = number) , how FLEXPART *
75  ! identifies fields *
76  ! parNum parameter number by product discipline and *
77  ! parameter category *
78  ! typSurf type of first fixed surface *
79  ! valSurf level *
80  ! discipl discipline of processed data contained in a *
81  ! GRIB message *
82  integer :: ifile
83  integer :: iret
84  integer :: igrib
85  integer :: gribver,parcat,parnum,typsurf,valsurf,discipl
86  integer :: gotgrid
87 
88 
89 
90  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
91  !!!! Vtable related variables
92 
93  ! Paths to Vtables (current implementation will assume they are in the cwd
94  ! This is a crappy place for these parameters. Need to move them.
95  character(LEN=255), parameter :: vtable_ecmwf_grib1_path = &
96  "Vtable_ecmwf_grib1", &
97  vtable_ecmwf_grib2_path = &
98  "Vtable_ecmwf_grib2", &
99  vtable_ecmwf_grib1_2_path = &
100  "Vtable_ecmwf_grib1_2"
101 
102  integer :: gribfile_type
103  integer :: current_grib_level ! This "was" isec1(8) in previous version
104  character(len=255) :: gribfile_name
105  character(len=255) :: vtable_path
106  character(len=15) :: fpname
107 
108  type(vtable) :: my_vtable ! unallocated
109  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110 
111 
112 
113 
114 
115 
116  !
117  ! Variables and arrays for grib decoding: *
118  ! dimension of isec2 at least (22+n), where n is the number of *
119  ! parallels or meridians in a quasi-regular (reduced) Gaussian or *
120  ! lat/long grid *
121  ! dimension of zsec2 at least (10+nn), where nn is the number of *
122  ! vertical coordinate parameters *
123  ! *
124  ! isec1 grib definition section (version, center, ... *
125  ! isec2 grid description section *
126  ! zsec4 the binary data section *
127  ! xaux
128  ! yaux
129  ! xauxin
130  ! yauxin
131  ! xaux0 auxiliary variable for xlon0 *
132  ! yaux0 auxiliary variable for xlat0 *
133  ! nsss NS surface stress *
134  ! ewss EW surface stress *
135  ! plev1 pressure of the first model layer *
136  ! pmean mean pressure between ?? *
137  ! tv virtual temperature *
138  ! fu for conversion from pressure to meters *
139  ! hlev1 height of the first model layer *
140  ! ff10m wind speed at 10 m *
141  ! fflev1 wind speed at the first model layere *
142  ! hflswitch logical variable to check existence of flux data *
143  ! strswitch logical variable to check existence of stress *
144  ! data *
145  integer :: isec1(56),isec2(22+nxmaxn+nymaxn)
146  real(kind=4) :: zsec4(jpunp)
147  real(kind=8) :: xauxin,yauxin
148  real(kind=4) :: xaux,yaux,xaux0,yaux0
149  real :: ewss(0:nxmaxn-1,0:nymaxn-1),nsss(0:nxmaxn-1,0:nymaxn-1)
150  real :: plev1,pmean,tv,fu,hlev1,ff10m,fflev1
151  logical :: hflswitch,strswitch
152  !
153  ! Other variables:
154  ! i,j,k loop control indices in each direction *
155  ! levdiff2 number of model levels - number of model levels *
156  ! for the staggered vertical wind +1 *
157  ! ifield index to control field read in *
158  ! iumax
159  ! iwmax
160  integer ::i,j,k,levdiff2,ifield,iumax,iwmax,l
161  !***********************************************************************
162 
163  !***********************************************************************
164  ! Local constants *
165  !HSO grib api error messages:
166  character(len=24) :: griberrormsg = 'Error reading grib file'
167  character(len=20) :: gribfunction = 'readwind_nests'
168  !***********************************************************************
169  !***********************************************************************
170  ! Global variables *
171  ! from par_mod and com_mod *
172  ! wfname File name of data to be read in *
173  ! maxnests maximum number of nests *
174  ! nxn,nyn,nuvz,nwz expected field dimensions *
175  ! nxmaxn,nymaxn maximum dimension of nested wind fields in *
176  ! x and y direction, respectively *
177  ! nuvzmax,nwzmax maximum dimension of (u,v) and (w) wind fields in z
178  ! direction (for fields on eta levels) *
179  ! nlev_ec number of vertical levels ecmwf model *
180  ! u10n,v10n wind fields at 10 m *
181  ! tt2n,td2n temperature and dew point temperature at 2 m *
182  ! tthn,qvhn temperature and specific humidity on original *
183  ! eta levels *
184  ! psn surface pressure *
185  ! sdn snow depth (but not used afterwards!) *
186  ! msln mean sea level pressure *
187  ! ttcn total cloud cover *
188  ! lsprecn large scale precipitation *
189  ! cprecn convective precipitation *
190  ! sshfn sensible heat flux *
191  ! ssrn solar radiation *
192  ! surfstrn surface stress *
193  ! oron orography *
194  ! excessoron standard deviation of orography *
195  ! lsmn land sea mask *
196  ! r_air individual gas constant for dry air [J/kg/K] *
197  ! ga gravity acceleration of earth [m/s**2] *
198  !***********************************************************************
199 
200 !-----------------------------------------------------------------------------
201 
202  do l=1,numbnests
203  hflswitch=.false.
204  strswitch=.false.
205  levdiff2=nlev_ec-nwz+1
206  iumax=0
207  iwmax=0
208 
209  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
210  !!!!!!!!!!!!!!!!!!! VTABLE code
211  !!!!!!! Vtable choice
212  gribfile_name = path(3)(1:length(3))//trim(wfname(indj))
213  print *, 'gribfile_name: ', gribfile_name
214 
215  gribfile_type = vtable_detect_gribfile_type( gribfile_name )
216 
217  print *, 'gribfile_type: ', gribfile_type
218 
219  if (gribfile_type .eq. vtable_gribfile_type_ecmwf_grib1) then
220  vtable_path = vtable_ecmwf_grib1_path
221  else if (gribfile_type .eq. vtable_gribfile_type_ecmwf_grib2) then
222  vtable_path = vtable_ecmwf_grib2_path
223  else if (gribfile_type .eq. vtable_gribfile_type_ecmwf_grib1_2) then
224  vtable_path = vtable_ecmwf_grib1_2_path
225  else
226  print *, 'Unsupported gribfile_type: ', gribfile_type
227  stop
228  endif
229 
230 
231  ! Load the Vtable into 'my_vtable'
232  print *, 'readwind_nests(): Loading Vtable: ', vtable_path
233  call vtable_load_by_name(vtable_path, my_vtable)
234  print *, 'readwind_nests(): Vtable Initialized: ', my_vtable%initialized
235  print *, 'readwind_nests(): Vtable num_entries: ', my_vtable%num_entries
236  !!!!!!!!!!!!!!!!!!! VTABLE code
237  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
238 
239 
240 
241 
242 
243  ifile=0
244  igrib=0
245  iret=0
246 
247  !
248  ! OPENING OF DATA FILE (GRIB CODE)
249  !
250 
251 5 call grib_open_file(ifile,path(numpath+2*(l-1)+1) &
252  (1:length(numpath+2*(l-1)+1))//trim(wfnamen(l,indj)),'r')
253  if (iret.ne.grib_success) then
254  goto 888 ! ERROR DETECTED
255  endif
256  !turn on support for multi fields messages */
257  !call grib_multi_support_on
258 
259  gotgrid=0
260  ifield=0
261 10 ifield=ifield+1
262  !
263  ! GET NEXT FIELDS
264  !
265  call grib_new_from_file(ifile,igrib,iret)
266  if (iret.eq.grib_end_of_file) then
267  goto 50 ! EOF DETECTED
268  elseif (iret.ne.grib_success) then
269  goto 888 ! ERROR DETECTED
270  endif
271 
272 
273  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
274  !!!!!!!!!!!!!!!!!!! VTABLE code
275  ! Get the fpname
276  fpname = vtable_get_fpname(igrib, my_vtable)
277  print *, 'readwind_nests(): fpname: ', trim(fpname)
278 
279 
280  !!!!!!!!!!!!!!!!!!! VTABLE code
281  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
282 
283 
284 
285 
286 
287 
288  !first see if we read GRIB1 or GRIB2
289  call grib_get_int(igrib,'editionNumber',gribver,iret)
290  call grib_check(iret,gribfunction,griberrormsg)
291 
292 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING
293 !!!!! DJM 2016-01-19 - WARNING - we might want to put in the call to
294 !!!!! grib2check(), just as it is in the mother grid
295 
296  call grib_get_int(igrib,'level', current_grib_level,iret)
297  call grib_check(iret,gribfunction,griberrormsg)
298 
299 
300 
301 
302 
303  !HSO get the size and data of the values array
304  if (isec1(6).ne.-1) then
305  call grib_get_real4_array(igrib,'values',zsec4,iret)
306  call grib_check(iret,gribfunction,griberrormsg)
307 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING
308 !!!!! DJM 2016-01-19 - WARNING - we might want to put in the zsec4
309 !!!!! conversion, just as it is in the mother grid
310  endif
311 
312  !HSO get the required fields from section 2 in a gribex compatible manner
313  if(ifield.eq.1) then
314  call grib_get_int(igrib,'numberOfPointsAlongAParallel', &
315  isec2(2),iret)
316  call grib_check(iret,gribfunction,griberrormsg)
317  call grib_get_int(igrib,'numberOfPointsAlongAMeridian', &
318  isec2(3),iret)
319  call grib_check(iret,gribfunction,griberrormsg)
320  call grib_get_int(igrib,'numberOfVerticalCoordinateValues', &
321  isec2(12))
322  call grib_check(iret,gribfunction,griberrormsg)
323  ! CHECK GRID SPECIFICATIONS
324  if(isec2(2).ne.nxn(l)) stop &
325  'READWIND: NX NOT CONSISTENT FOR A NESTING LEVEL'
326  if(isec2(3).ne.nyn(l)) stop &
327  'READWIND: NY NOT CONSISTENT FOR A NESTING LEVEL'
328  if(isec2(12)/2-1.ne.nlev_ec) stop 'READWIND: VERTICAL DISCRET&
329  &IZATION NOT CONSISTENT FOR A NESTING LEVEL'
330  endif ! ifield
331 
332  !HSO get the second part of the grid dimensions only from GRiB1 messages
333 
334 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING
335 !!!!! DJM 2016-01-19 - WARNING - in readwind() I got rid of this if block. Not
336 !!!!! sure if I will want to do that here
337 !!!!!
338  if ((gribver.eq.1).and.(gotgrid.eq.0)) then
339  call grib_get_real8(igrib,'longitudeOfFirstGridPointInDegrees', &
340  xauxin,iret)
341  call grib_check(iret,gribfunction,griberrormsg)
342  call grib_get_real8(igrib,'latitudeOfLastGridPointInDegrees', &
343  yauxin,iret)
344  call grib_check(iret,gribfunction,griberrormsg)
345  xaux=xauxin
346  yaux=yauxin
347  xaux0=xlon0n(l)
348  yaux0=ylat0n(l)
349  if(xaux.lt.0.) xaux=xaux+360.
350  if(yaux.lt.0.) yaux=yaux+360.
351  if(xaux0.lt.0.) xaux0=xaux0+360.
352  if(yaux0.lt.0.) yaux0=yaux0+360.
353  if(xaux.ne.xaux0) &
354  stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT FOR A NES&
355  &TING LEVEL'
356  if(yaux.ne.yaux0) &
357  stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT FOR A NEST&
358  &ING LEVEL'
359  gotgrid=1
360  endif
361 
362 k = current_grib_level
363 
364 !! TEMPERATURE
365 if(trim(fpname) .eq. 'TT') then
366  do j=0,nyn(1)-1
367  do i=0,nxn(l)-1
368  tthn(i,j,nlev_ec-k+2,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
369  enddo
370  enddo
371 endif
372 
373 !! U VELOCITY
374 if(trim(fpname) .eq. 'UU') then
375  iumax=max(iumax,nlev_ec-k+1)
376  do j=0,nyn(1)-1
377  do i=0,nxn(l)-1
378  uuhn(i,j,nlev_ec-k+2,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
379  enddo
380  enddo
381 endif
382 
383 !! V VELOCITY
384 if(trim(fpname) .eq. 'VV') then
385  do j=0,nyn(1)-1
386  do i=0,nxn(l)-1
387  vvhn(i,j,nlev_ec-k+2,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
388  enddo
389  enddo
390 endif
391 
392 !! W VELOCITY
393 if(trim(fpname) .eq. 'ETADOT') then
394  iwmax=max(iwmax,nlev_ec-k+1)
395  do j=0,nyn(1)-1
396  do i=0,nxn(l)-1
397  wwhn(i,j,nlev_ec-k+1,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
398  enddo
399  enddo
400 endif
401 
402 !! SPEC. HUMIDITY
403 if(trim(fpname) .eq. 'QV') then
404  do j=0,nyn(1)-1
405  do i=0,nxn(l)-1
406  qvhn(i,j,nlev_ec-k+2,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
407  if (qvhn(i,j,nlev_ec-k+2,n,l) .lt. 0.) &
408  qvhn(i,j,nlev_ec-k+2,n,l) = 0.
409  ! this is necessary because the gridded data may contain
410  ! spurious negative values
411  enddo
412  enddo
413 endif
414 
415 
416 !! SURF. PRESS
417 if(trim(fpname) .eq. 'PS') then
418  do j=0,nyn(1)-1
419  do i=0,nxn(l)-1
420  psn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
421  enddo
422  enddo
423 endif
424 
425 !! SNOW DEPTH
426 if(trim(fpname) .eq. 'SD') then
427  do j=0,nyn(1)-1
428  do i=0,nxn(l)-1
429  sdn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
430  enddo
431  enddo
432 endif
433 
434 !! SEA LEVEL PRESS.
435 if(trim(fpname) .eq. 'MSL') then
436  do j=0,nyn(1)-1
437  do i=0,nxn(l)-1
438  msln(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
439  enddo
440  enddo
441 endif
442 
443 !! CLOUD COVER
444 if(trim(fpname) .eq. 'TCC') then
445  do j=0,nyn(1)-1
446  do i=0,nxn(l)-1
447  tccn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
448  enddo
449  enddo
450 endif
451 
452 !! 10 M U VELOCITY
453 if(trim(fpname) .eq. 'U10') then
454  do j=0,nyn(1)-1
455  do i=0,nxn(l)-1
456  u10n(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
457  enddo
458  enddo
459 endif
460 
461 !! 10 M V VELOCITY
462 if(trim(fpname) .eq. 'V10') then
463  do j=0,nyn(1)-1
464  do i=0,nxn(l)-1
465  v10n(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
466  enddo
467  enddo
468 endif
469 
470 !! 2 M TEMPERATURE
471 if(trim(fpname) .eq. 'T2') then
472  do j=0,nyn(1)-1
473  do i=0,nxn(l)-1
474  tt2n(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
475  enddo
476  enddo
477 endif
478 
479 !! 2 M DEW POINT
480 if(trim(fpname) .eq. 'TD2') then
481  do j=0,nyn(1)-1
482  do i=0,nxn(l)-1
483  td2n(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
484  enddo
485  enddo
486 endif
487 
488 !! LARGE SCALE PREC.
489 if(trim(fpname) .eq. 'LSPREC') then
490  do j=0,nyn(1)-1
491  do i=0,nxn(l)-1
492  lsprecn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
493  if (lsprecn(i,j,1,n,l).lt.0.) lsprecn(i,j,1,n,l)=0.
494  enddo
495  enddo
496 endif
497 
498 !! CONVECTIVE PREC.
499 if(trim(fpname) .eq. 'CONVPREC') then
500  do j=0,nyn(1)-1
501  do i=0,nxn(l)-1
502  convprecn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
503  if (convprecn(i,j,1,n,l).lt.0.) convprecn(i,j,1,n,l)=0.
504  enddo
505  enddo
506 endif
507 
508 !! SENS. HEAT FLUX
509 if(trim(fpname) .eq. 'SHF') then
510  do j=0,nyn(1)-1
511  do i=0,nxn(l)-1
512  sshfn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
513  if (zsec4(nxn(l)*(nyn(l)-j-1)+i+1).ne.0.) hflswitch=.true. ! Heat flux available
514  enddo
515  enddo
516 endif
517 
518 !! SOLAR RADIATION
519 if(trim(fpname) .eq. 'SR') then
520  do j=0,nyn(1)-1
521  do i=0,nxn(l)-1
522  ssrn(i,j,1,n,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
523  if (ssrn(i,j,1,n,l).lt.0.) ssrn(i,j,1,n,l)=0.
524  enddo
525  enddo
526 endif
527 
528 !! EW SURFACE STRESS
529 if(trim(fpname) .eq. 'EWSS') then
530  do j=0,nyn(1)-1
531  do i=0,nxn(l)-1
532  ewss(i,j) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
533  if (zsec4(nxn(l)*(nyn(l)-j-1)+i+1).ne.0.) strswitch=.true. ! stress available
534  enddo
535  enddo
536 endif
537 
538 !! NS SURFACE STRESS
539 if(trim(fpname) .eq. 'NSSS') then
540  do j=0,nyn(1)-1
541  do i=0,nxn(l)-1
542  nsss(i,j) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
543  if (zsec4(nxn(l)*(nyn(l)-j-1)+i+1).ne.0.) strswitch=.true. ! stress available
544  enddo
545  enddo
546 endif
547 
548 !! ECMWF OROGRAPHY
549 if(trim(fpname) .eq. 'ORO') then
550  do j=0,nyn(1)-1
551  do i=0,nxn(l)-1
552  oron(i,j,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)/ga
553  enddo
554  enddo
555 endif
556 
557 !! STANDARD DEVIATION OF OROGRAPHY
558 if(trim(fpname) .eq. 'EXCESSORO') then
559  do j=0,nyn(1)-1
560  do i=0,nxn(l)-1
561  excessoron(i,j,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
562  enddo
563  enddo
564 endif
565 
566 !! ECMWF LAND SEA MASK
567 if(trim(fpname) .eq. 'LSM') then
568  do j=0,nyn(1)-1
569  do i=0,nxn(l)-1
570  lsmn(i,j,l) = zsec4(nxn(l)*(nyn(l)-j-1)+i+1)
571  enddo
572  enddo
573 endif
574 
575 
576  call grib_release(igrib)
577  goto 10 !! READ NEXT LEVEL OR PARAMETER
578  !
579  ! CLOSING OF INPUT DATA FILE
580  !
581 50 call grib_close_file(ifile)
582 
583  !error message if no fields found with correct first longitude in it
584  if (gotgrid.eq.0) then
585  print*,'***ERROR: input file needs to contain GRiB1 formatted'// &
586  'messages'
587  stop
588  endif
589 
590  if(levdiff2.eq.0) then
591  iwmax=nlev_ec+1
592  do i=0,nxn(l)-1
593  do j=0,nyn(l)-1
594  wwhn(i,j,nlev_ec+1,l)=0.
595  end do
596  end do
597  endif
598 
599  do i=0,nxn(l)-1
600  do j=0,nyn(l)-1
601  surfstrn(i,j,1,n,l)=sqrt(ewss(i,j)**2+nsss(i,j)**2)
602  end do
603  end do
604 
605  if ((.not.hflswitch).or.(.not.strswitch)) then
606  write(*,*) 'WARNING: No flux data contained in GRIB file ', &
607  wfnamen(l,indj)
608 
609  ! CALCULATE USTAR AND SSHF USING THE PROFILE METHOD
610  ! As ECMWF has increased the model resolution, such that now the first model
611  ! level is at about 10 m (where 10-m wind is given), use the 2nd ECMWF level
612  ! (3rd model level in FLEXPART) for the profile method
613  !***************************************************************************
614 
615  do i=0,nxn(l)-1
616  do j=0,nyn(l)-1
617  plev1=akz(3)+bkz(3)*psn(i,j,1,n,l)
618  pmean=0.5*(psn(i,j,1,n,l)+plev1)
619  tv=tthn(i,j,3,n,l)*(1.+0.61*qvhn(i,j,3,n,l))
620  fu=-r_air*tv/ga/pmean
621  hlev1=fu*(plev1-psn(i,j,1,n,l)) ! HEIGTH OF FIRST MODEL LAYER
622  ff10m= sqrt(u10n(i,j,1,n,l)**2+v10n(i,j,1,n,l)**2)
623  fflev1=sqrt(uuhn(i,j,3,l)**2+vvhn(i,j,3,l)**2)
624  call pbl_profile(psn(i,j,1,n,l),td2n(i,j,1,n,l),hlev1, &
625  tt2n(i,j,1,n,l),tthn(i,j,3,n,l),ff10m,fflev1, &
626  surfstrn(i,j,1,n,l),sshfn(i,j,1,n,l))
627  if(sshfn(i,j,1,n,l).gt.200.) sshfn(i,j,1,n,l)=200.
628  if(sshfn(i,j,1,n,l).lt.-400.) sshfn(i,j,1,n,l)=-400.
629  end do
630  end do
631  endif
632 
633 
634  ! Assign 10 m wind to model level at eta=1.0 to have one additional model
635  ! level at the ground
636  ! Specific humidity is taken the same as at one level above
637  ! Temperature is taken as 2 m temperature
638  !**************************************************************************
639 
640  do i=0,nxn(l)-1
641  do j=0,nyn(l)-1
642  uuhn(i,j,1,l)=u10n(i,j,1,n,l)
643  vvhn(i,j,1,l)=v10n(i,j,1,n,l)
644  qvhn(i,j,1,n,l)=qvhn(i,j,2,n,l)
645  tthn(i,j,1,n,l)=tt2n(i,j,1,n,l)
646  end do
647  end do
648 
649  if(iumax.ne.nuvz-1) stop &
650  'READWIND: NUVZ NOT CONSISTENT FOR A NESTING LEVEL'
651  if(iwmax.ne.nwz) stop &
652  'READWIND: NWZ NOT CONSISTENT FOR A NESTING LEVEL'
653 
654  end do
655 
656  return
657 888 write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD #### '
658  write(*,*) ' #### ',wfnamen(l,indj),' FOR NESTING LEVEL #### '
659  write(*,*) ' #### ',l,' IS NOT GRIB FORMAT !!! #### '
660  stop 'Execution terminated'
661 
662 
663 999 write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD #### '
664  write(*,*) ' #### ',wfnamen(l,indj),' #### '
665  write(*,*) ' #### CANNOT BE OPENED FOR NESTING LEVEL ',l,'####'
666 
667 end subroutine readwind_nests
subroutine readwind_nests(indj, n, uuhn, vvhn, wwhn)
character(len=15) function, public vtable_get_fpname(igrib, vtable_object)
subroutine pbl_profile(ps, td2m, zml1, t2m, tml1, u10m, uml1, stress, hf)
Definition: pbl_profile.f90:22
subroutine, public vtable_load_by_name(vtable_name, the_vtable_data)
integer function, public vtable_detect_gribfile_type(gribfilename)