text:
! Copyright 2019 NREL

! Licensed under the Apache License, Version 2.0 (the "License"); you may not use
! this file except in compliance with the License. You may obtain a copy of the
! License at http://www.apache.org/licenses/LICENSE-2.0

! Unless required by applicable law or agreed to in writing, software distributed
! under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
! CONDITIONS OF ANY KIND, either express or implied. See the License for the
! specific language governing permissions and limitations under the License.
! -------------------------------------------------------------------------------------------
! This module contains basic functions used by the controller

! Functions:
!       AeroDynTorque: Calculate aerodynamic torque
!       ColemanTransform: Perform Colemant transform
!       ColemanTransformInverse: Perform inverse Colemant transform
!       CPFunction: Find Cp using parameterized surface
!       Debug: Debug the controller
!       DFController: DF control
!       identity: Make identity matrix
!       interp1d: 1-d interpolation
!       interp2d: 2-d interpolation
!       matinv3: 3x3 matrix inverse
!       PIController: implement a PI controller
!       ratelimit: Rate limit signal
!       saturate: Saturate signal

MODULE Functions

USE Constants

IMPLICIT NONE

CONTAINS
!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION saturate(inputValue, minValue, maxValue)
    ! Saturates inputValue. Makes sure it is not smaller than minValue and not larger than maxValue

        IMPLICIT NONE

        REAL(DbKi), INTENT(IN)     :: inputValue
        REAL(DbKi), INTENT(IN)     :: minValue
        REAL(DbKi), INTENT(IN)     :: maxValue

        saturate = REAL(MIN(MAX(inputValue,minValue), maxValue),DbKi)

    END FUNCTION saturate

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION ratelimit(inputSignal, inputSignalPrev, minRate, maxRate, DT)
    ! Saturates inputValue. Makes sure it is not smaller than minValue and not larger than maxValue
        IMPLICIT NONE

        REAL(DbKi), INTENT(IN)     :: inputSignal
        REAL(DbKi), INTENT(IN)     :: inputSignalPrev
        REAL(DbKi), INTENT(IN)     :: minRate
        REAL(DbKi), INTENT(IN)     :: maxRate
        REAL(DbKi), INTENT(IN)     :: DT
        ! Local variables
        REAL(DbKi)                 :: rate

        rate = (inputSignal - inputSignalPrev)/DT                       ! Signal rate (unsaturated)
        rate = saturate(rate, minRate, maxRate)                 ! Saturate the signal rate
        ratelimit = inputSignalPrev + rate*DT                       ! Saturate the overall command using the rate limit

    END FUNCTION ratelimit

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION PIController(error, kp, ki, minValue, maxValue, DT, I0, piP, reset, inst)
        USE ROSCO_Types, ONLY : piParams

    ! PI controller, with output saturation

        IMPLICIT NONE
        ! Allocate Inputs
        REAL(DbKi),    INTENT(IN)         :: error
        REAL(DbKi),    INTENT(IN)         :: kp
        REAL(DbKi),    INTENT(IN)         :: ki
        REAL(DbKi),    INTENT(IN)         :: minValue
        REAL(DbKi),    INTENT(IN)         :: maxValue
        REAL(DbKi),    INTENT(IN)         :: DT
        INTEGER(IntKi), INTENT(INOUT)      :: inst
        REAL(DbKi),    INTENT(IN)         :: I0
        TYPE(piParams), INTENT(INOUT)  :: piP
        LOGICAL,    INTENT(IN)         :: reset
        ! Allocate local variables
        !REMOVED BECAUSE UNUSED !!! INTEGER(IntKi)                      :: i                                            ! Counter for making arrays
        REAL(DbKi)                         :: PTerm                                        ! Proportional term

        ! Initialize persistent variables/arrays, and set inital condition for integrator term
        IF (reset) THEN
            piP%ITerm(inst) = I0
            piP%ITermLast(inst) = I0

            PIController = I0
        ELSE
            PTerm = kp*error
            piP%ITerm(inst) = piP%ITerm(inst) + DT*ki*error
            piP%ITerm(inst) = saturate(piP%ITerm(inst), minValue, maxValue)
            PIController = saturate(PTerm + piP%ITerm(inst), minValue, maxValue)

            piP%ITermLast(inst) = piP%ITerm(inst)
        END IF
        inst = inst + 1

    END FUNCTION PIController

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION PIIController(error, error2, kp, ki, ki2, minValue, maxValue, DT, I0, piP, reset, inst)
    ! PI controller, with output saturation.
    ! Added error2 term for additional integral control input
        USE ROSCO_Types, ONLY : piParams

        IMPLICIT NONE
        ! Allocate Inputs
        REAL(DbKi), INTENT(IN)         :: error
        REAL(DbKi), INTENT(IN)         :: error2
        REAL(DbKi), INTENT(IN)         :: kp
        REAL(DbKi), INTENT(IN)         :: ki2
        REAL(DbKi), INTENT(IN)         :: ki
        REAL(DbKi), INTENT(IN)         :: minValue
        REAL(DbKi), INTENT(IN)         :: maxValue
        REAL(DbKi), INTENT(IN)         :: DT
        INTEGER(IntKi), INTENT(INOUT)   :: inst
        REAL(DbKi), INTENT(IN)         :: I0
        TYPE(piParams), INTENT(INOUT) :: piP
        LOGICAL, INTENT(IN)         :: reset
        ! Allocate local variables
        !INTEGER(IntKi)                      :: i                                            ! Counter for making arrays
        REAL(DbKi)                         :: PTerm                                        ! Proportional term

        ! Initialize persistent variables/arrays, and set inital condition for integrator term
        IF (reset) THEN
            piP%ITerm(inst) = I0
            piP%ITermLast(inst) = I0
            piP%ITerm2(inst) = I0
            piP%ITermLast2(inst) = I0

            PIIController = I0
        ELSE
            PTerm = kp*error
            piP%ITerm(inst) = piP%ITerm(inst) + DT*ki*error
            piP%ITerm2(inst) = piP%ITerm2(inst) + DT*ki2*error2
            piP%ITerm(inst) = saturate(piP%ITerm(inst), minValue, maxValue)
            piP%ITerm2(inst) = saturate(piP%ITerm2(inst), minValue, maxValue)
            PIIController = PTerm + piP%ITerm(inst) + piP%ITerm2(inst)
            PIIController = saturate(PIIController, minValue, maxValue)

            piP%ITermLast(inst) = piP%ITerm(inst)
        END IF
        inst = inst + 1

    END FUNCTION PIIController

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION interp1d(xData, yData, xq, ErrVar)
    ! interp1d 1-D interpolation (table lookup), xData should be strictly increasing

        USE ROSCO_Types, ONLY : ErrorVariables
        IMPLICIT NONE

        ! Inputs
        REAL(DbKi), DIMENSION(:), INTENT(IN)       :: xData        ! Provided x data (vector), to be interpolated
        REAL(DbKi), DIMENSION(:), INTENT(IN)       :: yData        ! Provided y data (vector), to be interpolated
        REAL(DbKi), INTENT(IN)                     :: xq           ! x-value for which the y value has to be interpolated
        INTEGER(IntKi)                              :: I            ! Iteration index

        ! Error Catching
        TYPE(ErrorVariables), INTENT(INOUT)     :: ErrVar
        INTEGER(IntKi)                              :: I_DIFF

        CHARACTER(*), PARAMETER                 :: RoutineName = 'interp1d'

        ! Catch Errors
        ! Are xData and yData the same size?
        IF (SIZE(xData) .NE. SIZE(yData)) THEN
            ErrVar%aviFAIL = -1
            ErrVar%ErrMsg  = ' xData and yData are not the same size'
            WRITE(ErrVar%ErrMsg,"(A,I2,A,I2,A)") " SIZE(xData) =", SIZE(xData), &
            ' and SIZE(yData) =', SIZE(yData),' are not the same'
        END IF

        ! Is xData non decreasing
        DO I_DIFF = 1, size(xData) - 1
            IF (xData(I_DIFF + 1) - xData(I_DIFF) <= 0) THEN
                ErrVar%aviFAIL = -1
                ErrVar%ErrMsg  = ' xData is not strictly increasing'
                EXIT
            END IF
        END DO

        ! Interpolate
        IF (xq <= MINVAL(xData)) THEN
            interp1d = yData(1)
        ELSEIF (xq >= MAXVAL(xData)) THEN
            interp1d = yData(SIZE(xData))
        ELSE
            DO I = 1, SIZE(xData)
                IF (xq <= xData(I)) THEN
                    interp1d = yData(I-1) + (yData(I) - yData(I-1))/(xData(I) - xData(I-1))*(xq - xData(I-1))
                    EXIT
                ELSE
                    CONTINUE
                END IF
            END DO
        END IF

        ! Add RoutineName to error message
        IF (ErrVar%aviFAIL < 0) THEN
            ErrVar%ErrMsg = RoutineName//':'//TRIM(ErrVar%ErrMsg)
        ENDIF

    END FUNCTION interp1d

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION interp2d(xData, yData, zData, xq, yq, ErrVar)
    ! interp2d 2-D interpolation (table lookup). Query done using bilinear interpolation.
    ! Note that the interpolated matrix with associated query vectors may be different than "standard", - zData should be formatted accordingly
    ! - xData follows the matrix from left to right
    ! - yData follows the matrix from top to bottom
    ! A simple case: xData = [1 2 3], yData = [4 5 6]
    !        | 1    2   3
    !       -------------
    !       4| a    b   c
    !       5| d    e   f
    !       6| g    H   i

        USE ROSCO_Types, ONLY : ErrorVariables
        USE ieee_arithmetic

        IMPLICIT NONE

        ! Inputs
        REAL(DbKi), DIMENSION(:),   INTENT(IN)     :: xData        ! Provided x data (vector), to find query point (should be strictly increasing)
        REAL(DbKi), DIMENSION(:),   INTENT(IN)     :: yData        ! Provided y data (vector), to find query point (should be strictly increasing)
        REAL(DbKi), DIMENSION(:,:), INTENT(IN)     :: zData        ! Provided z data (vector), to be interpolated
        REAL(DbKi),                 INTENT(IN)     :: xq           ! x-value for which the z value has to be interpolated
        REAL(DbKi),                 INTENT(IN)     :: yq           ! y-value for which the z value has to be interpolated

        ! Allocate variables
        INTEGER(IntKi)                              :: i            ! Iteration index & query index, x-direction
        INTEGER(IntKi)                              :: ii           ! Iteration index & second que .  ry index, x-direction
        INTEGER(IntKi)                              :: j            ! Iteration index & query index, y-direction
        INTEGER(IntKi)                              :: jj           ! Iteration index & second query index, y-direction
        REAL(DbKi), DIMENSION(2,2)                 :: fQ           ! zData value at query points for bilinear interpolation
        REAL(DbKi), DIMENSION(1)                   :: fxy           ! Interpolated z-data point to be returned
        REAL(DbKi)                                 :: fxy1          ! zData value at query point for bilinear interpolation
        REAL(DbKi)                                 :: fxy2          ! zData value at query point for bilinear interpolation
        !LOGICAL                                 :: edge

        ! Error Catching
        TYPE(ErrorVariables), INTENT(INOUT)     :: ErrVar
        INTEGER(IntKi)                              :: I_DIFF

        CHARACTER(*), PARAMETER                 :: RoutineName = 'interp2d'

        ! Error catching
        ! Are xData and zData(:,1) the same size?
        IF (SIZE(xData) .NE. SIZE(zData,2)) THEN
            ErrVar%aviFAIL = -1
            WRITE(ErrVar%ErrMsg,"(A,I4,A,I4,A)") " SIZE(xData) =", SIZE(xData), &
            ' and SIZE(zData,1) =', SIZE(zData,2),' are not the same'
        END IF

        ! Are yData and zData(1,:) the same size?
        IF (SIZE(yData) .NE. SIZE(zData,1)) THEN
            ErrVar%aviFAIL = -1
            WRITE(ErrVar%ErrMsg,"(A,I4,A,I4,A)") " SIZE(yData) =", SIZE(yData), &
            ' and SIZE(zData,2) =', SIZE(zData,1),' are not the same'
        END IF

        ! Is xData non decreasing
        DO I_DIFF = 1, size(xData) - 1
            IF (xData(I_DIFF + 1) - xData(I_DIFF) <= 0) THEN
                ErrVar%aviFAIL = -1
                ErrVar%ErrMsg  = ' xData is not strictly increasing'
                EXIT
            END IF
        END DO

        ! Is yData non decreasing
        DO I_DIFF = 1, size(yData) - 1
            IF (yData(I_DIFF + 1) - yData(I_DIFF) <= 0) THEN
                ErrVar%aviFAIL = -1
                ErrVar%ErrMsg  = ' yData is not strictly increasing'
                EXIT
            END IF
        END DO

        ! ---- Find corner indices surrounding desired interpolation point -----
            ! x-direction
        IF (xq <= MINVAL(xData) .OR. (ieee_is_nan(xq))) THEN       ! On lower x-bound, just need to find zData(yq)
            j = 1
            jj = 1
            interp2d = interp1d(yData,zData(:,j),yq,ErrVar)
            RETURN
        ELSEIF (xq >= MAXVAL(xData)) THEN   ! On upper x-bound, just need to find zData(yq)
            j = size(xData)
            jj = size(xData)
            interp2d = interp1d(yData,zData(:,j),yq,ErrVar)
            RETURN
        ELSE
            DO j = 1,size(xData)
                IF (xq == xData(j)) THEN ! On axis, just need 1d interpolation
                    jj = j
                    interp2d = interp1d(yData,zData(:,j),yq,ErrVar)
                    RETURN
                ELSEIF (xq < xData(j)) THEN
                    jj = j
                    EXIT
                ELSE
                    CONTINUE
                END IF
            END DO
        ENDIF
        j = j-1 ! Move j back one
            ! y-direction
        IF (yq <= MINVAL(yData) .OR. (ieee_is_nan(yq))) THEN       ! On lower y-bound, just need to find zData(xq)
            i = 1
            ii = 1
            interp2d = interp1d(xData,zData(i,:),xq,ErrVar)
            RETURN
        ELSEIF (yq >= MAXVAL(yData)) THEN   ! On upper y-bound, just need to find zData(xq)
            i = size(yData)
            ii = size(yData)
            interp2d = interp1d(xData,zData(i,:),xq,ErrVar)
            RETURN
        ELSE
            DO i = 1,size(yData)
                IF (yq == yData(i)) THEN    ! On axis, just need 1d interpolation
                    ii = i
                    interp2d = interp1d(xData,zData(i,:),xq,ErrVar)
                    RETURN
                ELSEIF (yq < yData(i)) THEN
                    ii = i
                    EXIT
                ELSE
                    CONTINUE
                END IF
            END DO
        ENDIF
        i = i-1 ! move i back one

        ! ---- Do bilinear interpolation ----
        ! Find values at corners
        fQ(1,1) = zData(i,j)
        fQ(2,1) = zData(ii,j)
        fQ(1,2) = zData(i,jj)
        fQ(2,2) = zData(ii,jj)
        ! Interpolate
        fxy1 = (xData(jj) - xq)/(xData(jj) - xData(j))*fQ(1,1) + (xq - xData(j))/(xData(jj) - xData(j))*fQ(1,2)
        fxy2 = (xData(jj) - xq)/(xData(jj) - xData(j))*fQ(2,1) + (xq - xData(j))/(xData(jj) - xData(j))*fQ(2,2)
        fxy = (yData(ii) - yq)/(yData(ii) - yData(i))*fxy1 + (yq - yData(i))/(yData(ii) - yData(i))*fxy2

        interp2d = fxy(1)

        ! Add RoutineName to error message
        IF (ErrVar%aviFAIL < 0) THEN
            ErrVar%ErrMsg = RoutineName//':'//TRIM(ErrVar%ErrMsg)
        ENDIF

    END FUNCTION interp2d

