The following workspace query fails with memory access error:
call ZGGES3(JOBVSL='N', JOBVSR='N', SORT='S', ..., LWORK=-1, ..., BWORK=NULL )
According to documentation, it is not correct to pass BWORK=NULL while SORT='S', ... but this is just a workspace query.
The subroutine passes BWORK down in
call ZTGSEN( IJOB=0, ..., SELECT=BWORK, ..., LWORK=-1, ... )
and that routine causes memory error reading SELECT(K) when it sets M to the dimension of the specified pair of deflating subspaces. Since IJOB=0 and this is workspace query, the computed M is not used anyway, so it would be safe to not refer to SELECT(K) when IJOB=0. Maybe, it would also be good to not refer to SELECT on workspace query, and evaluate LWMIN to N*N ( instead of 2*M*(N-M) ) regardless of IJOB? I would adjust the workspace query (computation of LWMIN and LIWMIN) in ZTGSEN so that it not reference SELECT for IJOB=0.
Also, if ZTGSEN uses SELECT=BWORK for workspace query, then ZGGES3 should initialize BWORK before passing it to ZTGSEN for workspace query.
What do you think about this?

