C++*******************************************************************
C
C TF.F
C
C **********************************************************************
C=* FROM: SPIDER - MODULAR IMAGE PROCESSING SYSTEM.   AUTHOR: J.FRANK  *
C=* Copyright (C) 1985-2005  Health Research Inc.                      *
C=*                                                                    *
C=* HEALTH RESEARCH INCORPORATED (HRI),                                *   
C=* ONE UNIVERSITY PLACE, RENSSELAER, NY 12144-3455.                   *
C=*                                                                    *
C=* Email:  spider@wadsworth.org                                       *
C=*                                                                    *
C=* This program is free software; you can redistribute it and/or      *
C=* modify it under the terms of the GNU General Public License as     *
C=* published by the Free Software Foundation; either version 2 of the *
C=* License, or (at your option) any later version.                    *
C=*                                                                    *
C=* This program is distributed in the hope that it will be useful,    *
C=* but WITHOUT ANY WARRANTY; without even the implied warranty of     *
C=* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
C=* General Public License for more details.                           *
C=*                                                                    *
C=* You should have received a copy of the GNU General Public License  *
C=* along with this program; if not, write to the                      *
C=* Free Software Foundation, Inc.,                                    *
C=* 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.      *
C=*                                                                    *
C **********************************************************************
C
C  TF(B,CS,DZ,LAMBDA,KM,NSAM,Q,DS,IE)
C
C  CHANGED 9/5/94 TO INCLUDE INTELLIGIBLE GAUSSIAN PARAMETER JF
C
C--*******************************************************************

	SUBROUTINE TF(B,CS,DZ,LAMBDA,KM,NSAM,Q,DS,IE,WGH,ENV)

C       I DO NOT KNOW IF SAVE IS NEEDED FEB 99 al
        SAVE

	REAL B(1),LAMBDA,KM,KAPPA,KM1

	DATA PI/3.14159/

	CS1   = CS*1.E7
	F1    = 1./SQRT(CS1*LAMBDA)
	F2    = SQRT(SQRT(CS1*LAMBDA**3))
	KM1   = KM*F2
	DK    = KM1/FLOAT(NSAM-1)
	Q1    = (Q*F2)**2
        ENV1  = ENV/F2**2
	F     = -PI**2
	DS1   = DS*F1
	KAPPA = (DS1**2)*F/(4.0)
  	DZ1   = DZ*F1

	DO K=1,NSAM
	   AK   = FLOAT(K-1)*DK
	   P    = AK**3-DZ1*AK
	   CH   = EXP(AK**4*KAPPA)
           B(K) = (EXP(F*Q1*P**2)*CH)*2*EXP(-ENV1*AK**2)
           IF (IE .NE. 1) THEN
              QQT  = 2.*PI*(.25*AK**4-.5*DZ1*AK**2)
              B(K) = B(K)*((1.0-WGH)*SIN(QQT)-WGH*COS(QQT))
           ENDIF
        END DO

        RETURN
	END