!-------------------------------------------------------------------------------------------------------------------------------
    FUNCTION matinv3(A) RESULT(B)
    ! Performs a direct calculation of the inverse of a 3×3 matrix.
    ! Source: http://fortranwiki.org/fortran/show/Matrix+inversion
        REAL(DbKi), INTENT(IN) :: A(3,3)   !! Matrix
        REAL(DbKi)             :: B(3,3)   !! Inverse matrix
        REAL(DbKi)             :: detinv

        ! Calculate the inverse determinant of the matrix
        detinv = 1/(A(1,1)*A(2,2)*A(3,3) - A(1,1)*A(2,3)*A(3,2)&
                - A(1,2)*A(2,1)*A(3,3) + A(1,2)*A(2,3)*A(3,1)&
                + A(1,3)*A(2,1)*A(3,2) - A(1,3)*A(2,2)*A(3,1))

        ! Calculate the inverse of the matrix
        B(1,1) = +detinv * (A(2,2)*A(3,3) - A(2,3)*A(3,2))
        B(2,1) = -detinv * (A(2,1)*A(3,3) - A(2,3)*A(3,1))
        B(3,1) = +detinv * (A(2,1)*A(3,2) - A(2,2)*A(3,1))
        B(1,2) = -detinv * (A(1,2)*A(3,3) - A(1,3)*A(3,2))
        B(2,2) = +detinv * (A(1,1)*A(3,3) - A(1,3)*A(3,1))
        B(3,2) = -detinv * (A(1,1)*A(3,2) - A(1,2)*A(3,1))
        B(1,3) = +detinv * (A(1,2)*A(2,3) - A(1,3)*A(2,2))
        B(2,3) = -detinv * (A(1,1)*A(2,3) - A(1,3)*A(2,1))
        B(3,3) = +detinv * (A(1,1)*A(2,2) - A(1,2)*A(2,1))
    END FUNCTION matinv3

!-------------------------------------------------------------------------------------------------------------------------------
    FUNCTION identity(n) RESULT(A)
    ! Produces an identity matrix of size n x n

        INTEGER, INTENT(IN)         :: n
        REAL(DbKi), DIMENSION(n, n)    :: A
        INTEGER                     :: i
        INTEGER                     :: j

        ! Build identity matrix
        DO i=1,n
            DO j = 1,n
                IF (i == j) THEN
                    A(i,j) = 1.0
                ELSE
                    A(i,j) = 0.0
                ENDIF
            ENDDO
        ENDDO

    END FUNCTION identity

!-------------------------------------------------------------------------------------------------------------------------------
    SUBROUTINE ColemanTransform(rootMOOP, aziAngle, nHarmonic, axTOut, axYOut)
    ! The Coleman or d-q axis transformation transforms the root out of plane bending moments of each turbine blade
    ! to a direct axis and a quadrature axis

        IMPLICIT NONE
        ! Inputs
        REAL(DbKi), INTENT(IN)     :: rootMOOP(3)                      ! Root out of plane bending moments of each blade
        REAL(DbKi), INTENT(IN)     :: aziAngle                         ! Rotor azimuth angle
        INTEGER(IntKi), INTENT(IN)  :: nHarmonic                        ! The harmonic number, nP
        ! Outputs
        REAL(DbKi), INTENT(OUT)    :: axTOut, axYOut               ! Direct axis and quadrature axis outputted by this transform
        ! Local
        REAL(DbKi), PARAMETER      :: phi2 = 2.0/3.0*PI                ! Phase difference from first to second blade
        REAL(DbKi), PARAMETER      :: phi3 = 4.0/3.0*PI                ! Phase difference from first to third blade

        ! Body
        axTOut  = 2.0/3.0 * (cos(nHarmonic*(aziAngle))*rootMOOP(1) + cos(nHarmonic*(aziAngle+phi2))*rootMOOP(2) + cos(nHarmonic*(aziAngle+phi3))*rootMOOP(3))
        axYOut  = 2.0/3.0 * (sin(nHarmonic*(aziAngle))*rootMOOP(1) + sin(nHarmonic*(aziAngle+phi2))*rootMOOP(2) + sin(nHarmonic*(aziAngle+phi3))*rootMOOP(3))

    END SUBROUTINE ColemanTransform

!-------------------------------------------------------------------------------------------------------------------------------
    SUBROUTINE ColemanTransformInverse(axTIn, axYIn, aziAngle, nHarmonic, aziOffset, PitComIPC)
    ! The inverse Coleman or d-q axis transformation transforms the direct axis and quadrature axis
    ! back to root out of plane bending moments of each turbine blade
        IMPLICIT NONE
        ! Inputs
        REAL(DbKi), INTENT(IN)     :: axTIn, axYIn         ! Direct axis and quadrature axis
        REAL(DbKi), INTENT(IN)     :: aziAngle                     ! Rotor azimuth angle
        REAL(DbKi), INTENT(IN)     :: aziOffset                    ! Phase shift added to the azimuth angle
        INTEGER(IntKi), INTENT(IN)  :: nHarmonic                    ! The harmonic number, nP
        ! Outputs
        REAL(DbKi), INTENT(OUT)    :: PitComIPC(3)                   ! Commanded individual pitch (deg)
        ! Local
        REAL(DbKi), PARAMETER      :: phi2 = 2.0/3.0*PI                ! Phase difference from first to second blade
        REAL(DbKi), PARAMETER      :: phi3 = 4.0/3.0*PI                ! Phase difference from first to third blade

        ! Body
        PitComIPC(1) = cos(nHarmonic*(aziAngle+aziOffset))*axTIn + sin(nHarmonic*(aziAngle+aziOffset))*axYIn
        PitComIPC(2) = cos(nHarmonic*(aziAngle+aziOffset+phi2))*axTIn + sin(nHarmonic*(aziAngle+aziOffset+phi2))*axYIn
        PitComIPC(3) = cos(nHarmonic*(aziAngle+aziOffset+phi3))*axTIn + sin(nHarmonic*(aziAngle+aziOffset+phi3))*axYIn

    END SUBROUTINE ColemanTransformInverse

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION CPfunction(CP, lambda)
    ! Paremeterized Cp(lambda) function for a fixed pitch angle. Circumvents the need of importing a look-up table
        IMPLICIT NONE

        ! Inputs
        REAL(DbKi), INTENT(IN) :: CP(4)    ! Parameters defining the parameterizable Cp(lambda) function
        REAL(DbKi), INTENT(IN) :: lambda    ! Estimated or measured tip-speed ratio input

        ! Lookup
        CPfunction = exp(-CP(1)/lambda)*(CP(2)/lambda-CP(3))+CP(4)*lambda
        CPfunction = saturate(CPfunction, 0.001_DbKi, 1.0_DbKi)

    END FUNCTION CPfunction

