This is documented in the second paragraph of the LWORK documentation:
LWORK is INTEGER
The dimension of the array WORK. LWORK > = 1.
If IJOB = 1 or 2 and TRANS = 'N', LWORK >= max(1,2*M*N).
If LWORK = -1, then a workspace query is assumed; the routine
only calculates the optimal size of the WORK array, returns
this value as the first entry of the WORK array, and no error
message related to LWORK is issued by XERBLA.
The lquery is being used as a flag for when a work length query was
being made.
Dan