我有一个fortran例程,该例程在外部静态库中调用C ++函数。我有一个整数:
integer (c_int) :: processor_wall_point_count
这只是传递给函数:
print*, processor_wall_point_count ! gives 112
call fci_wmm_allocate_domain(processor_wall_point_count, wall_model_ray_point_count)
C ++函数:
void fci_wmm_allocate_domain(int* _processor_wall_point_count, int* _ray_point_count)
{
std::cout << *_processor_wall_point_count << std::endl; // gives 70
}
[主代码具有MPI环境,并且在带有]的10个处理器上运行时>
print*, process_id, processor_wall_point_count !process id, variable call MPI_Barrier() call fci_wmm_allocate_domain(processor_wall_point_count, wall_model_ray_point_count)
和在C ++中:
void fci_wmm_allocate_domain(int* _processor_wall_point_count, int* _ray_point_count) { std::cout << process_id << ", " <<*_processor_wall_point_count << std::endl; MPI_Barrier(MPI_COMM_WORLD); }
我得到以下内容:
8 32 9 0 0 16 2 48 6 0 1 0 3 16 5 0 7 0 4 0 2, 48 8, 32 0, 10 3, 16 5, 0 9, 0 6, 0 1, 0 7, 0 4, 0
即,除处理器0外,所有值均正确传递。我以前使用C绑定没有(太多)问题。这是怎么回事?
我有一个fortran例程,该例程在外部静态库中调用C ++函数。我有一个整数:整数(c_int):: Processor_wall_point_count这只是传递给函数:print *,...
有趣的是112 = 0x70和16 = 0x10。可能是某个地方被遗忘的C ++流操纵器(std::hex
)吗?