!-------------------------------------------------------------------------------------------------------------------------------
    REAL(DbKi) FUNCTION AeroDynTorque(RotSpeed, BldPitch, LocalVar, CntrPar, PerfData, ErrVar)
    ! Function for computing the aerodynamic torque, divided by the effective rotor torque of the turbine, for use in wind speed estimation

        USE ROSCO_Types, ONLY : LocalVariables, ControlParameters, PerformanceData, ErrorVariables
        IMPLICIT NONE

        ! Inputs
        TYPE(ControlParameters), INTENT(IN) :: CntrPar
        TYPE(LocalVariables), INTENT(IN) :: LocalVar
        TYPE(PerformanceData), INTENT(IN) :: PerfData
        TYPE(ErrorVariables), INTENT(INOUT) :: ErrVar

        REAL(DbKi), INTENT(IN)  :: RotSpeed
        REAL(DbKi), INTENT(IN)  :: BldPitch

        ! Local
        REAL(DbKi) :: RotorArea
        REAL(DbKi) :: Cp
        REAL(DbKi) :: Lambda

        CHARACTER(*), PARAMETER                 :: RoutineName = 'AeroDynTorque'

        ! Find Torque
        RotorArea = PI*CntrPar%WE_BladeRadius**2
        Lambda = RotSpeed*CntrPar%WE_BladeRadius/LocalVar%WE_Vw

        ! Compute Cp
        Cp = interp2d(PerfData%Beta_vec,PerfData%TSR_vec,PerfData%Cp_mat, BldPitch*R2D, Lambda, ErrVar)

        AeroDynTorque = 0.5*(CntrPar%WE_RhoAir*RotorArea)*(LocalVar%WE_Vw**3/RotSpeed)*Cp
        AeroDynTorque = MAX(AeroDynTorque, 0.0_DbKi)

        ! Add RoutineName to error message
        IF (ErrVar%aviFAIL < 0) THEN
            ErrVar%ErrMsg = RoutineName//':'//TRIM(ErrVar%ErrMsg)
        ENDIF

    END FUNCTION AeroDynTorque

!-------------------------------------------------------------------------------------------------------------------------------
    ! Copied from NWTC_IO.f90
!> This function returns a character string encoded with today's date in the form dd-mmm-ccyy.
FUNCTION CurDate( )

    ! Function declaration.

    CHARACTER(11)                :: CurDate                                      !< 'dd-mmm-yyyy' string with the current date

    ! Local declarations.

    CHARACTER(8)                 :: CDate                                        ! String to hold the returned value from the DATE_AND_TIME subroutine call.

    !  Call the system date function.

    CALL DATE_AND_TIME ( CDate )

    !  Parse out the day.

    CurDate(1:3) = CDate(7:8)//'-'

    !  Parse out the month.

    SELECT CASE ( CDate(5:6) )
    CASE ( '01' )
        CurDate(4:6) = 'Jan'
    CASE ( '02' )
        CurDate(4:6) = 'Feb'
    CASE ( '03' )
        CurDate(4:6) = 'Mar'
    CASE ( '04' )
        CurDate(4:6) = 'Apr'
    CASE ( '05' )
        CurDate(4:6) = 'May'
    CASE ( '06' )
        CurDate(4:6) = 'Jun'
    CASE ( '07' )
        CurDate(4:6) = 'Jul'
    CASE ( '08' )
        CurDate(4:6) = 'Aug'
    CASE ( '09' )
        CurDate(4:6) = 'Sep'
    CASE ( '10' )
        CurDate(4:6) = 'Oct'
    CASE ( '11' )
        CurDate(4:6) = 'Nov'
    CASE ( '12' )
        CurDate(4:6) = 'Dec'
    END SELECT

    !  Parse out the year.

    CurDate(7:11) = '-'//CDate(1:4)

    RETURN
    END FUNCTION CurDate

!=======================================================================
!> This function returns a character string encoded with the time in the form "hh:mm:ss".
    FUNCTION CurTime( )

    ! Function declaration.

    CHARACTER(8)                 :: CurTime                                      !< The current time in the form "hh:mm:ss".

    ! Local declarations.

    CHARACTER(10)                :: CTime                                        ! String to hold the returned value from the DATE_AND_TIME subroutine call.

    CALL DATE_AND_TIME ( TIME=CTime )

    CurTime = CTime(1:2)//':'//CTime(3:4)//':'//CTime(5:6)

    RETURN
    END FUNCTION CurTime

!=======================================================================
! This function checks whether an array is non-decreasing
    LOGICAL Function NonDecreasing(Array)

    IMPLICIT NONE

    REAL(DbKi), DIMENSION(:)            :: Array
    INTEGER(IntKi)         :: I_DIFF

    NonDecreasing = .TRUE.
    ! Is Array non decreasing
    DO I_DIFF = 1, size(Array) - 1
        IF (Array(I_DIFF + 1) - Array(I_DIFF) <= 0) THEN
            NonDecreasing = .FALSE.
            RETURN
        END IF
    END DO

    RETURN
    END FUNCTION NonDecreasing

!=======================================================================
!> This routine converts all the text in a string to upper case.
    SUBROUTINE Conv2UC ( Str )

        ! Argument declarations.

     CHARACTER(*), INTENT(INOUT)  :: Str                                          !< The string to be converted to UC (upper case).

        ! Local declarations.

     INTEGER                      :: IC                                           ! Character index

     DO IC=1,LEN_TRIM( Str )

        IF ( ( Str(IC:IC) >= 'a' ).AND.( Str(IC:IC) <= 'z' ) )  THEN
           Str(IC:IC) = CHAR( ICHAR( Str(IC:IC) ) - 32 )
        END IF

     END DO ! IC

     RETURN
     END SUBROUTINE Conv2UC

!=======================================================================
     !> This function returns a left-adjusted string representing the passed numeric value.
    !! It eliminates trailing zeroes and even the decimal point if it is not a fraction. \n
    !! Use Num2LStr (nwtc_io::num2lstr) instead of directly calling a specific routine in the generic interface.
    FUNCTION Int2LStr ( Num )

        CHARACTER(11)                :: Int2LStr                                     !< string representing input number.

        ! Argument declarations.

        INTEGER, INTENT(IN)          :: Num                                          !< The number to convert to a left-justified string.

        WRITE (Int2LStr,'(I11)')  Num

        Int2Lstr = ADJUSTL( Int2LStr )

        RETURN
        END FUNCTION Int2LStr

END MODULE Functions

max_stars_repo_name: mvanv/ROSCO

max_issues_repo_name: mvanv/ROSCO

max_forks_repo_name: mvanv/ROSCO


text:
Aaron, Princess, lil Aaron, AlexChaun

530.750.APEX

Their Apex Cycles Bike Shop moved to 912 5th street in November, 2012.

Happy, go Lucky... Always willing to help.

Email Aaron with any Bicycle related questions. aaron@apexcycles.com.

Aaron came to Davis in 1997 to attend UC Davis on a full scholarship from The Buck Foundation.  During college, Aaron worked at a few of the downtown Bike Shops in addition to The Paint Chip, Mobile Connections, Jamba Juice, Cafe Roma, The Logical Learning Center, DM Information Systems, Inc., and Pak Mail. Aaron is very proud to say that he has never been unemployed for longer than 3 days (one time in 2004) since he was 14yrs old and that many of his jobs overlapped one another.

When hes not at his Apex Cycles Bike Shop, he can be found riding bikes with his kids around town.

Aaron and his boys train in Brazilian JiuJitsu, KaJuKenpo and Escrima.

Aaron prizes above all else, proper communication and respect.  A little known fact is that Aaron was adopted from Cambodia (even though everyone asumes hes from the Philippines) at the age of 3 by a retired Catholic Priest, and raised Jewish.

Aaron and his family are active members of the Davis community and can be found at most local functions especially if bikes are involved.  Aaron usually donates his time whenever a bike race or school bike safety rodeo needs a mechanic.  Aaron also works for the North Natomas TMA and is an outside sales rep for various brands in the bicycle industry for Hawaii.

If you happen to get a bike flat somewhere in town and happen to see his silver Honda Ridgeline or white Honda minivan with APEX stickers, he always carries tools, a pump and spare tubes.  Hell even give you a lift if needed.

Favorite Foods:

Sushi  Zen Toro hands down. Go 12 times a week
Indian  Kathmandu Kitchen, Rajas Owners are so genuinely nice, best nann bread ever
Thai  Thai Nakorn Nicest people around, Thai Canteen Cheap and good
Chinese  Shanghai Town Most authentic Ive found in town, Hunan One of the best lunch deals in town, Davis Noodle City Love the chicken chowmien and 5 spice beef noodle soup
Sandwich  Zias Delicatessen Meatball on a soft roll w/ $1 worth of pastrami, Beach Hut Deli North shore minus the ham
Brunch  Konditorei, Cafe Bernardo, Crepeville
Burger  InNOut Cheeseburger, animals style, protein style with fry light french fries, Burgers and Brew Spicy Guacamole Burger
Pizza  Village Bakery Veggie
Gelato/Yogurt  Icekrimski Cafe Coconut macadamia nut, Swirl I know its Cultivé Frozen Yogurt now, but it will always be Swirls to me.  Try the Taro flavor, reminds me of Ubi ice cream.  If you know what that is, you get a brownie point.

20080706 21:57:19 nbsp What was objectionable about http://daviswiki.org/Bizarro_World?actiondiff&version231&version130 this edit? If Im reading it right he gave reference to a nearby landmark. Users/JasonAller

20080706 22:00:12 nbsp Sorry, figured it out. Ill invite him to create a page for the new business. You only removed his second comment and I missed his first. Users/JasonAller

20080820 21:40:16 nbsp Jason and I both fixed it at the same time.  There was a bold in the very top announcement that wasnt closed. Users/JabberWokky

20081008 09:06:59 nbsp Sagat has yet to acknowledge the existence of her own page, perhaps you could clue her in that she can click her name and voila? Uni does need some color!

