Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 290321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:59:13+00:00 2026-05-12T05:59:13+00:00

I have a Fortran subroutine which uses BLAS’ subroutines dgemm, dgemv and ddot, which

  • 0

I have a Fortran subroutine which uses BLAS’ subroutines dgemm, dgemv and ddot, which calculate matrix * matrix, matrix * vector and vector * vector. I have m * m matrices and m * 1 vectors. In some cases m=1. It seems that those subroutines doesn’t work well in those cases. They doesn’t give errors, but there seems to be some numerical unstability in results. So I have to write something like:

if(m>1) then 
  vtuni(i,t) = yt(i,t) - ct(i,t) - ddot(m, zt(i,1:m,(t-1)*tvar(3)+1), 1, arec, 1)
else 
   vtuni(i,t) = yt(i,t) - ct(i,t) - zt(i,1,(t-1)*tvar(3)+1)*arec(1)

So my actual question is, am I right that those BLAS’ subroutines doesn’t work properly when m=1 or is there just something wrong in my code? Can the compiler affect this? I’m using gfortran.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:59:13+00:00Added an answer on May 12, 2026 at 5:59 am

    BLAS routines are supposed to behave correctly with objects of size 1. I don’t think it can depend on compiler, but it could possible depend on the implementation of BLAS you’re relying on (though I’d consider it a bug of the implementation). The reference (read: not target-optimised) implementation of BLAS, which can be found on Netlib, handles that case fine.

    I’ve done some testing on both arrays of size 1, and size-1 slices of larger array (as in your own code), and they both work fine:

     $ cat a.f90 
     implicit none
     double precision :: u(1), v(1)
     double precision, external :: ddot
     u(:) = 2
     v(:) = 3
     print *, ddot(1, u, 1, v, 1)
     end
     $ gfortran a.f90 -lblas && ./a.out
      6.0000000000000000     
    
     $ cat b.f90                       
     implicit none
     double precision, allocatable :: u(:,:,:), v(:)
     double precision, external :: ddot
     integer :: i, j
     allocate(u(3,1,3),v(1))
     u(:,:,:) = 2
     v(:) = 3
     i = 2
     j = 2
     print *, ddot(1, u(i,1:1,j), 1, v, 1)
     end
     $ gfortran b.f90 -lblas && ./a.out
      6.0000000000000000     
    

    Things I’d consider to debug this problem further:

    • Check that your ddot definition is correct
    • Substitute the reference BLAS to your optimised one, to check if it changes anything (you can just compile and link in the ddot.f file I linked to earlier in my answer)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which is read from a fortran subroutine as a 1D
Respected sir/madam, I have a fortran exe which takes a input file and produces
I have the following FORTRAN code which I need to convert to C or
Good practice dictates that subroutine arguments in Fortran should each have a specified intent
I have a Fortran program, which I can compile using f77, f95 or ifort
I have the following FORTRAN SUBROUTINE SETPATHS(INPUT) !DEC$ ATTRIBUTES DLLEXPORT::SetPaths CHARACTER*20 INPUT CHARACTER*20 DIRECTORY
I have the following FORTRAN: SUBROUTINE MYSUB(MYPARAM) !DEC$ ATTRIBUTES DLLEXPORT::SetPaths CHARACTER*50 MYPARAM WRITE(6, *)
I have a line of Fortran code, which includes some text. I'm changing the
I have a piece of fortran code, and I am not sure which standard
I am calling a fortran subroutine from C#. One of the parameter I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.