c

C file-name               GXPROFIL.HTM             020100
C**** SUBROUTINE GXPROF is called from group 13 of GREX3, by setting
C     the value ascribed to GROUND in the COVAL statement. The
C     subroutine is entered only when the patch name begins with
C     the character 'PROF'.
C
C.... The dummy FI14 is the value of H1, which is set through FIINIT(H1)
C     in group 11 of the SATELLITE.
C
C.... The library cases 190-192 make use of it.
C
C.... The following subroutines are used here:
C     FN2(Y,X,A,B)                    Y = A+B*X
C     FN4(Y,X,A,B,C,D)                Y = A+B*X+C*X**2+D*X**3
C     FN8(Y,X,A,B,C,D)                Y = A*(X+B)**C+D
C     FN23(Y,A)                       Y = AMIN1(Y,A)
C     FN25(Y,A)                       Y = A*Y
C     FN28(Y,X,A)                     Y = A/X
C     FN37(Y,X,A)                     Y = Y*X**A
C
      SUBROUTINE GXPROF(DEN,RHO,FI14)
C
      INCLUDE 'farray'
      INCLUDE 'grdloc'
      INCLUDE 'satgrd'
      COMMON /IGE/IXF,IXL,IYF,IYL,IREG,NZSTEP,IGR,ISC,IRUN,IZSTEP,ITHYD,
     1       ISWEEP,ISTEP,INDVAR,VAL,CO,NDIREC,WALDIS,PATGEO,IGES20(6)
      INTEGER DEN,VAL,CO,WALDIS,PATGEO
      COMMON /NAMFN/NAMFUN,NAMSUB
      CHARACTER*6 NAMFUN,NAMSUB
      LOGICAL GRN
C
      NAMSUB = 'GXPROF'
      IF(ISC.EQ.15) THEN
        IF(INDVAR.EQ.W1) THEN
          CALL FN8(VAL,YG2D,PROFD/PROFB**PROFC,0.,PROFC,0.)
          CALL FN23(VAL,PROFD)
        ELSEIF(INDVAR.EQ.P1) THEN
C.... PROFB is boundary width
C     PROFC is a power-factor
C     PROFD is the free stream velocity
          CALL FN8(VAL,YG2D,PROFD/PROFB**PROFC,0.,PROFC,0.)
          CALL FN23(VAL,PROFD)
          IF(GRN(RHO)) THEN
            CALL FN26(VAL,DEN)
          ELSE
            CALL FN25(VAL,RHO)
          ENDIF
        ELSEIF(INDVAR.EQ.KE) THEN
C.... CMUCD is the turbulence-model constant
          CALL FN2(VAL,YG2D,0.0,1./PROFB)
          CALL FN23(VAL,1.0)
          ACON = 0.5*PROFD*PROFD*PROFA/SQRT(CMUCD)
          CALL FN4(VAL,VAL,ACON,0.,-3.*ACON,2.*ACON)
        ELSEIF(INDVAR.EQ.EP) THEN
C.... CD and AK are the turbulence-model constants
          CALL FN2(VAL,YG2D,0.0,AK)
          CALL FN23(VAL,.09*PROFB)
          CALL FN28(VAL,VAL,CD)
          CALL FN37(VAL,12,1.5)
        ELSEIF(INDVAR.EQ.H1) THEN
C.... TEMP0 is the wall temperature, FI14 is the free stream temperature
          CALL FN8(VAL,YG2D,PROFD/PROFB**PROFC,0.,PROFC,0.)
          CALL FN23(VAL,PROFD)
          CALL FN2(VAL,VAL,TEMP0,(FI14-TEMP0)/PROFD)
        ENDIF
      ENDIF
      END
c