Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
21 Views

Problem in calling MKL function of dgesvd

hi,

 I followed the Intel manual to call the the MKL routine of "dgesvd" in my code as

call dgesvd( 'S', 'N', m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, info)

If I set the compiler option with /iface:cref, the code works well. However, if the compiler option is set as /iface:cref /iface:mixed_str_len_arg, the code will report error during calling dgesvd as "Access violation reading location 0x0000000000000001". Because I have to keep the latter compiler option, how can I resolve the problem?

Thanks in advance for any suggestion!

Jing

0 Kudos
10 Replies
Highlighted
21 Views

The problem here is that you need a declaration of the routine that includes the NOMIXED_STR_LEN_ARG attribute (or DEFAULT). MKL doesn't provide one. I'm going to move this to the MKL forum as the folk there may have a ready solution for you. If not, I can make a suggestion.

I'm a bit puzzled that you're using mixed_str_len_arg with cref - that's an unusual combination. What requires it?

Retired 12/31/2016
0 Kudos
Highlighted
Black Belt
21 Views

Interfaces to Lapack routines are provided in file mkl_lapack.fi in the mkl/includes directory. You need to find the portion for dgesvd, modify those lines by specifying [fortran]cDEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: DGESVD[/fortran] and include the modified interface block in your routine that calls dgesvd. If there are calls to other such MKL/LAPACK/BLAS routines, you would need to provide similarly modified interface blocks for them, as well.

I hope that you realize that all these non-standard fixes to get your code to work will negatively impact the portability of your code.

0 Kudos
Highlighted
Employee
21 Views

Jing,

MKL library function used the nomixed_str_len_arg convention for the hidden-length character, if you call the library by the mixed_str_len_arg(with the /iface:mixed_str_len_arg swith), it may create the error. I think mecej4 provide a good suggestion, which will that function called by the nomixed_str_len_arg convention.

Thanks,
Chao

0 Kudos
Highlighted
Beginner
21 Views

Hi, Steve:

Thanks for your help. Actually, The compiler option is forced by my customer and I am not very clear why they required this.

Mecej4 and Chao:

Many thanks for the solution. However, such approach seems not proper for me because my code will be deployed to many customers and I cann't require them to modify the mkl_lapack.fi on their computer.  Is that possible to solve this issue in other way?

Thanks again,

Jing

0 Kudos
Highlighted
Black Belt
21 Views

You do not need to modify mkl_lapack.fi. Copy the five or six lines pertaining to dgesvd, add the attribute declaration, and put these lines into your code. We are talking about less than ten lines, not the ~15000 lines in the include file.

It is possible that if you explain the issues to your customers they will discover that they really do not want mixed_str_len_arg with cref, either! As Steve stated, this is an unusual combination and, if they cannot give the reasons for choosing it, perhaps it is not needed at all.

0 Kudos
Highlighted
Beginner
21 Views

Hi, Mecej4:

Thanks a lot for your response. I followed your suggestion and add interface of dgesvd in my code as

      INTERFACE
         SUBROUTINE DGESVD(JOBU,JOBVT,M,N,A,LDA,S,U,LDU,VT,LDVT,WORK,LWORK,&
                           &INFO)
           !DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: JOBU,JOBVT
           CHARACTER          JOBU,JOBVT           
           INTEGER            INFO,LDA,LDU,LDVT,LWORK,M,N
           DOUBLE PRECISION   A(LDA,*),S(*),U(LDU,*),VT(LDVT,*),WORK(*)
         END
      END INTERFACE    

But the compiler report error during compiling as:

error #7796: Only a function or subroutine subprogram may have the !DEC$ ATTRIBUTES directive [NO]MIXED_STR_LEN_ARG specifier.   [JOBU]    

error #7796: Only a function or subroutine subprogram may have the !DEC$ ATTRIBUTES directive [NO]MIXED_STR_LEN_ARG specifier.   [JOBVT]    

Do you have any idea about that?

0 Kudos
Highlighted
Black Belt
21 Views

Sorry, replace [fortran] !DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: JOBU,JOBVT[/fortran] by [fortran] !DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: DGESVD[/fortran] It would also be helpful if you show the source of a full example along with error messages, since the declarations often show why the error messages were generated.

0 Kudos
Highlighted
Beginner
21 Views

The subroutine is likeing the following

      SUBROUTINE FULLSOLUTIONPATH(FLAG,NT,SNAPSHOT,SPNUM)

      IMPLICIT NONE

      INTERFACE       
         SUBROUTINE DGESVD(JOBU,JOBVT,M,N,A,LDA,S,U,LDU,VT,LDVT,WORK,LWORK,&
                           &INFO)
           !DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: JOBU,JOBVT   
           CHARACTER          JOBU,JOBVT           
           INTEGER            INFO,LDA,LDU,LDVT,LWORK,M,N
           DOUBLE PRECISION   A(LDA,*),S(*),U(LDU,*),VT(LDVT,*),WORK(*)
         END
      END INTERFACE        

      ......
      LWORK = -1
      ALLOCATE(WORK(1))
      CALL DGESVD('S','N',MT,NT,SNAPSHOT_tmp,MT,SINGULARVALUE, &
                  & Utmp,MT,VT,ONE,WORK,LWORK,INFO)
      LWORK = INT(WORK(1))
      DEALLOCATE(WORK)

      ALLOCATE(WORK(LWORK))    
      CALL DGESVD('S','N',MT,NT,SNAPSHOT_tmp,MT,SINGULARVALUE, &
                  & Utmp,MT,VT,ONE,WORK,LWORK,INFO)
      ......

      END SUBROUTINE  FULLSOLUTIONPATH

Where should I  place the

!DEC$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: DGESVD


Thanks in advance!

0 Kudos
Highlighted
Black Belt
21 Views

In the line containing "!DEC$..." in your listing, replace "JOBU,JOBVT" by "DGESVD".

0 Kudos
Highlighted
Beginner
21 Views

Hi, Mecej4:

It works now. Thank you very much!

Jing

0 Kudos