if else endif using csh

I am trying to use csh to do an if statement as below

  if ( $tmaxf2 > $tmaxf1 ) then
    set tmax = $tmaxf2
  else
    set tmax = $tmaxf1
  endif

Does not work and I'm getting

if: Badly formed number.