File: spd3d.f

package info (click to toggle)
vis5d 4.3-5
  • links: PTS
  • area: main
  • in suites: slink
  • size: 16,856 kB
  • ctags: 6,127
  • sloc: ansic: 66,158; fortran: 4,470; makefile: 1,683; tcl: 414; sh: 69
file content (75 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
C spd3d.f
C
C VIS-5D analysis function to compute 3-D wind velocity from
C U, V, and W components.

C See example.f for more information about writing functions.


      INTEGER FUNCTION USERFUNC( OUTGRID, OUTNL, OUTLOWLEV,
     *                           INGRID, NR, NC, NL, LOWLEV, MAXNL,
     *                           NVARS, NAMES,
     *                           DATE, TIME,
     *                           PROJECTION, PROJ_ARGS,
     *                           VERTICAL, VERT_ARGS )
C     ARGUMENTS:
      REAL OUTGRID(NR,NC,MAXNL)
      INTEGER OUTNL, OUTLOWLEV
      REAL INGRID(NR,NC,MAXNL,NVARS)
      INTEGER NR, NC, NL(NVARS), LOWLEV(NVARS), MAXNL
      INTEGER NVARS
      CHARACTER*8 NAMES(NVARS)
      INTEGER DATE, TIME
      INTEGER PROJECTION
      REAL PROJ_ARGS(*)
      INTEGER VERTICAL
      REAL VERT_ARGS(*)

C     LOCAL VARS:
      integer var, ir, ic, il
      integer iu, iv, iw
      real u, v, w, spd

C     Specify number of levels in OUTGRID
      OUTNL = MAXNL
      OUTLOWLEV = 0

C     Find the U and V variables
      iu = -1
      iv = -1
      iw = -1
      do var=1,nvars
         if (names(var) .eq. 'U') iu = var
         if (names(var) .eq. 'V') iv = var
         if (names(var) .eq. 'W') iw = var
      end do

C     If U, V or W not found, return error 1
      if (iu .eq. -1 .or. iv .eq. -1 .or. iw .eq. -1) then
         print *, "Couldn't find U, V, and/or W variables!"
         userfunc = 1
         return
      endif

C     Compute 3-D wind speed
      do il=1,maxnl
         do ic=1,nc
            do ir=1,nr
               u = ingrid(ir,ic,il,iu)
               v = ingrid(ir,ic,il,iv)
               w = ingrid(ir,ic,il,iw)
C              Check for missing data
               if (u .ge. 1.0e30 .or. v .ge. 1.0e30 .or.
     *             w .ge. 1.0e30) then
                  spd = 1.0e35
               else
                  spd = sqrt( u*u + v*v + w*w )
               end if
               outgrid(ir,ic,il) = spd
            end do
         end do
      end do

      USERFUNC = 0
      RETURN
      END