anchor.diff:         ! Out-of-Bound SZA, VZA (but not missing!)
          ! ----------------------------------------
          WHERE ( &
  -            ( sza(spix:epix,it) < MINVAL(vl_sza) ) .OR. &
  -            ( sza(spix:epix,it) > MAXVAL(vl_sza) ) .OR. &
  -            ( vza(spix:epix,it) < MINVAL(vl_vza) ) .OR. &
  -            ( vza(spix:epix,it) > MAXVAL(vl_vza) )      )
  +            ( sza(spix:epix,it) < MINVAL(lut_sza) ) .OR. &
  +            ( sza(spix:epix,it) > MAXVAL(lut_sza) ) .OR. &
  +            ( vza(spix:epix,it) < MINVAL(lut_vza) ) .OR. &
  +            ( vza(spix:epix,it) > MAXVAL(lut_vza) )      )
             amfdiag(spix:epix,it) = omi_oobview_amf
          END WHERE
   
  
positive.code:           local_sza    = cos(d2r*REAL(sza(ixtrack,itime), KIND = r8))  ! JED fix
            local_vza    = cos(d2r*REAL(vza(ixtrack,itime), KIND = r8))  ! JED fix
            local_thg    = REAL(terrain_height(ixtrack,itime), KIND = r8)
            local_chg(:) = cli_heights(ixtrack,itime,:)
  
            ! ----------------------------------------------
            ! Convert pixel terrain height to pressure using
  
negative.code:        ! --------------------------
         DO ixtrack = 1, nx
  
            
            IF (amfdiag(ixtrack,itime) .LT. 0) CYCLE
  
            ! -----------------------------------------
            ! Find out which TOMS profile we should use
            ! in function of latitude and ozone column.
            ! -----------------------------------------        
            IF ( ABS(lat(ixtrack,itime)) .GT. 60.0 ) THEN
               toms_idx = MINLOC(ABS(hxxx-omi_ozone_amount(ixtrack,itime)/du)) + 0
            ELSE IF ( ABS(lat(ixtrack,itime)) .GT. 30.0 .AND. ABS(lat(ixtrack,itime)) .LE. 60.0 ) THEN
               toms_idx = MINLOC(ABS(mxxx-omi_ozone_amount(ixtrack,itime)/du)) + 17
            ELSE IF ( ABS(lat(ixtrack,itime)) .LE. 30.0 ) THEN
               toms_idx = MINLOC(ABS(lxxx-omi_ozone_amount(ixtrack,itime)/du)) + 11
            ENDIF
            
            ! ----------------------------------------------
            ! If this point is reached then scattw should be
            ! different from r8_missval and it needs to be
  