Hey, want a challenge you wont be able to fix (no shop in Northern California has been able to help me, including all the usual suspects in Davis bike church,bike exchange, places in sac, etc)? I have a 4 speed sturmey archer from a moulten that is from early 60s and has working full suspension, the piece that goes in the center of the sturmey (axle thingy) snapped... I really want to get this bike working again cause its just awesome and utterly classic... Users/StevenDaubert

20081008 19:26:12 nbsp Heya, is there a fee to get an appointment on Sunday?  My back wheel bearings are shot and need to be replaced.  I might even need a red tuning (or at the least a yellow) once you see how bad the wheels are. Users/SunjeetBaadkar

20081009 10:41:57 nbsp What sunny warrants a response but I dont? Users/StevenDaubert

20081020 10:34:51 nbsp What up Aaron, I talked with Sagat yesterday and apparently she is having one of her buddies who is an artist come in from Japan! Like I said sagat wasnt aware of the personal page, but I told her how to peep scene!

P.S. give the students there fixie fix and when it slows down and you want a real challenge I will bring my moulten thru. I honestly dont expect you to succeed where every bike shop for 50 miles hasnt, but its still worth a shot! Users/StevenDaubert

20081020 21:05:49 nbsp Hello Aaron. Thank you very much for your offer! Actually we have been working with a couple artists about showcasing their work in our shop. However, nothing will be confirmed until November. I shall let you know as soon as I find out!  Users/Sagat

20081209 19:18:28 nbsp sounds great! Users/StevenDaubert

20081213 07:38:46 nbsp No problem.  Ive been meaning to mention that there are some issues with that layout on smaller monitors, with the images on the left and right top pinching the text.  You might want to move the ones on the left down to the text.  Its not a tremendously big deal, but if you have your browser window sized certain ways (or have certain resolution screens), it can look odd and hard to read (the table gets squeezed).  I think I fixed it awhile back, and you migrated the photos back up over time, but I never bothered to fix it again, as its not a terrible problem.  When it gets really small, the table pops to below the photos. Users/JabberWokky

20081224 12:47:06 nbsp Did you ever get a chance to visit Konditorei at its old location? Users/StevenDaubert

20081224 12:54:19 nbsp ¬_¬

So yeah, scratch trying to fix the moulten, my dad would rather throw away history then have it take up a small small spot of his garage... Users/StevenDaubert

20090423 02:15:34 nbsp you should try thai dynamite Users/StevenDaubert

20090725 17:18:32 nbsp Thanks. I already got my current issues resolved but maybe next time.  Users/RealComputers

20090731 10:07:57 nbsp Well, the first thing that comes to mind when setting any event up is the audience. First off, what kind of crowds it brings. Understandably that would be the biking community. However, there is that secondary issue of the moneymaking community. My worry is the legitimacy of this sort of event. There would have to be a way to make sure that parts being traded and sold are not illegally obtained. What is to stop someone from stealing a random bike earlier in the day, breaking it apart, and then selling the nonlicensed parts? When a bike is licensed via TAPS or whatnot, it is licensed as a whole. That is just a random thought that comes to mind (evil minds arent necessarily evil themselves). Reputable vendors would need to be contacted and nonreputable vendors would need to be verified. However, the perfect venue would be Central Park. It is close to most places people bike near/to so that works out pretty well for the people who somehow arent reached by advertising methods. As far as advertising, that is the easy part. With enough time (but not too much time), the internet, flyers, word of mouth, and calling in favors is how it is done (at least in my world). I could easily help with that part if you need. But frankly, I think it is a great idea if only the people buying and selling were people at manned booths with a background that is traceable. I think the idea that someone can walk up off the street and sell something to someone other person off the street is a bit tricky if there is an altercation. Otherwise, great idea. It would need to be brainstormed more, but yeah. Let me know if you want my help. Users/SunjeetBaadkar

20090914 14:58:00 nbsp Hey Aaron, I have a cheap mountain bike, the pedals have some movement that they shouldnt have (its kinda up and down, as if they arent seated with the axle or whatnot) I have another exact copy of the same cheap bike that doesnt have the problem... How do I swap / repair? Users/StevenDaubert
 Upon further reflection I think Im going to just unbend the other bikes bent derailer hanger and then move the good derailer onto the old bike... How much do you want for use of a chain breaker onsite @ apex ?

20090922 08:51:57 nbsp Others might disagree, but I think the reason to keep those brief is because the page is a directory pointing people to the more detailed entries about each shop or resource.  The text should be however long it takes to distinguish each for somebody scanning over the list looking for something particular. Users/JabberWokky

20091212 11:36:28 nbsp I went and asked for wiki:wikispotCommunity Guidelines/Business promotion questions/Talk clarification. Hopefully the answer will make things clearer for everyone. Despite any issues that arise the good news that comes with this change is that the way is cleared to now make some improvements to the software that hosts Davis Wiki and the other Wiki Spot wikis. Users/JasonAller

20100201 19:03:03 nbsp regarding your bizarro votes: reread question #2  thats not a direct link, its a general link.  the text was a link to comics and to roleplaying.    Just like every thai place links to thai restaurants and every barber shop links back to stylist places, etc.   question #1 is about the direct link.  Users/EdWins

20100414 14:13:05 nbsp I will bring you an abalone to the bbq, bring a cooler or a bucket that can hold some water to put it in. Users/DagonJones

20100529 18:40:12 nbsp Hey Aaron, I missed you at the bbq, I had your abalone.  I am in Fort Bragg right now and will be bring back a few abalone.   If your shop is open on monday I will gladly bring by one or two to give to you.  Otherwise, I can bring one by to another location if you like.  I will likely have more than I can eat.  Just  let me know. Users/DagonJones

20100603 22:17:03 nbsp your welcome.  I am glad you enjoyed it, I will have to try it that way some time.  someone told me it is good to steam it with sake.  your kids seemed to enjoy poking at it when I brought it over. Users/DagonJones

20100628 22:55:29 nbsp bike is working great, thanks for the help.  It is nice to not have my chain skipping all the time. Users/DagonJones

20100712 10:12:53 nbsp Ugh, sorry to hear about your experience at Bistro.  I despise that place. Users/TomGarberson

20100712 10:22:22 nbsp What a great family portrait!!   Users/CovertProfessor

  Thanks... it was taken at the UCD Arboretum by  Musa Zaid, musazaid@gmail.com.  Hes a great local Photographer that used to work for the Aggie and is now at UCSF Med School.  Email him if you ever need some pics done.  his family still lives in Davis, so he comes back and forth regularly.

20100807 15:18:24 nbsp It was nice running into you today!

I bought the stickers http://www.123stickers.com/index.asp?PageActionVIEWCATS&Category202 here and bought 500 of the 4.25 x 1.38 ones. The file I sent them is http://daviswiki.org/Wiki_Sticker/StickiWiki_Design_Contest?actionFiles&doview&targetoriginalishinverted.tif here. It took me about a week to get them! Users/WilliamLewis

20100902 08:48:40 nbsp Hey Aaron, thanks so much for the auction donation!  I think my wife may be bidding on the tuneup, since shes headed back to school next week.  Her poor bike has been largely neglected over the summer.  (Dont tell her I said that, shell feel guilty) Users/TomGarberson

20100922 23:14:14 nbsp Good man on the bike pump Users/StevenDaubert

20101013 21:33:57 nbsp Good luck with the possible expansion! Users/WilliamLewis

20101201 10:17:31 nbsp Bad luck about the chuck... I hope it was a case of somebody pocketing it while they were working on their bike and forgetting or some similar case of neglect rather than malice. Users/JabberWokky

  Nope... they stole it.  The compressor in question is the one that I left a hose outside for people to use anytime.  If the chuck is removed, the hose leaks and makes a huge racket with the compressor constantly running and trying to fill the tank.  So they new what they were doing as it would be instantaneous loud obnoxious noise.  When I came to the shop in the morning, the compressor was still running (and overheating) so I had to unplug it.  Its too bad really, as many people came by and used it on a regular basis.  Users/Aaron.Curtin

20110216 20:48:02 nbsp I probably wont swing by anytime soon, so why dont you email me at dagonjones at gmail.com  I am happy to answer any questions you have. Users/DagonJones

20110415 13:45:51 nbsp Hey Aaron, I noticed the $15 off any tuneup for studentsis the $25/45/75/105 set of figures listed on Bicycle Shops still current?  If so, whats actually included in the $10 (with discount for students) tuneup?  Thats an impressive price! Users/TomGarberson

20110828 20:21:15 nbsp Just wanted to say that I hope all is well with the family. Saw the message on the door of your shop during my shift.  My prayers are with you. Users/WesP
  Things are getting better, but being an only child, everything falls on my shoulders.  My parents are both not doing well, so I have to take care of everything for them in addition to trying to take care of everything here.  I hope that in the next few weeks I can get everything taken care of and back to a normal life.  I appreciate your kind words and all the support and understanding Ive gotten from customers.  Heres to better days ahead. Users/Aaron.Curtin

20111013 16:24:02 nbsp Thanks for the info Aaron. Ill probably check with Freewheeler first since thats where I got my bike, but youre my backup ) Users/MeggoWaffle

20111022 10:25:18 nbsp how was your tenure at DM info? Ever run into Scott there? Also I saw the APEX name on one of those Taco bell one dollar to charity cards! Props for donating to charity, unprops for eating TB {{{^__~}}}
I still remember when I thought fast food was a treat ugh Users/StevenDaubert

  I worked At DM Info, when it was independently owned.  Not a horrible job, but not the best for a college student with an short attention span (in my case).  Mainly worked on the Aerojet litigation.  Too much time in front of a computer screen.  They did have free ice cream sandwiches in the employee lounge though ;)  As for TB, yeah... try to not go there more than 2x a month... lesser of 2 evils when compared to Jack in the Box.
Verily, all fast food is gnarbar... Daubert
  I just quoted your reply to Sarah, and she laughed and said, he is a wonderful person.  More people should use the word verily. jw
   Im guessing this is the worlds first sentence to use both verily and gnarbar.  cp

20111105 04:28:07 nbsp goodbye and good riddance?

now we just have to get the alley un painted from that stupid shade of green Users/StevenDaubert

20120329 10:22:27 nbsp I just bought the groupon for a tuneup at APEX.  My poor bike is sadly neglected, looking forward to getting it fixed up a bit.  I know Im going to need a new tube, and Im guessing new brake cables as well. Users/TomGarberson

20120624 15:26:48 nbsp tell me a little more about your experience with Ally if you please Users/StevenDaubert

  What would you like to know? How after 3 years they still havent given me the light switch and socket covers (which puts me in violation of fire codes for which I have been cited), or how I got the run around for 2 years about expanding/moving to another larger location next door, or how I was told my current location was 600sq/ft and charged accordingly but after measuring its only 351sq/ft with no explanation on their part.  Dealing with them has been/is a nightmare.

