! compute the daily wind dir, representative wind speed and umax, umin subroutine day_wind( i rnd1, rnd2, month, dirf, o idir, wdir, a, urep, umax, umin) include 'wind_db.fi' real rnd1, rnd2 integer month real dirf(0:NDIR,0:NMONTHS-1) integer idir ! index for wind directions real wdir ! actual computed wind direction in degrees real a ! tmp variable real urep, umax, umin integer i real tmpres ! tmp variable integer gotit ! tmp variable c compute predominant wind direction on a daily basis (idir) if (rnd1 .gt. dirf(NDIR-1,month-1)) then idir = CALM else gotit = 0 do 90 i = 0, NDIR-1 if (rnd1 .gt. dirf(i,month-1)) then if (rnd1 .le.dirf(i+1,month-1)) then idir = i gotit = gotit + 1 endif endif 90 continue endif if (gotit .eq. 0) then ! catch if rnd1 = 1 and dirf(dir,)<1 idir = NDIR - 1 endif if (idir .eq. CALM) then wdir = -1.0 urep = 0.0 umax = 0.0 umin = 0.0 else ! We do have a blowing wdir = idir * 22.5 a = 1/shape(idir, month-1) tmpres = -(log(1.0 - rnd2)) urep = scale(idir, month-1)*((tmpres)**a) umax = 2 * ratio(month-1) * urep / (1 + ratio(month-1)) umin = umax / ratio(month-1) endif return end