allocate diag after input arguments