20120711 16:02:27 nbsp Hey Aaron, Im inheriting an oldish road bike my dad doesnt ride anymore.  Its been hanging in his garage for a decade or two, so it may need some wheel work.  Also, his old biking shoes wont fit me... do you carry various types of shoes?  I have no idea what kind of pedals are on the bike (and if I did I wouldnt know what it meant).  Am I likely to need to get new pedals, along with shoes?  If so, any recommendations on how to go about selecting something suitable for me? Users/TomGarberson

20130522 17:46:10 nbsp Sinish has the manager make orders from classico (the distributor), talk to them or just tell them you want to order one of the I think 5 liter tubs if you really really want it back... Users/StevenDaubert

20130625 11:14:44 nbsp Aaron, I see that http://daviswiki.org/T%26M_Bike_Shop?actiondiff&version24&version13 this negative comment was left from the same IP addresses IP address that you yourself used, just minutes before, to make edits on the same page, a competitors page.  I dont think of you as the sort of businessman who would engage in that sort of sockpuppets sockpuppeting against a potential competitor.  Can you clarify? Users/CovertProfessor

  I usually use the other handle when I dont want things directly tied to me.  But I left nothing negative.  Statement of facts.  wiki (which I based my visit on) and sign in the window said open at 10. I got There at 10:30.  They werent there so I left after waiting for about 20 minutes because I had to get to the shop and open myself.  Called numerous times when I got to my shop and they didnt get in until noon.  I realize thyre new, and wanted to see what They had to offer.  Nothing out of the ordinary or to differentiate themselves from any of the other shops.  I have yet to test their bike knowledge, but time will tell. Users/Aaron.Curtin
   Aaronnot sure youre seeing the point. It isnt your job to test them...also saying 1st impressions not too great. is definitely a negative statement. Why dont you focus on your bike business.  If your product and services are good enough to fulfill the community needs, you shouldnt have to worry about what other businesses are doing. Users/PeteB

  Not open, next to nothing for sale... these Are all Things I had to deal with years ago.  Are they reliable, not sure, but considering what limited experience Ive had with then, Id say not so.  It is my place to see what other business are doing as all the bike shops in town are not only in friendly competition, but also part of the cycling community as a whole.  We rely on each other for parts, tools or advice.  If I cant use them as such why should anyone else?  1st impression not too great.  I didnt mention that there were 2 other potential customers there that were waiting that left.  I never mentioned to them that I owned a shop or to go anywhere else.  I let them formulate that opinion on their own.  This was my experience and within my right to voice it.  I have since removed all association with the other handle and posted under my REAL name,  Feel free to talk to me in person anytime.  You can find me at my shop during regular POSTED business hours unless Im at lunch, but Id be willing to schedule an appointment if youd like.  Aaron
   Thank you for correcting your attempt to hide behind a false name, however, if I come to Davis Ill shop elsewhere. Attempts like yours kill my faith in businesses.  Users/PeteB

  Attempt at what? Are you implying something, because it would be better if you just came out and said what you are thinking rather than beat around the bush.  If you do decide to come to Davis, fell free to shop elsewhere.  Better yet, check Daviswiki, youll find many useful reviews and customer feedback in regards to me and my business practices.  Im not perfect, nor did I ever claim to be, but as far as bikes are concerned, you wont find anyone better.  That said, I do reserve the right to refuse service as well.  Aaron

20130625 13:48:45 nbsp Not trying to air your personal business, but that comment reads very differently coming from you vs. a customer. Users/CovertProfessor

  Regardless if you were or not, you did, and that was what I was trying to avoid in the first place.   Aaron
   Im not getting it.  You were the one who revealed the information about yourself and your family.  Not sure why it airs your personal business to say that you were the one who wrote it.  cp

  I changed it to my real name to apease the DWgods... at the time it was meant to be anonymous. By you reveling that it was me, you outed me and aspects of my personal life that I was not comfortable with at the time.  Why is that so hard for you to understand considering you dont even use your own real name when editing the wiki?  Aaron
   Aaronagain youre not getting it, man. No matter what you do on the Wikianyone can see by the IPs that you were the same person posting from both accounts. You outed yourself. Please stop blaming others for what you set yourself up for. Users/PeteB
   Youll just have to take my word for it  I genuinely dont understand.  I can see why you wouldnt use your own name when commenting on a business, although I think its shady when you do it while critiquing a competitor (and hey, everyone else can see that it was a critique but you).  But I truly dont understand the comment on your own page.  Using your pseudonym, you wrote, In response to all the recent questions and concerns about the shop. I have to say that this is still one of the best little bike shops around. They are going through some tough times right now as it is a family business and I overheard one of the volunteers mentioning that Aaron has been dealing with his mothers Alzheimers and has had to close the shop periodically to deal with that. I rolled past tonight, and there he was working late into the night to try and make up for not being open during the day. He said he wont be around again tomorrow since he has to follow up with doctors and find an assisted living facility for his mother. If you need to get something done with your bike, hes still one of the best local resources. He hopes that all his loyal customers understand and that he will try to have the shop up and running regular hours by the middle of the week. Feel free to call him or shoot him an email with any questions.  That comment in itself revealed your personal life about you caring for your mother; I didnt do it.  My saying it was you who wrote it lets people know that youre willing to pretend to be a customer who says praiseworthy things about your own business.  Sorry, that doesnt reflect well on you.  I can see that you were going through a bad time, so I am sympathetic  but still, it was not the right thing to do.  So, who is in the wrong here  the person who sockpuppeted about his own business, pretending to be a customer who said it was one of the best little bike shops around, or the person who pointed out the other persons bad behavior?   Users/CovertProfessor

  @ CP, I understand your point on that, and during that time I WAS going through a lot, dealing with my 90 year old Fathers failing health, and my mothers Alzheimers, while raising my young family and running my business.  More than any 30 year old should have to endure. For that I apologize. But this more recent use of my formerly anonymous account was strictly for reference without being targeted as biased.  As anyone who really knows me as a person, not just as a business entity, they will tell you that I dont have a malicious bone in my body.  @ PeteB, youre blowing it out of proportion.  And I may have inadvertently outed myself via IP addresses, but that shred of anonymity was lost when CP posted who I was.  Even if its one click away, at least there was another step to hide who I was.  I dont have to answer to any of you.  Ive been in business for 7 years, Ill be here as long as I want.  I have wholeheartedly supported the Daviswiki, financially and in spirit, but today its over.  I have touted to other local business owners the benefits of the wiki to deaf ears.  Now I share their sentiment as it has grown into a circle jerk of moderators  Aaron
   Aaron, youve been a valued member of the DavisWiki for many years.  Thats why I was so surprised to see you sockpuppet a competitor today.  I think maybe you need to take a step back, maybe ask some people not involved with the wiki what they think, and really reflect on whether its right to do what you did today on a competitors business page.  I think youll see that you ought not to have done that.  No one is trying to come down hard on you.  In fact, notice that no one has written anything on your business page about this.  To be clear, I am not making a threat (I have no intention of making such an edit), but pointing out that editors have in fact been fairly gentle with your behavior, behavior that has always been frowned upon.  Youve been editing the wiki long enough to know that sockpuppeting a business is not acceptable.  Id like to see you continue to edit the wiki in a productive way, as you always have in the past.   Users/CovertProfessor
   AaronI am truly sorry for the tribulations you experienced with your parents. Mine are both elderly and in failing health so Im entering a hard time myself but CP really is spot on here. Noone is trying to chase you away at all. We really want you to be a productive contributor. Please consider whats been said here. Users/PeteB

And vise versa  Aaron

20130625 15:48:20 nbsp First edit with the other account was three years ago... Outside of http://daviswiki.org/APEX_Cycles_%26_Service?actiondiff&version2266&version1265 this which is technically sockpuppety but is of a much lesser degree (compared to examples like http://daviswiki.org/DOSiRAK?actiondiff&version215&version114 these with attacks on competitors)...  Pretty long con to attack a new used bike store when there are stronger competitors in town, and it didnt even seem like much of an attack. I feel like there was either a huge amount of malice that required serious longterm planning and slightly negative remarks to eventually ruin someones business (a plan that was ruined by not using a proxy) or maybe a person genuinely curious about another business who wanted to share his experience with another shop, but figured he would be burned alive if people found out he owned a bike shop. I can definitely understand why someone might want to review anonymously (business owners, professors, celebrities), and it might even be positive to the community if someone with a strong following (like a celebrity) would prefer their words be taken because of their previous contribution to the site rather than their status in the real world. If the anonymous account consistently provides good contributions, I dont think it would be a terrible idea if some people decided to have a separate anonymous account to review things. For example on a forum, if a popular moderator were to say something positive about something, youre most likely going to get a circlejerk just due to that moderators status, so if the moderator wanted his or her words taken seriously, posting on a regular account might be beneficial for the community.  Users/hankim
   To be clear: I dont object to him having a separate, anonymous account that he uses to comment on restaurants and such.  I object to him using it to say good things about his business and bad things about competitors businesses.  The fact that he didnt create the account in order to do that specifically, or that there are worse instances of sockpuppeting   both points I acknowledge  doesnt change the fact that what he did in those two instances was shady. I can understand the urge, but I still think its shady.   Users/CovertProfessor
     Definitely the first sockpuppetry act was shady (the one on his own business page) but I feel like the second one didnt seem malicious. I dont have an issue with a bike store owner reviewing other bike stores anonymously as long as he isnt lying about his experience there and he actually visited the shop. Users/hankim
      I see a reason but again IPs are logged and if he understood that in any way, then he had to know hed be discovered and questions would arise (again setting himself up). My only thought is he didnt realize his IPs were being logged? Users/PeteB
      I dont think it was malicious, no.  But he wrote things that cast the other place in a bad light.  In such a case, it matters that he has a financial stake.  cp
       A financial stake in taking out a new bike shop when there are larger and more established businesses in town? Users/hankim
        As Aaron himself said, Davis is a town that has more than a dozen competing businesses all vying for the same limited customer base.  cp
      That nails it perfectly CP...Users/PeteB
This isnt that big a deal. Id just suggest the problem go away: http://daviswiki.org/T%26M_Bike_Shop/Talk  Users/DonShor

What did I say specifically warrants that the comment should go away?  Aaron
 Youre a competitor, Aaron. Im not going to go over and critique another garden center. My critique wouldnt be the point. Its a conflict of interest.  Don

  I DIDNT CRITIQUE, I STATED THEY WERENT OPEN DURING POSTED HOURS (I WAITED 20 MINUTES BUT HAD TO LEAVE TO OPEN MY OWN SHOP) AND DESCRIBED WHAT I SAW IN THE STOREFRONT.  NOT ONCE DID I SAY ANYTHING NEGATIVE ABOUT THEIR QUALITY OF WORK OR PRODUCT.  AARON

   Aaronone simple quote but 1st impressions not too great. That seems negative to me. As Daubert stated, Its not what you say but how you say it .  That could give someone a negative opinion of the bike shop right off the bat.  Thank you for updating your original post on the page for their shop.Users/PeteB

