[SciPy-dev] "intent(aux)" does not honor "depend(..)"

Berthold "Höllmann" berthold.hoellmann@gl-group....
Tue Nov 11 07:52:31 CST 2008


Tiziano Zito <opossumnano@gmail.com> writes:

> hi berthold, the zheevr routine is wrapped already in the symeig
> package (http://mdp-toolkit.sourceforge.net/symeig.html). this
> package is being integrated in scipy, but in the meanwhile it is
> available as a standalone package. 
>
> ciao,
> tiziano
>
>
> On Fri 07 Nov, 16:08, Berthold Höllmann wrote:
>> 
>> I try to wrap the lapack zheevr routine for a project of ours. Doing
>> this I try to determine the optimal workspace in the wrapper
>> routine. The generated code does work when put into correct order, but
>> inspite ow writing::
>> 
>>      integer intent(aux), depend(n) :: nb1 = __ilaenv(1, "ZHETRD", uplo, n, -1, -1, -1)
>>      integer intent(aux), depend(n) :: nb2 = __ilaenv(1, "ZUNMTR", uplo, n, -1, -1, -1)
>>      integer intent(aux), depend(nb1, nb2) :: nb = MAX(nb1, nb2)
>> 
>> the generated code for calculating nb1, nb2, and nb is inserted directly
>> after `PyArg_ParseTupleAndKeywords` is called, instead at a point after
>> `uplo` and `n` are set. I guess this is a bug?

I wanted to check all the arguments for valid values and use the optimal
workspace size. I found a way to achieve this by the following signature
(comments left out):

   subroutine zheevr(jobz, range, uplo, n, a, lda, vl, vu, il, iu, &
        & abstol, m, w, z, ldz, isuppz, work, lwork, rwork, lrwork, &
        & iwork, liwork, info)
     character intent(in), check(*jobz=='N'||*jobz=='V') :: jobz
     character intent(in), check(*range=='A'||*range=='V'||*range=='I') :: range
     character intent(in), check(*uplo=='U'||*uplo=='L') :: uplo
     integer intent(hide), check(shape(a,1)==n), depend(a)  :: n=shape(a,1)
     complex*16 intent(in,out), dimension(lda,n) :: a
     integer  intent(hide), check(shape(a,0)==lda), depend(a) :: lda=shape(a,0)
     double precision intent(in), optional, depend(vu), &
          & check((not *range=='V')||vl < vu) :: vl=0.
     double precision intent(in), optional :: vu=0.
     integer intent(in), optional, depend(iu), &
          & check((not *range=='I')|| &
          & (((n>0&&(1<=il<=iu<=n)))||(n==0&&(il==1&&iu==0)))) :: il=-1
     integer intent(in), optional :: iu=-1
     double precision intent(in), optional :: abstol=0.
     integer intent(out) :: m
     double precision intent(out), dimension(n) :: w
     complex*16 intent(out), dimension(ldz,n) :: z
     integer intent(hide) :: ldz=MAX(1,n)
     integer intent(out), dimension(2*MAX(1,n)) :: isuppz
     complex*16 intent(hide, cache), dimension(lwork), depend(lwork) :: work
     integer intent(hide), depend(n, uplo) :: lwork=zheevr_lwork(n, &uplo)
     double precision intent(hide, cache), dimension(lrwork), depend(lrwork) :: rwork
     integer intent(hide), depend(n, uplo) :: lrwork=zheevr_lrwork(n, &uplo)
     integer intent(hide, cache), dimension(liwork), depend(liwork) :: iwork
     integer intent(hide), depend(n) :: liwork=MAX(1, 10*n)
     integer intent(out) :: info
   end subroutine zheevr

The functions `zheevr_lwork` and `zheevr_lrwork` are defined in the
`usercode` block as::

  extern void F_WRAPPEDFUNC(ilaenv,ILAENV)(int*,int*,string,string,int*,int*,int*,int*,size_t,size_t);
  
  static int zheevr_nb(int n, char uplo) {
    int nb1, nb2;
    int one=1;
    int none=-1;
    size_t name_len = 6;
    size_t opts_len = 1;
    (*F_WRAPPEDFUNC(ilaenv,ILAENV))(&nb1, &one, "ZHETRD", &uplo, &n, &none, &none, &none, name_len, opts_len);
    (*F_WRAPPEDFUNC(ilaenv,ILAENV))(&nb2, &one, "ZUNMTR", &uplo, &n, &none, &none, &none, name_len, opts_len);
    return MAX(nb1, nb2);
  }
  static int zheevr_lwork(int n, char uplo) {
    int nb = zheevr_nb(n, uplo);
    return MAX((nb+1)*n, MAX(1, 2*n));
  }
  static int zheevr_lrwork(int n, char uplo) {
    int nb = zheevr_nb(n, uplo);
    return MAX((nb+1)*n, MAX(1, 24*n));
  }

Any comments are welcome.

Kind regards

Berthold Höllmann
-- 
Germanischer Lloyd AG
CAE Development
Vorsetzen 35
20459 Hamburg
Phone: +49(0)40 36149-7374
Fax: +49(0)40 36149-7320
e-mail: berthold.hoellmann@gl-group.com
Internet: http://www.gl-group.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20081111/f35ce567/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: disclaimer.txt
Type: application/octet-stream
Size: 2196 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20081111/f35ce567/attachment.obj 


More information about the Scipy-dev mailing list