66 real(kind=4) :: uuh(0:nxmax-1,0:nymax-1,nuvzmax)
67 real(kind=4) :: vvh(0:nxmax-1,0:nymax-1,nuvzmax)
68 real(kind=4) :: wwh(0:nxmax-1,0:nymax-1,nwzmax)
91 integer :: gribver,parcat,parnum,typsurf,valsurf,discipl
111 integer :: numpt,numpu,numpv,numpw,numprh
112 real :: help, temp,
ew
114 real :: ulev1(0:nxmax-1,0:nymax-1),vlev1(0:nxmax-1,0:nymax-1)
115 real :: tlev1(0:nxmax-1,0:nymax-1)
116 real :: qvh2(0:nxmax-1,0:nymax-1)
117 integer :: i179,i180,i181
122 integer :: isec1(8),isec2(3)
123 real(kind=4) :: zsec4(jpunp)
124 real(kind=4) :: xaux,yaux,xaux0,yaux0
125 real(kind=8) :: xauxin,yauxin
126 real(kind=4) :: ewss(0:nxmax-1,0:nymax-1),nsss(0:nxmax-1,0:nymax-1)
127 real :: plev1,hlev1,ff10m,fflev1
128 logical :: hflswitch,strswitch
137 integer :: ii,i,j,k,levdiff2,ifield,iumax,iwmax
142 real,
parameter :: eps=1.e-4
144 character(len=24) :: griberrormsg =
'Error reading grib file'
145 character(len=20) :: gribfunction =
'readwind_gfs'
183 levdiff2=nlev_ec-nwz+1
191 5 call grib_open_file(ifile,path(3)(1:length(3)) &
192 //trim(wfname(indj)),
'r',iret)
193 if (iret.ne.grib_success)
then
197 call grib_multi_support_on
209 call grib_new_from_file(ifile,igrib,iret)
210 if (iret.eq.grib_end_of_file)
then
212 elseif (iret.ne.grib_success)
then
217 call grib_get_int(igrib,
'editionNumber',gribver,iret)
218 call grib_check(iret,gribfunction,griberrormsg)
220 if (gribver.eq.1)
then
223 call grib_get_int(igrib,
'indicatorOfParameter',isec1(6),iret)
224 call grib_check(iret,gribfunction,griberrormsg)
225 call grib_get_int(igrib,
'indicatorOfTypeOfLevel',isec1(7),iret)
226 call grib_check(iret,gribfunction,griberrormsg)
227 call grib_get_int(igrib,
'level',isec1(8),iret)
228 call grib_check(iret,gribfunction,griberrormsg)
233 call grib_get_int(igrib,
'discipline',discipl,iret)
234 call grib_check(iret,gribfunction,griberrormsg)
235 call grib_get_int(igrib,
'parameterCategory',parcat,iret)
236 call grib_check(iret,gribfunction,griberrormsg)
237 call grib_get_int(igrib,
'parameterNumber',parnum,iret)
238 call grib_check(iret,gribfunction,griberrormsg)
239 call grib_get_int(igrib,
'typeOfFirstFixedSurface',typsurf,iret)
240 call grib_check(iret,gribfunction,griberrormsg)
241 call grib_get_int(igrib,
'scaledValueOfFirstFixedSurface', &
243 call grib_check(iret,gribfunction,griberrormsg)
249 if ((parcat.eq.0).and.(parnum.eq.0).and.(typsurf.eq.100))
then
253 elseif ((parcat.eq.2).and.(parnum.eq.2).and.(typsurf.eq.100))
then
257 elseif ((parcat.eq.2).and.(parnum.eq.3).and.(typsurf.eq.100))
then
261 elseif ((parcat.eq.2).and.(parnum.eq.8).and.(typsurf.eq.100))
then
265 elseif ((parcat.eq.1).and.(parnum.eq.1).and.(typsurf.eq.100))
then
269 elseif ((parcat.eq.1).and.(parnum.eq.1).and.(typsurf.eq.103))
then
273 elseif ((parcat.eq.0).and.(parnum.eq.0).and.(typsurf.eq.103))
then
277 elseif ((parcat.eq.2).and.(parnum.eq.2).and.(typsurf.eq.103))
then
281 elseif ((parcat.eq.2).and.(parnum.eq.3).and.(typsurf.eq.103))
then
285 elseif ((parcat.eq.3).and.(parnum.eq.1).and.(typsurf.eq.101))
then
289 elseif ((parcat.eq.3).and.(parnum.eq.0).and.(typsurf.eq.1))
then
293 elseif ((parcat.eq.1).and.(parnum.eq.13).and.(typsurf.eq.1))
then
297 elseif ((parcat.eq.0).and.(parnum.eq.0).and.(typsurf.eq.104))
then
301 elseif ((parcat.eq.2).and.(parnum.eq.2).and.(typsurf.eq.104))
then
305 elseif ((parcat.eq.2).and.(parnum.eq.3).and.(typsurf.eq.104))
then
309 elseif ((parcat.eq.3).and.(parnum.eq.5).and.(typsurf.eq.1))
then
313 elseif ((parcat.eq.0).and.(parnum.eq.0).and.(typsurf.eq.1) &
314 .and.(discipl.eq.2))
then
318 elseif ((parcat.eq.3).and.(parnum.eq.196).and.(typsurf.eq.1))
then
322 elseif ((parcat.eq.1).and.(parnum.eq.7).and.(typsurf.eq.1))
then
326 elseif ((parcat.eq.1).and.(parnum.eq.196).and.(typsurf.eq.1))
then
334 if (isec1(6).ne.-1)
then
336 call grib_get_real4_array(igrib,
'values',zsec4,iret)
337 call grib_check(iret,gribfunction,griberrormsg)
344 call grib_get_int(igrib,
'numberOfPointsAlongAParallel', &
346 call grib_check(iret,gribfunction,griberrormsg)
347 call grib_get_int(igrib,
'numberOfPointsAlongAMeridian', &
349 call grib_check(iret,gribfunction,griberrormsg)
350 call grib_get_real8(igrib,
'longitudeOfFirstGridPointInDegrees', &
352 call grib_check(iret,gribfunction,griberrormsg)
353 call grib_get_real8(igrib,
'latitudeOfLastGridPointInDegrees', &
355 call grib_check(iret,gribfunction,griberrormsg)
356 xaux=xauxin+
real(nxshift)*dx
361 if(isec2(2).ne.nxfield) stop
'READWIND: NX NOT CONSISTENT'
362 if(isec2(3).ne.ny) stop
'READWIND: NY NOT CONSISTENT'
363 if(xaux.eq.0.) xaux=-179.0
366 if(xaux.lt.0.) xaux=xaux+360.
367 if(yaux.lt.0.) yaux=yaux+360.
368 if(xaux0.lt.0.) xaux0=xaux0+360.
369 if(yaux0.lt.0.) yaux0=yaux0+360.
370 if(abs(xaux-xaux0).gt.eps) &
371 stop
'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
372 if(abs(yaux-yaux0).gt.eps) &
373 stop
'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
385 if (isec1(6).ne.-1)
then
389 if((isec1(6).eq.011).and.(isec1(7).eq.100))
then
391 if((i.eq.0).and.(j.eq.0))
then
393 if ((isec1(8)*100.0).eq.akz(ii)) numpt=ii
396 help=zsec4(nxfield*(ny-j-1)+i+1)
398 tth(i179+i,j,numpt,n)=help
400 tth(i-i181,j,numpt,n)=help
403 if((isec1(6).eq.033).and.(isec1(7).eq.100))
then
405 if((i.eq.0).and.(j.eq.0))
then
407 if ((isec1(8)*100.0).eq.akz(ii)) numpu=ii
410 help=zsec4(nxfield*(ny-j-1)+i+1)
412 uuh(i179+i,j,numpu)=help
414 uuh(i-i181,j,numpu)=help
417 if((isec1(6).eq.034).and.(isec1(7).eq.100))
then
419 if((i.eq.0).and.(j.eq.0))
then
421 if ((isec1(8)*100.0).eq.akz(ii)) numpv=ii
424 help=zsec4(nxfield*(ny-j-1)+i+1)
426 vvh(i179+i,j,numpv)=help
428 vvh(i-i181,j,numpv)=help
431 if((isec1(6).eq.052).and.(isec1(7).eq.100))
then
433 if((i.eq.0).and.(j.eq.0))
then
435 if ((isec1(8)*100.0).eq.akz(ii)) numprh=ii
438 help=zsec4(nxfield*(ny-j-1)+i+1)
440 qvh(i179+i,j,numprh,n)=help
442 qvh(i-i181,j,numprh,n)=help
445 if((isec1(6).eq.001).and.(isec1(7).eq.001))
then
447 help=zsec4(nxfield*(ny-j-1)+i+1)
449 ps(i179+i,j,1,n)=help
451 ps(i-i181,j,1,n)=help
454 if((isec1(6).eq.039).and.(isec1(7).eq.100))
then
456 if((i.eq.0).and.(j.eq.0))
then
458 if ((isec1(8)*100.0).eq.akz(ii)) numpw=ii
461 help=zsec4(nxfield*(ny-j-1)+i+1)
463 wwh(i179+i,j,numpw)=help
465 wwh(i-i181,j,numpw)=help
468 if((isec1(6).eq.066).and.(isec1(7).eq.001))
then
470 help=zsec4(nxfield*(ny-j-1)+i+1)
472 sd(i179+i,j,1,n)=help
474 sd(i-i181,j,1,n)=help
477 if((isec1(6).eq.002).and.(isec1(7).eq.102))
then
479 help=zsec4(nxfield*(ny-j-1)+i+1)
481 msl(i179+i,j,1,n)=help
483 msl(i-i181,j,1,n)=help
486 if((isec1(6).eq.071).and.(isec1(7).eq.244))
then
488 help=zsec4(nxfield*(ny-j-1)+i+1)
490 tcc(i179+i,j,1,n)=help
492 tcc(i-i181,j,1,n)=help
495 if((isec1(6).eq.033).and.(isec1(7).eq.105).and. &
496 (isec1(8).eq.10))
then
498 help=zsec4(nxfield*(ny-j-1)+i+1)
500 u10(i179+i,j,1,n)=help
502 u10(i-i181,j,1,n)=help
505 if((isec1(6).eq.034).and.(isec1(7).eq.105).and. &
506 (isec1(8).eq.10))
then
508 help=zsec4(nxfield*(ny-j-1)+i+1)
510 v10(i179+i,j,1,n)=help
512 v10(i-i181,j,1,n)=help
515 if((isec1(6).eq.011).and.(isec1(7).eq.105).and. &
516 (isec1(8).eq.02))
then
518 help=zsec4(nxfield*(ny-j-1)+i+1)
520 tt2(i179+i,j,1,n)=help
522 tt2(i-i181,j,1,n)=help
525 if((isec1(6).eq.017).and.(isec1(7).eq.105).and. &
526 (isec1(8).eq.02))
then
528 help=zsec4(nxfield*(ny-j-1)+i+1)
530 td2(i179+i,j,1,n)=help
532 td2(i-i181,j,1,n)=help
535 if((isec1(6).eq.062).and.(isec1(7).eq.001))
then
537 help=zsec4(nxfield*(ny-j-1)+i+1)
539 lsprec(i179+i,j,1,n)=help
541 lsprec(i-i181,j,1,n)=help
544 if((isec1(6).eq.063).and.(isec1(7).eq.001))
then
546 help=zsec4(nxfield*(ny-j-1)+i+1)
548 convprec(i179+i,j,1,n)=help
550 convprec(i-i181,j,1,n)=help
553 if((isec1(6).eq.007).and.(isec1(7).eq.001))
then
555 help=zsec4(nxfield*(ny-j-1)+i+1)
558 excessoro(i179+i,j)=0.0
561 excessoro(i-i181,j)=0.0
564 if((isec1(6).eq.081).and.(isec1(7).eq.001))
then
566 help=zsec4(nxfield*(ny-j-1)+i+1)
573 if((isec1(6).eq.221).and.(isec1(7).eq.001))
then
575 help=zsec4(nxfield*(ny-j-1)+i+1)
577 hmix(i179+i,j,1,n)=help
579 hmix(i-i181,j,1,n)=help
582 if((isec1(6).eq.052).and.(isec1(7).eq.105).and. &
583 (isec1(8).eq.02))
then
585 help=zsec4(nxfield*(ny-j-1)+i+1)
592 if((isec1(6).eq.011).and.(isec1(7).eq.107))
then
594 help=zsec4(nxfield*(ny-j-1)+i+1)
601 if((isec1(6).eq.033).and.(isec1(7).eq.107))
then
603 help=zsec4(nxfield*(ny-j-1)+i+1)
610 if((isec1(6).eq.034).and.(isec1(7).eq.107))
then
612 help=zsec4(nxfield*(ny-j-1)+i+1)
625 if((isec1(6).eq.33).and.(isec1(7).eq.100))
then
630 call grib_release(igrib)
638 call grib_close_file(ifile)
652 if (gribver.eq.2)
then
656 if (convprec(i179+i,j,1,n).lt.lsprec(i179+i,j,1,n))
then
657 lsprec(i179+i,j,1,n)= &
658 lsprec(i179+i,j,1,n)-convprec(i179+i,j,1,n)
660 lsprec(i179+i,j,1,n)=0
663 if (convprec(i-i181,j,1,n).lt.lsprec(i-i181,j,1,n))
then
664 lsprec(i-i181,j,1,n)= &
665 lsprec(i-i181,j,1,n)-convprec(i-i181,j,1,n)
667 lsprec(i-i181,j,1,n)=0
683 plev1=akm(k)+bkm(k)*ps(i,j,1,n)
684 elev=
ew(temp)*help/100.0
685 qvh(i,j,k,n)=xmwml*(elev/(plev1-((1.0-xmwml)*elev)))
698 elev=
ew(temp)/100.*help/100.
699 td2(i,j,1,n)=243.5/(17.67/log(elev/6.112)-1)+273.
700 if (help.le.0.) td2(i,j,1,n)=tt2(i,j,1,n)
704 if(levdiff2.eq.0)
then
708 wwh(i,j,nlev_ec+1)=0.
751 convprec(i,j,1,n)=convprec(i,j,1,n)*3600.
752 lsprec(i,j,1,n)=lsprec(i,j,1,n)*3600.
753 surfstr(i,j,1,n)=sqrt(ewss(i,j)**2+nsss(i,j)**2)
757 if ((.not.hflswitch).or.(.not.strswitch))
then
767 ff10m= sqrt(u10(i,j,1,n)**2+v10(i,j,1,n)**2)
768 fflev1=sqrt(ulev1(i,j)**2+vlev1(i,j)**2)
770 tt2(i,j,1,n),tlev1(i,j),ff10m,fflev1, &
771 surfstr(i,j,1,n),sshf(i,j,1,n))
772 if(sshf(i,j,1,n).gt.200.) sshf(i,j,1,n)=200.
773 if(sshf(i,j,1,n).lt.-400.) sshf(i,j,1,n)=-400.
779 if(iumax.ne.nuvz) stop
'READWIND: NUVZ NOT CONSISTENT'
780 if(iumax.ne.nwz) stop
'READWIND: NWZ NOT CONSISTENT'
783 888
write(*,*)
' #### FLEXPART MODEL ERROR! WINDFIELD #### '
784 write(*,*)
' #### ',wfname(indj),
' #### '
785 write(*,*)
' #### IS NOT GRIB FORMAT !!! #### '
786 stop
'Execution terminated'
787 999
write(*,*)
' #### FLEXPART MODEL ERROR! WINDFIELD #### '
788 write(*,*)
' #### ',wfname(indj),
' #### '
789 write(*,*)
' #### CANNOT BE OPENED !!! #### '
790 stop
'Execution terminated'
subroutine shift_field(field, nxf, nyf, nzfmax, nzf, nmax, n)
subroutine readwind_gfs(indj, n, uuh, vvh, wwh)
subroutine pbl_profile(ps, td2m, zml1, t2m, tml1, u10m, uml1, stress, hf)
subroutine shift_field_0(field, nxf, nyf)