@Don, Are we not all friends and here for the benefit of the wiki? If I were looking at a garden center, Id want your opinion, because I respect it because I know that you know gardening.  Wether it be in a public forum or in private.  Who knows a field better than ones own?

@ Pete, So youre telling me if I were to say, 1st impressions not too great about any other business then itd be ok? But since I singled out the new business to which I had yet to formulate an opinion as a consumer or competitor and didnt have a great 1st impression I should have kept it to myself?

My opinion of them stands, its my opinion of Daviswiki that has changed.  Aaron

20130625 18:38:53 nbsp Their Bike Shop is moving to 912 Fifth Street Suite 105 within the next few weeks hasnt the shop been moved? Users/StevenDaubert

NITPICK MUCH?  AARON

No not really I just noticed that you have outdated information on your page. I would change it but its your userpage. Therefore I settled for second best which is telling you. ~SD

  Hmm... lets see.  You didnt tell me, you passive aggressively made it known.  Ill quote you on this one.  Its not what you say, its how you say it   Aaron

   AaronDaubert was perfectly in his rights and very appropriate in how he posted it. I suggest everyone just leave this alone for the night and if need be revisit it tmrw.  Users/PeteB

Stay out of it Pete.  This is between me and SD.  Aaron

20130626 09:17:26 nbsp Dont forget places like http://daviswiki.org/The_Used_Phone_Store this and http://daviswiki.org/Bookstores these. People need to know what kind of phones they can purchase and all the publishers of products the bookstores might sell. Users/hankim

20130626 09:27:37 nbsp Heres a sequence of events that I see.  For years, you are considered a valued and productive member of the Davis Wiki.  Your business page is, in fact, a disaster.  Its promotional and bolded and over the top.  But I think everyone looked the other way because you were one of us.  Then you sockpuppeted against a defender.  Anyone can make a mistake, but in fact, youve defended your actions when someone as experienced with the wiki as you ought to know that what you did was wrong.  Now youre just retaliating by making a mess of the wiki.  Basically, your spending all the capital youve built over the years.  You no longer come across as a good guy, happy go lucky, etc.  You come across as petty.  You might want to rethink your actions.  They are not helping you or your business.  Some friendly advice. Users/CovertProfessor

 Ive moved pass the sockpuppet debacle, I took my licks like a man and fessed up to it.  I updated and took credit for my posts.  I am now and still talking about what should be allowed on a business page.  If they can do it, so can all other retailers.  Do some research on their business, get to work and start editing, fix my sloppy haphazard edits and make the Daviswiki the best it can be.  Aaron

  I look at it like this, if its good for the goose, its good for the gander.  Just because its assumed or implied does not make it so.  I will spend time toning APEXs page down to the specs of the other pages, but I will aso try and make an attempt at other retailers pages to list what brands they sell new and used since thats what your argument is in regards to my wanting to remove it from T&M.  Lets educate the public rather than allow one retailer to benefit from the wikis indifference and self righteous atitude towards me.  As many of you have stated in regards to yourselves, I will continue to fight the good fight but as I see fit. I expect you all to do no less.  Aaron

20130626 15:48:37 nbsp May be worth stepping back for a bit and letting things cool off. Everyones already fired up.  Users/jefftolentino

20130626 15:54:51 nbsp Not yetIve had some work issues come up (server moves) and Im now doing dbl shifts the rest of the week. I promise Ill look into it when I can but work comes first. Will probably be next week at this point.Users/PeteB

20130702 21:27:44 nbsp Aaronwhen you asked me to look into Cannondale, I thought to check out some of the authorized dealers you list on the APEX Cycles page. What is concerning is that a few of themBiria Bicycles, Lynskey Titanium Bikes and Von Dessel (I spoke to 2Von Dessel emailed me back) have stated you are NOT an authorized dealer for their bikes.

Im going to be around very sporadically for the next few weeks as my elderly mother is very ill at a local hospital, but I wanted you to have an opportunity at clarifying the issues with these 3 companies. Users/PeteB
  Im curious to hear your reply to PeteB, given how concerned you were about other shops potentially misrepresenting who they are authorized dealers for.   Users/CovertProfessor
  Due to your not responding I have removed Biria & Lynskey & Von Dessel from your authorized dealers list. Both of them said (Biria & Lynskey)on the phone to me(Von Dessel informed me by email) that you are not an authorized dealer. If you are going to express concerns about other bike shops it would be appropriate to make sure your own list of authorized dealers is updated. Users/PeteB

   Wow, take a break from the wiki to let things cool down and this is where you guys want to take it.  Not sure who you talked to at Biria USA and Lynskey, but according to Michael Biria @ BiriaUSA (2014611980) and Don Erwin, Sales Manager or Jack Kopeski, Sales Account Manager @ Lynskey Performance (423.499.5815) I I am still an authorized dealer and considered a non stocking dealer respectively.  As for Van Dessel, I was the only dealer in the area for a long time and did not think to ever renew my dealership agreement as I always just ordered when I needed one.  Im fine with the removal of Van Dessel, but I urge you to call the names above to confirm my status with Biria and Lynskey.  I await your all powerful verdicts.  Aaron (07/16/13)

20130716 17:25:30 nbsp Terrific! You followed up and corrected the issuegreat! Thats what we were suggesting. Users/PeteB

20130716 17:32:33 nbsp I restored Biria and Lynskey. I called the #s on the website and was given to people who I simply asked the question if you were an authorized dealer and was told no. Straight up question and I was put on hold while they researched it and said you werent an authorized dealer. shrug. Maybe they have a staff issue but I am not responsible if they gave me inaccurate info Users/PeteB

20130716 19:06:53 nbsp PB gave you lots of time (two weeks) to respond before editing the page for your business, and then when he did edit the page, merely deleted the claims that were, as best as he could tell, false.  That is far more courtesy than you extended to your competitors.  You keep trying to act the injured party here, but I am not buying it. Users/CovertProfessor

  You dont have to buy it, you have to accept it because DW is a MPOV wiki.  Im sure you were curious, based off of you back handed/snide remark back on 07/02. And I didnt need to extend that courtesy, because I new for a fact that my competitor had no place claiming something that was false.  Its because of the one sided battle with the popular editors that I stayed away from the wiki for a while, but we can get back into it if you wish.  Aaron

  You can consider it snide if you like.  But in fact, it was a second invitation (PBs was the first) for you to respond.  But do I have to accept that you are an innocent party here?  No, I dont have to.    cp
   And sure, we can get back into how you sockpuppeted and used that sockpuppet to criticize a competitor, then acted like a spoiled child.  But hey, none of that reflects well on you, so I would drop it.  Even better, admit that you behaved badly.  Look, all that was needed here was for you to set the record straight on which companies you are in fact authorized for.  But youve come back with an attitude, so now youre making yourself and everyone miserable.  Doesnt have to be that way, but thats the bed youve made.  cp

   Sure, and we can go on about how you as a popular editor can make all the snide comments you wish with no recourse.  The kettle calling the pot black as it were.  AC

20130716 19:43:19 nbsp I didnt make that remark about popular editors  PB did.  I dont know why you keep mixing me up in that. Users/CovertProfessor

  I never said you did. Im generalizing that you popular editors like to tag team and at times are just as unproductive as anyone else.  I admit that much of what I have said recently has no benefit to the wiki, its the fact that I cant stand the condescending attitude from you guys (another generalization).  Look yourself in the mirror and ask yourself if you can truly say youve never said or done anything in frustration/anger that you later regret.  I apologize, if I didnt make it clear that I did before (and will probably have to apologize for the rest of my time on DW) for my actions and hope to make it a better place for all.  But I will not stand by and let the opinions of a select few try directly or indirectly make me out to be the villain.  I was merely pointing out that whomever PB talked to was misinformed, but I did see it as a direct retaliation for my previous actions.  If it truly was just to be fair, why not do it for ALL the shops, not just mine. He can shrug all he wants, but thats how it looks and again, I know first hand how appearances play a factor on DW.  But of course you had to chime in as well.  Was it productive and in the benefit of DW, some might say yes, and some might say no, but it did come off as snarky.  Again, something that I was crucified for being.  But in regards to EZ smog, I was totally justified in my opinion that PB made a mistake in mentioning the popularity of an editor to justify her stand on the matter.  So no matter how childish I may sound at times there is relevance to that post.  But you nor PB were able to see that.  You popular editors (again a generalization), saw that it was me and started to jump down my throat.  It would appear I was not the only child on the playground that day.  Aaron

There are a bunch of issues mixed together here, so let me separate them out and respond one at a time.
  I am not a popular editor; I am a frequent editor who has pissed off every single one of the other frequent editors on more than one occasion.  We dont all walk in lockstep, agreeing on everything.
  I agree, not all of my edits are productive and I have done things in frustration and anger that I have regretted later, here on the wiki and elsewhere.
  Thank you for the apology.  Prior to this, you defended your actions and then said you wanted to move on.  I would find it hard to work with someone who felt that such actions were legitimate.  Now that you have apologized, I can move on and not bring up the subject again.
  It was fine for you to point out that whoever PB talked to was misinformed.  Thats why we waited two weeks for your response  to hear your side of things.
  I see PBs checking up on your business as an issue of consistency.  If someone is going to make a big stink about other businesses, as you did, then they should expect that they will be examined in the same fashion.  They are in effect saying that these are the standards that they wish to be held by and by which they hold others. I am sorry if you see that as retaliatory, but I dont.
  I agree with you that being popular has nothing to do with comments that stay on EZSmog, but I never said otherwise.  My comment on the talk page was directed at the topic of the page, not at you.  I dont know why you insist on thinking that it had something to do with you.  I only responded to you when it seemed that you were criticizing my claim that the comment should stay on the page.

Users/CovertProfessor

20130716 20:35:20 nbsp Thank you for cleaning up the A1 Smog page, Aaron.  I hope you dont mind that Im staying out of this whole thing.  After having had to file a lawsuit after bullshit that grew out of wiki drama, I dont have much stomach for it.  Ill just note that I think everyone involved seems to be editing angry again, and it doesnt seem very constructive.  Calling your vendors did seem a bit retaliatory, and Im not a fan of that.  But I think todays discussion is only making things worse. Users/TomGarberson
    To answer TGs thoughtI called the vendors originally out of his concern that a competitor was inappropriately listing names of companies they were not authorized dealers for. If you are going to be concerned about the listings for other providers, I thought it reasonable to check for him too. Only after my research did I discover competitors page no longer has the listings but the work had already been done. In no way was it retaliatoryit was being fair. Users/PeteB

ext: f

max_stars_repo_name: voflo/Search

max_issues_repo_name: voflo/Search

max_forks_repo_name: voflo/Search


text:
!==============================================================================!
  subroutine Comm_Mod_Global_Min_Real(phi)
!------------------------------------------------------------------------------!
!   Dummy function for sequential runs.                                        !
!------------------------------------------------------------------------------!
  implicit none
