The error statement is pretty clear. These lines:
Real, allocatable :: x(:),u(:),a(:),b(:),c(:),d(:)
Real:: m,dx,dt,Tmax
Integer:: j,NI,JI
have to appear before this line:
call thomas(a,b,c,d,JI)
I'm not sure why you're calling the Thomas solver before you even assemble a, b, c, and d...