Extract Local Variable

Description:  removes a subexpression from a larger expression and assigns that subexpression to a local variable, replacing the original subexpression with a reference to that variable. This refactoring is usually used to eliminate duplicated subexpressions or to introduce explanatory variable names into complex expressions.

State: Implemeted         Author: Jeff Overbey      Version:   Photran 5.0

Code Example:

    program main

   if(ind.eq.2)then
        nlh=nl/2+1
        global_umax=0.
        do 50 k=nlh,nl
        do 50 lgns=1,lat2
        do 50 mg=1,lon
        global_umax=max(global_umax, _
          sqrt(ureal(mg,lgns,k)**2+vreal(mg,lgns,k)**2) )
   50   continue
   end if

end program

    program main
   real :: velocity

   if(ind.eq.2)then
        nlh=nl/2+1
        global_umax=0.
        do 50 k=nlh,nl
        do 50 lgns=1,lat2
        do 50 mg=1,lon
        global_umax=max(global_umax, _
          velocity = vreal(mg,lgns,k)
          sqrt(ureal(mg,lgns,k)**2+velocity**2) )
   50   continue
   end if

end program

ScreenShots

          



HTML Comment Box is loading comments...