Hello,

I compiled the newest version of  petsc-3.5.2 and tried to test an example
code with it. I could managed the compilation, but as I ran the sample,
some error popped out.  Could you please have a check? (files attached. I
did search the issue online, but ends up with no valid solution.)


--------------------------------------------------------------------------
Error obtaining unique transport key from ORTE
(orte_precondition_transports not present in
the environment).



Thanks,
Paul



Huaibao (Paul) Zhang
*Gas Surface Interactions Lab*
Department of Mechanical Engineering
University of Kentucky,
Lexington,
KY, 40506-0503
*Office*: 216 Ralph G. Anderson Building
*Web*:gsil.engineering.uky.edu
set (CMAKE_CXX_COMPILER mpiCC)
set (CMAKE_CXX_FLAGS "-O3")

set (PETSC_INCLUDE_DIRS1 /home/hzh225/LIB_CFD/nP/petsc-3.5.2/include)
set (PETSC_INCLUDE_DIRS2 
/home/hzh225/LIB_CFD/nP/petsc-3.5.2/linux-gnu-intel/include)
set (PETSC_LIBRARY_DIRS /home/hzh225/LIB_CFD/nP/petsc-3.5.2/linux-gnu-intel/lib)

cmake_minimum_required(VERSION 2.6)



project(kats)
set (kats_VERSION_MAJOR 2)
set (kats_VERSION_MINOR 0)

list (APPEND CMAKE_MODULE_PATH "${kats_SOURCE_DIR}/CMake")

# Pass some CMake settings to source code through a header file
configure_file (
        "${PROJECT_SOURCE_DIR}/cmake_vars.h.in"
        "${PROJECT_BINARY_DIR}/cmake_vars.h"
)

set (CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../)

# add to the include search path
include_directories("${PROJECT_SOURCE_DIR}")
include_directories(${PETSC_INCLUDE_DIRS1})
include_directories(${PETSC_INCLUDE_DIRS2})

link_directories(${PETSC_LIBRARY_DIRS})

#set (EXTRA_LIBS parmetis metis cgns petsc)# imf m)
set (EXTRA_LIBS petsc )

#add the executable
set (SOURCES
main.cc
cmake_vars.h
)
add_executable(kats ${SOURCES})

target_link_libraries (kats ${FCFD_LIBS} ${EXTRA_LIBS})

install (TARGETS kats RUNTIME DESTINATION bin)



#define FREECFD_VERSION_MAJOR 
#define FREECFD_VERSION_MINOR 
#include "petscksp.h"
#include <mpi.h>
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <limits>


static char help[] = "Solves a tridiagonal linear system with KSP.\n\n";

using namespace std;



int Rank,np;
int PetscPrintError(const char error[],...){
        if (Rank==0) cerr << "PETSc Error ... exiting" << endl;
        exit(1);
        return 0;
}




int main(int argc, char *argv[]) {

        // Initialize mpi
        MPI_Init(&argc,&argv);
        MPI_Comm_rank(MPI_COMM_WORLD, &Rank);
        MPI_Comm_size(MPI_COMM_WORLD, &np);



	KSP ksp;
	Mat A;
	Vec x, b;
	int n, its;
	PetscErrorCode ierr;
        PetscScalar value;
	PetscMPIInt np;
	int i,j; 

        PetscInitialize(&argc,&argv,(char *)0,help);
        PetscErrorPrintf = PetscPrintError;

	ierr = MPI_Comm_size(PETSC_COMM_WORLD,&np);CHKERRQ(ierr);
	if (np != 1) SETERRQ(PETSC_COMM_SELF,1,"This is a uniprocessor example only!");
	ierr = PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);CHKERRQ(ierr);


	/* linear solver context */
	/* matrix */
	/* solution, RHS vectors */
	/* problem dimension, number of iterations */
	n=2;

	cout<<"n="<<n<<endl;


	ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);
	ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr);
	ierr = MatSetFromOptions(A);CHKERRQ(ierr);


	value=1.; i=0; j=0;
	ierr = MatSetValues(A,1,&i,1,&j,&value,INSERT_VALUES);CHKERRQ(ierr);
	value=1.; i=0; j=1;
	ierr = MatSetValues(A,1,&i,1,&j,&value,INSERT_VALUES);CHKERRQ(ierr);
	value=1.; i=1; j=0;
	ierr = MatSetValues(A,1,&i,1,&j,&value,INSERT_VALUES);CHKERRQ(ierr);
	value=-1.; i=1; j=1;
	ierr = MatSetValues(A,1,&i,1,&j,&value,INSERT_VALUES);CHKERRQ(ierr);

	ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
	ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);

	MatView(A,PETSC_VIEWER_STDOUT_WORLD);     

	exit(0);

	/* (code to assemble matrix not shown) */
	VecCreate(PETSC_COMM_WORLD,&x);
	VecSetSizes(x,PETSC_DECIDE, n);
	VecSetFromOptions(x);
	VecDuplicate(x,&b);
	/* (code to assemble RHS vector not shown)*/
	KSPCreate(PETSC_COMM_WORLD, &ksp);
	//KSPSetOperators(ksp, A, A, DIFFERENT_NONZERO_PATTERN);
	KSPSetOperators(ksp, A, A);
	KSPSetFromOptions(ksp);


	KSPSolve(ksp, b, x);
	KSPDestroy(&ksp);

}

Reply via email to