小编Ant*_*ano的帖子

LAPACK例程是否安全?

我是一个使用LAPACK例程的新手,所以我不太了解它们,我想在并行循环(openmp)中使用它们.

我使用Ubuntu 14.04LTS并使用我的包管理器安装LAPACK.安装的版本是:

liblapack3    3.5.0-2ubuntu1     Library of linear algebra routines 3 - shared version
Run Code Online (Sandbox Code Playgroud)

相关的BLAS库是:

libblas3    1.2.20110419-7
Run Code Online (Sandbox Code Playgroud)

所以,我的第一个问题很简单:我可以在使用OpenMP并行化的循环中使用LAPACK的任何子例程或函数吗?Id est,他们是安全的吗?

另一个问题是:我可以在我的纯子程序中使用LAPACK的任何子程序或函数吗?id est,在我编写的子程序中定义为纯子程序.

如果这些问题的答案是"不是所有LAPACK程序,而是其中一些程序",那么,我可以使用以下子程序吗?:

  • dgetrs
  • dgetrf
  • dgetri
  • dgecon

最后一个问题:LAPACK程序是否使用了我的所有内核?,id est,它们是否已经并行?

multithreading fortran blas lapack

6
推荐指数
1
解决办法
2289
查看次数

从名称列表中读取可分配数组

我正在使用GNU Fortran(GCC)4.8.2

我想从名称列表中读取可分配数组。但是我事先不知道必须向可分配数组中读取多少个元素,因此我无法在读取名称列表之前对其进行分配。

这是我的名单:namelist.nml:

&SECTION_1
    intList = 5,6,7
&END
Run Code Online (Sandbox Code Playgroud)

这是我的程序:namelist.f08:

program namelist
    implicit none

    integer, allocatable    :: intList(:)
    integer                 :: U    ! Unit to read the namelist file

    namelist /SECTION_1/ intList

    !allocate(intList(3)) ! <-- If I uncomment this, the program works.
    open(NEWUNIT=U, file="namelist.nml", status='OLD', recl=80, delim='APOSTROPHE')
    rewind(U)
    read(U, nml=SECTION_1)
    close(U)

    write (*,*) intList
end program namelist
Run Code Online (Sandbox Code Playgroud)

如果我取消标记行的注释,程序将运行,但是,正如我之前说的,我无法在分配之前读取名称列表。有人知道如何做到这一点吗?

fortran configuration-files allocatable-array

5
推荐指数
1
解决办法
687
查看次数

Fortran指向结构的指针

我有一个问题,指向结构的指针,指向结构的指针.我使用gfortran 4.6.3,文件名是test_pointer_struct.f08,所以我使用的是Fortran 2008标准(由gfortran 4.6.3支持).

赫拉来了代码:

PROGRAM test_pointer_struct

type tSmall
  integer          :: a
  double precision :: b
end type tSmall

type tBig
  integer                   :: h
  type(tSmall), pointer     :: member_small
end type tBig

type(tBig)                  :: var_big
type(tSmall), pointer       :: var_small(:)

! We get an array of pointers to the small structure
allocate(var_small(3))
! Also allocate the member_small strucutre (not an array)
allocate(var_big%member_small)

var_big%member_small%a = 1
var_big%member_small%b = 2.0

! Now we want an element of the var_samall array of pointers, to point …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran

3
推荐指数
1
解决办法
899
查看次数

为什么同一程序的 c 和 fortran 版本会产生不同的结果?

我使用 gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

C代码是:

// Compile with:
//  gcc -o little_c little.c
#include <stdio.h>  // printf

void main(void) {
    int n = 800;
    float a[n][n], b[n][n], c[n][n];
    int i, j, k;

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            a[i][j] = (float) (i+j);
            b[i][j] = (float) (i-j);
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            float …
Run Code Online (Sandbox Code Playgroud)

c precision fortran gfortran

2
推荐指数
1
解决办法
98
查看次数