cli_wndgen.f90 Source File


This file depends on

sourcefile~~cli_wndgen.f90~~EfferentGraph sourcefile~cli_wndgen.f90 cli_wndgen.f90 sourcefile~climate_module.f90 climate_module.f90 sourcefile~cli_wndgen.f90->sourcefile~climate_module.f90 sourcefile~hydrograph_module.f90 hydrograph_module.f90 sourcefile~cli_wndgen.f90->sourcefile~hydrograph_module.f90 sourcefile~time_module.f90 time_module.f90 sourcefile~cli_wndgen.f90->sourcefile~time_module.f90 sourcefile~hydrograph_module.f90->sourcefile~time_module.f90 sourcefile~basin_module.f90 basin_module.f90 sourcefile~hydrograph_module.f90->sourcefile~basin_module.f90

Source Code

      subroutine cli_wndgen(iwgn)
      
!!    ~ ~ ~ PURPOSE ~ ~ ~
!!    this subroutine generates wind speed

!!    ~ ~ ~ INCOMING VARIABLES ~ ~ ~
!!    name        |units         |definition
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
!!    idg(:)      |none          |array location of random number seed used
!!                               |for a given process
!!    j           |none          |HRU number
!!    rndseed(:,:)|none          |random number seeds
!!    wndav(:,:)  |m/s           |average wind speed for the month in HRU
!!    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
!!    ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!!    Intrinsic: Log
!!    SWAT: Aunif
!!    ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

      use hydrograph_module
      use climate_module
      use time_module
      
      implicit none
      
      real :: v6 = 0.             !none          |random number between 0.0 and 1.0
      real :: v7 = 0.             !              |
      real :: rdir2 = 0.          !              |
      real :: pi2 = 0.            !              |
      integer :: idir = 0         !none          |counter
      integer :: idir1 = 0        !              |
      integer :: idir2 = 0        !              |
      integer :: mo = 0           !              |
      integer :: iwgn             !              | 
      integer :: iwndir = 0       !              |
      real :: aunif               !              |
      real :: g = 0.              !              |

      pi2 = 6.283185
      mo = time%mo
      
      !! Generate wind speed !!
      v6 = Aunif(rndseed(idg(5),iwgn))
      wst(iwst)%weat%windsp = wgn(iwgn)%windav(time%mo) * (-Log(v6)) ** 0.3
      
      !! Generate wind direction !!
      !!! set to zero, no longer attempt to read in
      iwndir = 0
      if (iwndir > 0) then
      idir1 = 16
      idir2 = 15
      v7 = Aunif(rndseed(idg(5),iwgn))
      do idir = 1, 16
        if (wnd_dir(iwndir)%dir(mo,idir) > v7) then
          idir1 = idir
          idir2 = idir - 1
          exit
        end if
      end do
      if (idir1 == 1) then
        g = v7 / wnd_dir(iwndir)%dir(mo,idir1)
      else
        g = (v7 - wnd_dir(iwndir)%dir(mo,idir2)) /                        &
           (wnd_dir(iwndir)%dir(mo,idir1) - wnd_dir(iwndir)%dir(mo,idir2))
      end if

      rdir2 = float (idir2)
      wst(iwst)%weat%wndir = pi2 * (g + rdir2 - .5) / 16.
      wst(iwst)%weat%wndir = pi2 + wst(iwst)%weat%wndir
      end if
      
      return
      end subroutine cli_wndgen