小编A2L*_*LBK的帖子

在声明类型中分配参数声明类型时,ifort发生严重错误

请考虑以下代码

  module t_test
     implicit none

     type ttt(tsize)
        integer, len :: tsize
        real x(tsize)
     end type ttt



  type :: t_rndom_diameter(t_rsize,t_csize)
      integer, len :: t_rsize,t_csize
      real :: x(t_rsize,t_csize)
     type(ttt(tsize=:)), allocatable :: test_type
  end type t_rndom_diameter




  end module t_test


  program p_test
  USE t_test
  implicit none

  type(t_rndom_diameter(t_rsize=3,t_csize=3)) :: gdad

  allocate(gdad% ttt(tsize=10) ::  gdad % test_type)


  end program
Run Code Online (Sandbox Code Playgroud)

它给了我一个灾难性的错误,而没有提到错误是什么:

catastrophic error: **Internal compiler error: segmentation violation signal raised** Please
report this error along with the circumstances in which it occurred in a Software Problem
Report. …
Run Code Online (Sandbox Code Playgroud)

fortran intel-fortran

5
推荐指数
0
解决办法
98
查看次数

在Fortran中具有不同窗口大小的MPI共享内存

我正在尝试采用我的代码来利用MPI共享内存。

为了使事情尽可能简单,假设我只有两个核心。核心A需要来自核心b的size_b数组,而核心b需要来自核心a的size_a数组

在核心A上执行时,我可以执行以下操作吗?

 call MPI_WIN_ALLOCATE_SHARED(size_a_in_BYTES, disp_unit, MPI_INFO_NULL, comm_shm, ptr, win_a, mpierr)
 call C_F_pointer(ptr, fptr, (/size_a/))
Run Code Online (Sandbox Code Playgroud)

对于核心B

 call MPI_WIN_ALLOCATE_SHARED(size_b_in_BYTES, disp_unit, MPI_INFO_NULL, comm_shm, ptr, win_b, mpierr)
 call C_F_pointer(ptr, fptrb, (/size_b/))
Run Code Online (Sandbox Code Playgroud)

现在,假设我事后分别通过MPI_SEND / RECV win_a和win_b与核心B和核心a进行通信。现在的逻辑是按照以下方式进行两个查询

核心A:

        call MPI_WIN_SHARED_QUERY( win_b
 &                               , rank_of_core_B
 &                               , size_b
 &                               , disp_unit
 &                               , ptr_buf
 &                               , mpierr )
        call C_F_pointer(ptr_buf, fptr_query_A, (/size_b/))
Run Code Online (Sandbox Code Playgroud)

反之亦然,核心B

假设我知道在Core B中将我的指针指向fptrb一个数组,即

  fptrb = GIVEN_ARRAY_OF_SIZEB
Run Code Online (Sandbox Code Playgroud)

然后,我能否通过访问fptr_query_A例如在CORE中检索内存

   fptr_recv = fptr_query_A
Run Code Online (Sandbox Code Playgroud)

在fptr_recv与相同KIND的内核A中声明的指针在哪里fptr_query_A

我之所以这样问是因为,从手册中还不清楚例程是否MPI_WIN_ALLOCATE_SHARED除了为comm_shm共同使用外,是否还必须对所有共享内存核具有相同的胜利和规模。

请在回答时,我认为我的一些困惑是由于以下原因

1)进行呼叫 …

fortran mpi shared-memory

5
推荐指数
0
解决办法
95
查看次数

用现代 C++ 替换宏

我有以下宏

 #define Error(error_msg) ErrorMsg(__FILE__,__LINE__,error_msg)
Run Code Online (Sandbox Code Playgroud)

我想知道这是否可以用更现代的 c++ 替换,它可以在头文件中一劳永逸地定义?

我的功能ErrorMsg有以下界面

void ErrorMsg(const std::string &file, int line, const std::string &report)
Run Code Online (Sandbox Code Playgroud)

c++ c++20

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

Stack problems when copying from array to another in Fortran?

If I am doing the following copy in Fortran

 arr(i1:i2) = u(1:n) 
Run Code Online (Sandbox Code Playgroud)

where SIZE(arr(i1:i2)) == SIZE(u(1:n)) and the size is relative big, e.g 2M elements of double precision.

If variable arr is a pointer alias to another allocatable array. Would Fortran use the stack or heap memory to handle the copy assignment.?

If it is using the stack, is there any specific reason for that choice.?

How could one possibly avoid the compiler using the stack to not get a …

fortran segmentation-fault intel-fortran

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

指向访问其 () 运算符的类的指针的声明类型

我有以下课程

template<class T> class CT
{
  T& operator()(int i,int j) const noexcept
  { return indx[i*N+j]; }
  private:
  T  *indx;
  int N;

};
Run Code Online (Sandbox Code Playgroud)

现在在我的应用程序中的某些地方我有以下内容

CT<double> arr, (...);
(...)
decltype(arr) *alias;
if(usearr)alias = &arr;
(...)


alias(0,0) = 3.0; // Compiler ERROR!
Run Code Online (Sandbox Code Playgroud)

编译器抱怨我正在访问的对象类型decltype不是函数或函数指针。

如果我删除声明中的指针alias并将该行替换为赋值重载,则问题可以解决

decltype(arr) alias;
if(usearr)alias = arr;
Run Code Online (Sandbox Code Playgroud)

前一种方法有什么问题?

c++ pointers decltype c++11

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