!---------------------------------[Arguments]----------------------------------!
  real    :: phi
!==============================================================================!

  end subroutine

max_stars_repo_name: MassimoBorrelliPhysicist/T-Flows

max_issues_repo_name: MassimoBorrelliPhysicist/T-Flows

max_forks_repo_name: MassimoBorrelliPhysicist/T-Flows


text:
C **********************************************************************
C *                                                                    *
C * STRCPY - COPY STRING                                               *
C *                                                                    *
C * COPY SRC$ TO DST$. DST$ MUST BE LARGE ENOUGH TO ACCOMODATE SRC$.   *
C *                                                                    *
C **********************************************************************
C
      SUBROUTINE STRCPY(DST$, SRC$)
      REAL DST$, SRC$
C
      INTEGER I, J, K
      REAL S$
      INTEGER IS$(2), S$OFF, S$LEN
      REAL T$
      INTEGER IT$(2), T$OFF, T$LEN
C
      INCLUDE STRING.INC
C
      EQUIVALENCE (S$, IS$(1)), (IS$(1), S$OFF), (IS$(2), S$LEN)
      EQUIVALENCE (T$, IT$(1)), (IT$(1), T$OFF), (IT$(2), T$LEN)
C
      S$ = DST$
      T$ = SRC$
      S$LEN = 0
      DST$ = S$
      IF (T$LEN .LE. 0) RETURN
      DO 1 I = 1, T$LEN
          J = S$OFF + I - 1
          K = T$OFF + I - 1
          STRDAT(J) = STRDAT(K)
    1 CONTINUE
      S$LEN = T$LEN
      DST$ = S$
      RETURN
      END

ext: for


text:
**==dcintm.spg  processed by SPAG 5.00N  at 11:12 on 23 Mar 1999
      SUBROUTINE DCINTM(Maxitm,Num,Nitem)
      IMPLICIT NONE
C
C ======================================================================
C
C  PURPOSE:
C       Decode several INTEGER number(s).
C
C  METHOD:
C       Loop and call DCINT to decode max MAXITM, INTEGER number(s)
C
C  ERROR HANDLING:
C       See DCINT
C
C  INPUT:
C       MAXITM - Max no of numbers allowed
C
C  OUTPUT:
C       NUM    - Array of decoded INTEGER number(s)
C       NITEM  - No of numbers decoded
C
C  INTERNAL VARIABLES:
C       IEND   - See MOVEIP
C
C  CALL TO:
C       MOVEIP, DCINT
C
C  CALL FROM:
C       General purpose routine.
C
C  LIBRARY:
C       FFDLIB
C
C  MACHINE DEPENDENT PART:
C       INCLUDE statement
C
C  PROGRAMMED BY:
C       Per Ivar Loekstad / ETOE / Aker Engineering a.s.
C
C  DATE/VERSION:
C       11.02.94/1.0
C
C ======================================================================
C
      INTEGER iend , Nitem , Num(*) , Maxitm
      INTEGER IFERR
C
      INCLUDE 'ffd.inc'
C
C ----------------------------------------------------------------------
C
      Nitem = 0
C
 100  CALL MOVEIP(iend)
C
      IF ( iend.EQ.0 ) THEN
         Nitem = Nitem + 1
C
         IF ( Nitem.GT.Maxitm ) THEN
            WRITE (LPU,99001) Maxitm
            CALL PRIERR()
            IDCerr = -1
            GOTO 200
         ENDIF
C
         CALL DCINT(Num(Nitem))
C
         IF ( IFERR().LT.0 ) THEN
            WRITE (LPU,99002)
            GOTO 200
         ENDIF
C
         GOTO 100
C
      ENDIF
C
C ----------------------------------------------------------------------
 200  RETURN
C ----------------------------------------------------------------------
C
99001 FORMAT (/,' *** FFDLIB ERROR - Max no of INTEGER numbers',
     &        ' exceeded (=',I6,') - (MODULE: DCINTM)',/)
99002 FORMAT (/,' *** FFDLIB ERROR - Decoding INTEGER number',
     &        ' - (MODULE: DCINTM)',/)
C
      END


text:
Subroutine distce(i1, i2, deltar, ds, dt, ec, srt, ic, px1cm, py1cm, pz1cm)
  Parameter (maxstr=150001)
  Common /aa/r(3, maxstr)
  Common /bb/p(3, maxstr)
  Common /cc/e(maxstr)
  Common /bg/betax, betay, betaz, gamma
  Common /ee/id(maxstr), lb(maxstr)
  Common /leadng/lb1, px1, py1, pz1, em1, e1, xfnl, yfnl, zfnl, tfnl, px1n, py1n, pz1n, dp1n
  Common /dpi/em2, lb2
  Save
  ic = 0
  x1 = r(1, i1)
  y1 = r(2, i1)
  z1 = r(3, i1)
  px1 = p(1, i1)
  py1 = p(2, i1)
  pz1 = p(3, i1)
  x2 = r(1, i2)
  y2 = r(2, i2)
  z2 = r(3, i2)
  px2 = p(1, i2)
  py2 = p(2, i2)
  pz2 = p(3, i2)
  em1 = e(i1)
  em2 = e(i2)
  e1 = sqrt(em1**2+px1**2+py1**2+pz1**2)
  rsqare = (x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2
  If (rsqare>deltar**2) Goto 400
  e2 = sqrt(em2**2+px2**2+py2**2+pz2**2)
  s = srt*srt
  If (s<ec) Goto 400
  p1beta = px1*betax + py1*betay + pz1*betaz
  transf = gamma*(gamma*p1beta/(gamma+1)-e1)
  prcm = sqrt(px1cm**2+py1cm**2+pz1cm**2)
  If (prcm<=0.00001) Goto 400
  drbeta = betax*(x1-x2) + betay*(y1-y2) + betaz*(z1-z2)
  transf = gamma*gamma*drbeta/(gamma+1)
  dxcm = betax*transf + x1 - x2
  dycm = betay*transf + y1 - y2
  dzcm = betaz*transf + z1 - z2
  drcm = sqrt(dxcm**2+dycm**2+dzcm**2)
  dzz = (px1cm*dxcm+py1cm*dycm+pz1cm*dzcm)/prcm
  If ((drcm**2-dzz**2)<=0.) Then
     bbb = 0.
  Else
     bbb = sqrt(drcm**2-dzz**2)
  End If
  If (bbb>ds) Goto 400
  relvel = prcm*(1.0/e1+1.0/e2)
  ddd = relvel*dt*0.5
  If (abs(ddd)<abs(dzz)) Goto 400
  ic = 1
  Goto 500
400 ic = -1
500 Continue
  Return
End Subroutine distce

max_stars_repo_name: xiaohaijin/AMPT

max_issues_repo_name: xiaohaijin/AMPT

max_forks_repo_name: xiaohaijin/AMPT


! ##################################################################################################################################
! Begin MIT license text.
! _______________________________________________________________________________________________________

! Copyright 2019 Dr William R Case, Jr (dbcase29@gmail.com)

! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
! associated documentation files (the "Software"), to deal in the Software without restriction, including
! without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
! the following conditions:

! The above copyright notice and this permission notice shall be included in all copies or substantial
! portions of the Software and documentation.

! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
! THE SOFTWARE.
! _______________________________________________________________________________________________________

! End MIT license text.

      MODULE RIGID_BODY_DISP_MATS

! Rigid body displacement matrices

      USE PENTIUM_II_KIND, ONLY :  BYTE, LONG, DOUBLE

      IMPLICIT NONE

      SAVE

      REAL(DOUBLE), ALLOCATABLE       :: RBGLOBAL_GSET(:,:)! NDOFG x 6 matrix of displacements for the G-set
      REAL(DOUBLE), ALLOCATABLE       :: RBGLOBAL_NSET(:,:)! NDOFN x 6 matrix of displacements for the N-set
      REAL(DOUBLE), ALLOCATABLE       :: RBGLOBAL_FSET(:,:)! NDOFF x 6 matrix of displacements for the F-set
      REAL(DOUBLE), ALLOCATABLE       :: RBGLOBAL_ASET(:,:)! NDOFA x 6 matrix of displacements for the A-set
      REAL(DOUBLE), ALLOCATABLE       :: RBGLOBAL_LSET(:,:)! NDOFL x 6 matrix of displacements for the L-set

      REAL(DOUBLE), ALLOCATABLE       :: TR6_CG(:,:)       ! NDOFR x 6 rigid body displ matrix for R-set rel to model CG
      REAL(DOUBLE), ALLOCATABLE       :: TR6_MEFM(:,:)     ! NDOFR x 6 rigid body displ matrix for R-set rel to MEFMGRID
      REAL(DOUBLE), ALLOCATABLE       :: TR6_0(:,:)        ! NDOFR x 6 rigid body displ matrix for R-set rel to model basic coords

      END MODULE RIGID_BODY_DISP_MATS


text:
subroutine drotim(nst       ,j         ,nmmaxj    ,kmax      ,ndro      , &
                & icx       ,icy       ,windxt    ,windyt    ,windft    , &
                & kcu       ,kcv       ,kcs       ,kfu       ,kfv       , &
                & mndro     ,itdro     ,u1        ,v1        ,xcor      , &
                & ycor      ,guu       ,gvv       ,guv       ,gvu       , &
                & dxydro    ,xydro     ,hu        ,hv        ,s1        , &
                & dpu       ,dpv       ,thick     ,drodep    , &
                & kfumin    ,kfumax    ,kfvmin    ,kfvmax    , &
                & dzu1      ,dzv1      ,zk        ,gdp       )
!----- GPL ---------------------------------------------------------------------
!
!  Copyright (C)  Stichting Deltares, 2011-2016.
!
!  This program is free software: you can redistribute it and/or modify
!  it under the terms of the GNU General Public License as published by
!  the Free Software Foundation version 3.
!
!  This program is distributed in the hope that it will be useful,
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  GNU General Public License for more details.
!
!  You should have received a copy of the GNU General Public License
!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
!
!  contact: delft3d.support@deltares.nl
!  Stichting Deltares
!  P.O. Box 177
!  2600 MH Delft, The Netherlands
!
!  All indications and logos of, and references to, "Delft3D" and "Deltares"
!  are registered trademarks of Stichting Deltares, and remain the property of
!  Stichting Deltares. All rights reserved.
!
!-------------------------------------------------------------------------------
!  $Id: drotim.f90 5717 2016-01-12 11:35:24Z mourits $
!  $HeadURL: https://svn.oss.deltares.nl/repos/delft3d/tags/6686/src/engines_gpl/flow2d3d/packages/kernel/src/compute/drotim.f90 $
!!--description-----------------------------------------------------------------
!
!    Function: - calculates drogues if release time < NST
!                if stop time > NST and drogue on active point
! Method used:
!
!!--pseudo code and references--------------------------------------------------
! NONE
!!--declarations----------------------------------------------------------------
    use precision
    !
    use globaldata
    !
    implicit none
    !
    type(globdat),target :: gdp
    !
    ! The following list of pointer parameters is used to point inside the gdp structure
    !
    real(fp)     , pointer :: hdt
!
! Global variables
!
    integer                                               :: icx    !!  Increment in the X-dir., if ICX= NMAX
                                                                    !!  then computation proceeds in the X-
                                                                    !!  dir. If icx=1 then computation pro-
                                                                    !!  ceeds in the Y-dir.
    integer                                               :: icy    !!  Increment in the Y-dir. (see ICX)
    integer                                               :: j      !!  Begin pointer for arrays which have
                                                                    !!  been transformed into 1D arrays.
                                                                    !!  Due to the shift in the 2nd (M-)
                                                                    !!  index, J = -2*NMAX + 1
    integer                                               :: kmax   !  Description and declaration in esm_alloc_int.f90
    integer                                 , intent(in)  :: ndro   !  Description and declaration in dimens.igs
    integer                                               :: nmmaxj !  Description and declaration in dimens.igs
    integer                                 , intent(in)  :: nst    !!  Time step number
    integer, dimension(2, ndro)             , intent(in)  :: itdro  !  Description and declaration in esm_alloc_int.f90
    integer, dimension(2, ndro)                           :: mndro  !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub)             :: kcs    !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub)             :: kcu    !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub)             :: kcv    !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub)             :: kfu    !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub)             :: kfv    !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub), intent(in) :: kfumax !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub), intent(in) :: kfumin !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub), intent(in) :: kfvmax !  Description and declaration in esm_alloc_int.f90
    integer, dimension(gdp%d%nmlb:gdp%d%nmub), intent(in) :: kfvmin !  Description and declaration in esm_alloc_int.f90
    real(fp)                                              :: windft !  Description and declaration in trisol.igs
    real(fp)                                              :: windxt !  Description and declaration in trisol.igs
    real(fp)                                              :: windyt !  Description and declaration in trisol.igs
    real(fp), dimension(2, ndro)                          :: dxydro !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(2, ndro)                          :: xydro  !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: guu    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: guv    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: gvu    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: gvv    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: hu     !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: hv     !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: xcor   !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: ycor   !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub, kmax)      :: u1     !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub, kmax)      :: v1     !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: s1     !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: dpu    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub)            :: dpv    !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub, kmax), intent(in) :: dzu1   !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(gdp%d%nmlb:gdp%d%nmub, kmax), intent(in) :: dzv1   !  Description and declaration in esm_alloc_real.f90
    real(fp), dimension(kmax)                             :: thick  ! Description and declaration in esm_alloc_real.f90
    real(fp), dimension(0:kmax)             , intent(in)  :: zk
    real(fp), dimension(ndro)                             :: drodep
