67 real(kind=4) :: uuh(0:nxmax-1,0:nymax-1,nuvzmax)
68 real(kind=4) :: vvh(0:nxmax-1,0:nymax-1,nuvzmax)
69 real(kind=4) :: wwh(0:nxmax-1,0:nymax-1,nwzmax)
92 integer :: gribver,parcat,parnum,typsurf,valsurf,discipl
112 integer :: numpt,numpu,numpv,numpw,numprh
113 real :: help, temp,
ew
115 real :: ulev1(0:nxmax-1,0:nymax-1),vlev1(0:nxmax-1,0:nymax-1)
116 real :: tlev1(0:nxmax-1,0:nymax-1)
117 real :: qvh2(0:nxmax-1,0:nymax-1)
118 integer :: i179,i180,i181
126 character(LEN=255),
parameter :: vtable_ncep_grib1_path = &
127 "Vtable_ncep_grib1", &
128 vtable_ncep_grib2_path = &
133 integer :: gribfile_type
134 integer :: current_grib_level
135 character(len=255) :: gribfile_name
136 character(len=255) :: vtable_path
137 character(len=15) :: fpname
155 real(kind=4) :: zsec4(jpunp)
156 real(kind=4) :: xaux,yaux,xaux0,yaux0
157 real(kind=8) :: xauxin,yauxin
158 real(kind=4) :: ewss(0:nxmax-1,0:nymax-1),nsss(0:nxmax-1,0:nymax-1)
159 real :: plev1,hlev1,ff10m,fflev1
160 logical :: hflswitch,strswitch
169 integer :: ii,i,j,k,levdiff2,ifield,iumax,iwmax
174 real,
parameter :: eps=1.e-4
176 character(len=24) :: griberrormsg =
'Error reading grib file'
177 character(len=20) :: gribfunction =
'readwind_gfs'
222 levdiff2=nlev_ec-nwz+1
231 gribfile_name = path(3)(1:length(3))//trim(wfname(indj))
232 print *,
'gribfile_name: ', gribfile_name
236 print *,
'gribfile_type: ', gribfile_type
238 if (gribfile_type .eq. vtable_gribfile_type_ncep_grib1)
then
239 vtable_path = vtable_ncep_grib1_path
240 else if (gribfile_type .eq. vtable_gribfile_type_ncep_grib2)
then
241 vtable_path = vtable_ncep_grib2_path
243 print *,
'Unsupported gribfile_type: ', gribfile_type
249 print *,
'Loading Vtable: ', vtable_path
251 print *,
'Vtable Initialized: ', my_vtable%initialized
252 print *,
'Vtable num_entries: ', my_vtable%num_entries
261 5 call grib_open_file(ifile,path(3)(1:length(3)) &
262 //trim(wfname(indj)),
'r',iret)
263 if (iret.ne.grib_success)
then
267 call grib_multi_support_on
279 call grib_new_from_file(ifile,igrib,iret)
280 if (iret.eq.grib_end_of_file)
then
282 elseif (iret.ne.grib_success)
then
300 call grib_get_int(igrib,
'editionNumber',gribver,iret)
301 call grib_check(iret,gribfunction,griberrormsg)
303 if (gribver.eq.1)
then
305 call grib_get_int(igrib,
'level', current_grib_level, iret)
306 call grib_check(iret,gribfunction,griberrormsg)
310 current_grib_level = current_grib_level*100.0
314 call grib_get_int(igrib,
'scaledValueOfFirstFixedSurface', &
315 current_grib_level, iret)
316 call grib_check(iret,gribfunction,griberrormsg)
320 if (trim(fpname) .ne.
'None')
then
322 call grib_get_real4_array(igrib,
'values',zsec4,iret)
323 call grib_check(iret,gribfunction,griberrormsg)
330 call grib_get_int(igrib,
'numberOfPointsAlongAParallel', &
332 call grib_check(iret,gribfunction,griberrormsg)
333 call grib_get_int(igrib,
'numberOfPointsAlongAMeridian', &
335 call grib_check(iret,gribfunction,griberrormsg)
336 call grib_get_real8(igrib,
'longitudeOfFirstGridPointInDegrees', &
338 call grib_check(iret,gribfunction,griberrormsg)
339 call grib_get_real8(igrib,
'latitudeOfLastGridPointInDegrees', &
341 call grib_check(iret,gribfunction,griberrormsg)
342 xaux=xauxin+
real(nxshift)*dx
351 if(isec2(2).ne.nxfield) stop
'READWIND: NX NOT CONSISTENT'
352 if(isec2(3).ne.ny) stop
'READWIND: NY NOT CONSISTENT'
354 if(xaux.eq.0.) xaux=-179.0
357 if(xaux.lt.0.) xaux=xaux+360.
358 if(yaux.lt.0.) yaux=yaux+360.
359 if(xaux0.lt.0.) xaux0=xaux0+360.
360 if(yaux0.lt.0.) yaux0=yaux0+360.
361 if(abs(xaux-xaux0).gt.eps) &
362 stop
'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
363 if(abs(yaux-yaux0).gt.eps) &
364 stop
'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
380 if( trim(fpname) .eq.
'TT' )
then
383 if((i.eq.0).and.(j.eq.0))
then
385 if (current_grib_level .eq. akz(ii)) numpt=ii
388 help=zsec4(nxfield*(ny-j-1)+i+1)
390 tth(i179+i,j,numpt,n)=help
392 tth(i-i181,j,numpt,n)=help
400 if( trim(fpname) .eq.
'UU' )
then
403 if((i.eq.0).and.(j.eq.0))
then
405 if (current_grib_level .eq. akz(ii)) numpu=ii
408 help=zsec4(nxfield*(ny-j-1)+i+1)
410 uuh(i179+i,j,numpu)=help
412 uuh(i-i181,j,numpu)=help
419 if( trim(fpname) .eq.
'VV' )
then
422 if((i.eq.0).and.(j.eq.0))
then
424 if (current_grib_level .eq. akz(ii)) numpv=ii
427 help=zsec4(nxfield*(ny-j-1)+i+1)
429 vvh(i179+i,j,numpv)=help
431 vvh(i-i181,j,numpv)=help
439 if( trim(fpname) .eq.
'WW' )
then
442 if((i.eq.0).and.(j.eq.0))
then
444 if (current_grib_level .eq. akz(ii)) numpw=ii
447 help=zsec4(nxfield*(ny-j-1)+i+1)
449 wwh(i179+i,j,numpw)=help
451 wwh(i-i181,j,numpw)=help
459 if( trim(fpname) .eq.
'RH' )
then
462 if((i.eq.0).and.(j.eq.0))
then
464 if (current_grib_level .eq. akz(ii)) numprh=ii
467 help=zsec4(nxfield*(ny-j-1)+i+1)
469 qvh(i179+i,j,numprh,n)=help
471 qvh(i-i181,j,numprh,n)=help
479 if( trim(fpname) .eq.
'PS' )
then
482 help=zsec4(nxfield*(ny-j-1)+i+1)
484 ps(i179+i,j,1,n)=help
486 ps(i-i181,j,1,n)=help
494 if( trim(fpname) .eq.
'SD' )
then
497 help=zsec4(nxfield*(ny-j-1)+i+1)
499 sd(i179+i,j,1,n)=help
501 sd(i-i181,j,1,n)=help
509 if( trim(fpname) .eq.
'SLP' )
then
512 help=zsec4(nxfield*(ny-j-1)+i+1)
514 msl(i179+i,j,1,n)=help
516 msl(i-i181,j,1,n)=help
524 if( trim(fpname) .eq.
'TCC' )
then
527 help=zsec4(nxfield*(ny-j-1)+i+1)
529 tcc(i179+i,j,1,n)=help
531 tcc(i-i181,j,1,n)=help
538 if( trim(fpname) .eq.
'U10' )
then
541 help=zsec4(nxfield*(ny-j-1)+i+1)
543 u10(i179+i,j,1,n)=help
545 u10(i-i181,j,1,n)=help
552 if( trim(fpname) .eq.
'V10' )
then
555 help=zsec4(nxfield*(ny-j-1)+i+1)
557 v10(i179+i,j,1,n)=help
559 v10(i-i181,j,1,n)=help
567 if( trim(fpname) .eq.
'T2' )
then
570 help=zsec4(nxfield*(ny-j-1)+i+1)
572 tt2(i179+i,j,1,n)=help
574 tt2(i-i181,j,1,n)=help
581 if( trim(fpname) .eq.
'TD2' )
then
584 help=zsec4(nxfield*(ny-j-1)+i+1)
586 td2(i179+i,j,1,n)=help
588 td2(i-i181,j,1,n)=help
596 if( trim(fpname) .eq.
'LSPREC' )
then
599 help=zsec4(nxfield*(ny-j-1)+i+1)
601 lsprec(i179+i,j,1,n)=help
603 lsprec(i-i181,j,1,n)=help
611 if( trim(fpname) .eq.
'CONVPREC' )
then
614 help=zsec4(nxfield*(ny-j-1)+i+1)
616 convprec(i179+i,j,1,n)=help
618 convprec(i-i181,j,1,n)=help
626 if( trim(fpname) .eq.
'ORO' )
then
629 help=zsec4(nxfield*(ny-j-1)+i+1)
632 excessoro(i179+i,j)=0.0
636 excessoro(i-i181,j)=0.0
644 if( trim(fpname) .eq.
'LSM' )
then
647 help=zsec4(nxfield*(ny-j-1)+i+1)
659 if( trim(fpname) .eq.
'HMIX' )
then
662 help=zsec4(nxfield*(ny-j-1)+i+1)
664 hmix(i179+i,j,1,n)=help
666 hmix(i-i181,j,1,n)=help
674 if( trim(fpname) .eq.
'RH2' )
then
677 help=zsec4(nxfield*(ny-j-1)+i+1)
689 if( trim(fpname) .eq.
'TSIG1' )
then
692 help=zsec4(nxfield*(ny-j-1)+i+1)
704 if( trim(fpname) .eq.
'USIG1' )
then
707 help=zsec4(nxfield*(ny-j-1)+i+1)
718 if( trim(fpname) .eq.
'VSIG1' )
then
721 help=zsec4(nxfield*(ny-j-1)+i+1)
737 if( trim(fpname) .eq.
'UU')
then
743 call grib_release(igrib)
751 call grib_close_file(ifile)
765 if (gribver.eq.2)
then
769 if (convprec(i179+i,j,1,n).lt.lsprec(i179+i,j,1,n))
then
770 lsprec(i179+i,j,1,n)= &
771 lsprec(i179+i,j,1,n)-convprec(i179+i,j,1,n)
773 lsprec(i179+i,j,1,n)=0
776 if (convprec(i-i181,j,1,n).lt.lsprec(i-i181,j,1,n))
then
777 lsprec(i-i181,j,1,n)= &
778 lsprec(i-i181,j,1,n)-convprec(i-i181,j,1,n)
780 lsprec(i-i181,j,1,n)=0
796 plev1=akm(k)+bkm(k)*ps(i,j,1,n)
797 elev=
ew(temp)*help/100.0
798 qvh(i,j,k,n)=xmwml*(elev/(plev1-((1.0-xmwml)*elev)))
811 elev=
ew(temp)/100.*help/100.
812 td2(i,j,1,n)=243.5/(17.67/log(elev/6.112)-1)+273.
813 if (help.le.0.) td2(i,j,1,n)=tt2(i,j,1,n)
817 if(levdiff2.eq.0)
then
821 wwh(i,j,nlev_ec+1)=0.
864 convprec(i,j,1,n)=convprec(i,j,1,n)*3600.
865 lsprec(i,j,1,n)=lsprec(i,j,1,n)*3600.
866 surfstr(i,j,1,n)=sqrt(ewss(i,j)**2+nsss(i,j)**2)
870 if ((.not.hflswitch).or.(.not.strswitch))
then
880 ff10m= sqrt(u10(i,j,1,n)**2+v10(i,j,1,n)**2)
881 fflev1=sqrt(ulev1(i,j)**2+vlev1(i,j)**2)
883 tt2(i,j,1,n),tlev1(i,j),ff10m,fflev1, &
884 surfstr(i,j,1,n),sshf(i,j,1,n))
885 if(sshf(i,j,1,n).gt.200.) sshf(i,j,1,n)=200.
886 if(sshf(i,j,1,n).lt.-400.) sshf(i,j,1,n)=-400.
892 if(iumax.ne.nuvz) stop
'READWIND: NUVZ NOT CONSISTENT'
893 if(iumax.ne.nwz) stop
'READWIND: NWZ NOT CONSISTENT'
896 888
write(*,*)
' #### FLEXPART MODEL ERROR! WINDFIELD #### '
897 write(*,*)
' #### ',wfname(indj),
' #### '
898 write(*,*)
' #### IS NOT GRIB FORMAT !!! #### '
899 stop
'Execution terminated'
900 999
write(*,*)
' #### FLEXPART MODEL ERROR! WINDFIELD #### '
901 write(*,*)
' #### ',wfname(indj),
' #### '
902 write(*,*)
' #### CANNOT BE OPENED !!! #### '
903 stop
'Execution terminated'
subroutine readwind_gfs(indj, n, uuh, vvh, wwh)
character(len=15) function, public vtable_get_fpname(igrib, vtable_object)
subroutine shift_field(field, nxf, nyf, nzfmax, nzf, nmax, n)
subroutine pbl_profile(ps, td2m, zml1, t2m, tml1, u10m, uml1, stress, hf)
subroutine, public vtable_load_by_name(vtable_name, the_vtable_data)
subroutine shift_field_0(field, nxf, nyf)
integer function, public vtable_detect_gribfile_type(gribfilename)