C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C***************************
C**      LFN_OD_TABLE     **
C***************************
C
C
      SUBROUTINE LFN_OD_TABLE
C
      INCLUDE 'implicit_none.finc'
C
C Purpose:       Generate look-up table for optical density (single byte
C                film data only)
C
C **** Service Routine Only ****
C
C Author: Q. Hao
C
C====== Parameter statements
C
      INCLUDE 'saint_limits.finc' 
C
C====== GLOBALS:
C
      INCLUDE 'lfn_saint.finc'
C
C====== LOCALS:
C
      REAL BASEOD
      REAL NONL
      REAL CFAC
      REAL BASE
      REAL TRUOD
      INTEGER I
      INTEGER ND 
      INTEGER IFLAG
      INTEGER N1OD
C
C     REAL BASEOD	!Optical density of the film base (OD unit)
C     REAL NONL		!Non-linearity parameter for film 
C     REAL CFAC		!Temp. parameter
C     REAL BASE		!Optical density of the film base (pixel unit)
C     REAL TRUOD	!True pixel value
C     INTEGER I         !Temp/loop variable
C     INTEGER ND        !Number of decimal places for print
C     INTEGER IFLAG     !Flag = -1 undefined value 
C                             =  0 default value 
C                             =  1 value set explicitly
C                             =  2 value set globally 
C     INTEGER N1OD	!Pixel value for 1 OD
C
C------------------------------------------------------------------------------- 
C
      CALL LDM_GET_BASE (BASEOD, IFLAG, ND)
      CALL LDM_GET_NONL (NONL, IFLAG, ND)
      CALL LDM_GET_N1OD (N1OD, IFLAG)
      CFAC=NONL/N1OD
      BASE=BASEOD*N1OD
      DO 50 I=0,255 
         TRUOD=I-BASE 
         TABLE(I)=TRUOD*(1.0+CFAC*TRUOD)
         TABLE(I)=MAX(0.0,TABLE(I))
50    CONTINUE
      RETURN
      END