!
! Local variables
!
    integer  :: ddb
    integer  :: i     ! Hulp var.
    integer  :: icxy  ! Max (ICX  ,ICY )
    integer  :: mf    ! M-coordinate at start of calculation and after calculation (-><- Cline)
    integer  :: nf    ! N coordinate at start of calculation and after calculation (-><- Cline)
    integer  :: nm    ! N,M array index
    real(fp) :: dxf   ! Delta X at start of calculation and after calculation (-><- Cline)
    real(fp) :: dyf   ! Delta Y at start of calculation and after calculation (-><- Cline)
    real(fp) :: xf    ! X coordinate at start of calculation and after calculation (-><- Cline)
    real(fp) :: yf    ! Y coordinet at start of calculation and after calculation (-><- Cline)
!
!! executable statements -------------------------------------------------------
!
    hdt     => gdp%gdnumeco%hdt
    !
    ddb  = gdp%d%ddbound
    icxy = max(icx, icy)
    !
    ! calculate starting point of streamlines
    !
    do i = 1, ndro
       nm = (mndro(2, i) + ddb)*icy + (mndro(1, i) + ddb)*icx - icxy
       !
       ! drogue only calculated if a) drogue released, and still
       !                              to be calculated
       !                           b) drogue on active point
       ! not for itdro(2,i) = nst (info that is calculated in step
       ! nst will be written to file as coordinates for nst+1)
       !
       if (itdro(1, i)<=nst .and. itdro(2, i)>nst .and. kcs(nm)==1) then
          mf  = mndro(1, i)
          nf  = mndro(2, i)
          dxf = dxydro(1, i)
          dyf = dxydro(2, i)
          xf  = xydro(1, i)
          yf  = xydro(2, i)
          !
          ! calculate composed line
          !
          call cline(hdt       ,j         ,nmmaxj    ,kmax      ,icx       , &
                   & icy       ,icxy      ,mf        ,nf        ,dxf       , &
                   & dyf       ,xf        ,yf        ,u1        ,v1        , &
                   & xcor      ,ycor      ,guu       ,gvv       ,guv       , &
                   & gvu       ,kcu       ,kcv       ,kcs       ,kfu       , &
                   & kfv       ,windxt    ,windyt    ,windft    , &
                   & s1        ,dpu       ,dpv       ,thick     ,drodep(i) , &
                   & kfumin    ,kfumax    ,kfvmin    ,kfvmax    , &
                   & dzu1      ,dzv1      ,zk        ,gdp       )
          !
          ! rewrite n,m and dx,dy and write x,y point of drogue
          ! in arrays
          !
          mndro (1, i) = mf
          mndro (2, i) = nf
          dxydro(1, i) = dxf
          dxydro(2, i) = dyf
          xydro (1, i) = xf
          xydro (2, i) = yf
       endif
    enddo
end subroutine drotim

max_stars_repo_name: liujiamingustc/phd

max_issues_repo_name: liujiamingustc/phd

max_forks_repo_name: liujiamingustc/phd


text:
decimal \ important

#define <A>  1
#define <B>  2
#define <C>  3
#define <D>  4
#define <E>  5
#define <F>  6
#define <G>  7
#define <H>  8
#define <I>  9
#define <J>  10
#define <K>  11
#define <L>  12
#define <M>  13
#define <N>  14
#define <O>  15
#define <P>  16
#define <Q>  17
#define <R>  18
#define <S>  19
#define <T>  20
#define <U>  21
#define <V>  22
#define <W>  23
#define <X>  24
#define <Y>  25
#define <Z>  26

#define <0>  27
#define <1>  28
#define <2>  29
#define <3>  30
#define <4>  31
#define <5>  32
#define <6>  33
#define <7>  34
#define <8>  35
#define <9>  36

#define <PAD0>  37
#define <PAD1>  38
#define <PAD2>  39
#define <PAD3>  40
#define <PAD4>  41
#define <PAD5>  42
#define <PAD6>  43
#define <PAD7>  44
#define <PAD8>  45
#define <PAD9>  46

#define <F1>  47
#define <F2>  48
#define <F3>  49
#define <F4>  50
#define <F5>  51
#define <F6>  52
#define <F7>  53
#define <F8>  54
#define <F9>  55
#define <F10>  56
#define <F11>  57
#define <F12>  58

#define <ESCAPE>  59
<escape> constant <esc>
#define <TILDE>  60
<tilde> constant <`>
<tilde> constant <~>
#define <MINUS>  61
<minus> constant <->
#define <EQUALS>  62
<equals> constant <=>
<equals> constant <+>
#define <BACKSPACE>  63
<backspace> constant <bksp>
#define <TAB>  64
#define <OPENBRACE>  65
<openbrace> constant <[>
#define <CLOSEBRACE>  66
<closebrace> constant <]>
#define <ENTER>  67
#define <SEMICOLON>  68
<semicolon> constant <;>
#define <QUOTE>  69
<quote> constant <'>
#define <BACKSLASH>  70
<backslash> constant <\>
#define <BACKSLASH2>  71 /* DirectInput calls this DIK_OEM_102: "< > | on UK/Germany keyboards" */
#define <COMMA>  72
<comma> constant <,>
#define <FULLSTOP>  73
<fullstop> constant <.>
#define <SLASH>  74
<slash> constant </>
#define <SPACE>  75

#define <INSERT>  76
<insert> constant <ins>
#define <DELETE>  77
<delete> constant <del>
#define <HOME>  78
#define <END>  79
#define <PGUP>  80
#define <PGDN>  81
#define <LEFT>  82
#define <RIGHT>  83
#define <UP>  84
#define <DOWN>  85

#define <PAD_SLASH>  86
#define <PAD_ASTERISK>  87
#define <PAD_MINUS>  88
#define <PAD_PLUS>  89
#define <PAD_DELETE>  90
#define <PAD_ENTER>  91

#define <PRINTSCREEN>  92
#define <PAUSE>  93

#define <ABNT_C1>  94
#define <YEN>  95
#define <KANA>  96
#define <CONVERT>  97
#define <NOCONVERT>  98
#define <AT>  99
#define <CIRCUMFLEX>  100
#define <COLON2>  101
#define <KANJI>  102

#define <PAD_EQUALS>  103  /* MacOS X */
#define <BACKQUOTE>  104  /* MacOS X */
#define <SEMICOLON2>  105  /* MacOS X -- TODO: ask lillo what this should be */
#define <COMMAND>  106  /* MacOS X */
#define <UNKNOWN>  107

\ /* All codes up to before #define <MODIFIERS can be freely
\  * assignedas additional unknown keys like cvarious multimedia
\  * and application keys keyboards may have.
\  */

#define <lshift>  215
#define <rshift>  216
#define <LCTRL>  217
#define <RCTRL>  218
#define <ALT>  219
#define <ALTGR>  220
#define <LWIN>  221
#define <RWIN>  222
#define <MENU>  223
#define <SCROLLLOCK>  224
#define <NUMLOCK>  225
#define <CAPSLOCK>  226

#define ALLEGRO_KEYMOD_SHIFT       $00001
#define ALLEGRO_KEYMOD_CTRL        $00002
#define ALLEGRO_KEYMOD_ALT         $00004
#define ALLEGRO_KEYMOD_LWIN        $00008
#define ALLEGRO_KEYMOD_RWIN        $00010
#define ALLEGRO_KEYMOD_MENU        $00020
#define ALLEGRO_KEYMOD_ALTGR       $00040
#define ALLEGRO_KEYMOD_COMMAND     $00080
#define ALLEGRO_KEYMOD_SCROLLLOCK  $00100
#define ALLEGRO_KEYMOD_NUMLOCK     $00200
#define ALLEGRO_KEYMOD_CAPSLOCK    $00400
#define ALLEGRO_KEYMOD_INALTSEQ	   $00800
#define ALLEGRO_KEYMOD_ACCENT1     $01000
#define ALLEGRO_KEYMOD_ACCENT2     $02000
#define ALLEGRO_KEYMOD_ACCENT3     $04000
#define ALLEGRO_KEYMOD_ACCENT4     $08000

max_stars_repo_name: RogerLevy/RamenEngine

max_issues_repo_name: Alim-Oezdemir/RamenEngine

max_forks_repo_name: Alim-Oezdemir/RamenEngine