简体   繁体   English

无法为基本PETSc程序生成Makefile

[英]Unable to generate makefile for basic PETSc program

I have a very basic program using PETSC 我有一个使用PETSC的非常基本的程序

 #include "PETSC/petsc.h"
 #include "PETSC/petscsys.h"
 #include "PETSC/petscmat.h"

 int main(int argc, char *argv[]) {
     PetscMPIInt    rank,size;
     PetscInitialize(&argc,&argv,0,0);
     MPI_Comm_size(PETSC_COMM_WORLD,&size);
     MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
     PetscPrintf(PETSC_COMM_WORLD,"Number of processors = %d, rank = %d\n",size,rank);
     PetscSynchronizedPrintf(PETSC_COMM_WORLD,"synchronized rank = %d\n",rank);

     MPI_Barrier(PETSC_COMM_WORLD);
 PetscFinalize();
     return 0;
 }

However, I got undefined reference errors to PETSC_COMM_WORLD , PetscInitialize and other junk, when I tried to compile using mpic++ 但是,当我尝试使用mpic ++进行编译时,出现了PETSC_COMM_WORLDPetscInitialize和其他垃圾的未定义引用错误。

I am now trying to use build and cmake. 我现在正在尝试使用build和cmake。 This is my attempt at a CMakeLists 这是我尝试的CMakeLists

 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

 PROJECT(checkMPI)

 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")

 set(PETSC_ARCH linux-gnu)
 set(PETSC_DIR l${PROJECT_SOURCE_DIR}/third-party/petsc)

 FIND_PACKAGE(PETSc REQUIRED)

 INCLUDE_DIRECTORIES(${PETSC_INCLUDES})
 ADD_DEFINITIONS(${PETSC_DEFINITIONS})

 ADD_EXECUTABLE(checkMPI checkMPI.cpp)

 TARGET_LINK_LIBRARIES(checkMPI ${PETSC_LIBRARIES})

In addition, I have a directory cmake-modules containing the cmake-modules for PETSc 此外,我还有一个目录cmake-modules其中包含PETSc的cmake-modules

However, when I try to generate the makefile by typing ccmake .. and then c , I get the output 但是,当我尝试通过键入ccmake ..然后输入c生成makefile时,得到了输出

CMake Error at cmake-modules/FindPETSc.cmake:127 (message):
   The pair PETSC_DIR=l/directory/HPC/third-party/petsc
   PETSC_ARCH=linux-gnu do not specify a valid PETSc installation
 Call Stack (most recent call first):
   CMakeLists.txt:10 (FIND_PACKAGE)

 CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108
(message):
   PETSc could not be found.  Be sure to set PETSC_DIR and PETSC_ARCH.
   (missing: PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS)
 Call Stack (most recent call first):
   /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315

Anyone can help? 有人可以帮忙吗?

Based on FindPETSC.cmake it seems that the default options for PETSC_ARCH are: 基于FindPETSC.cmake似乎默认选项PETSC_ARCH是:

linux-gnu-c-debug 
linux-gnu-c-opt
x86_64-unknown-linux-gnu 
i386-unknown-linux-gnu

or the one you have used in case of the manual build . 或在手动构建情况下使用的一种。

CMake tries to find file ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h or ${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h . CMake尝试查找文件${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM