SUBROUTINE FPIPE90(TIN1,IQW,FILIT)
!use consts
use global
implicit none  
    
real(DP) :: filit,iqw,g1,trad,fili,tin1
integer :: iloc,iloci
      SAVE

      FILIT=0.
      IF(IQW.EQ.1) GO TO 20
!.................................. Direct fluid flow
      DO 10 ILOC=1,NLOC
        G1=1.-BETA(ILOC)
        TRAD=TR(ILOC,2)+TGM(ILOC)
        FILI=CWQW*G1*(TIN1-TRAD)
        TIN1=TIN1+G1*(TRAD-TIN1)
        FILIT=FILIT+FILI
        FRR(ILOC,2)=FILI/PLSTL(ILOC)
   10 CONTINUE
      RETURN
   20 CONTINUE
!.................................  Reverse fluid flow
      DO 30 ILOCI=1,NLOC
        ILOC=NLOC1-ILOCI
        G1=1.-BETA(ILOC)
        TRAD=TR(ILOC,2)+TGM(ILOC)
        FILI=CWQW*G1*(TIN1-TRAD)
        TIN1=TIN1+G1*(TRAD-TIN1)
        FILIT=FILIT+FILI
        FRR(ILOC,2)=FILI/PLSTL(ILOC)
   30 CONTINUE   

!write(519,*) g1,trad,fili,tin1,filit

RETURN
END subroutine fpipe90