int main(int argc, char **argv) { int val = 0; set_global_debug_level_fc(&val); val = 0; set_pseudo2d_domain_fc(&val); #ifdef HAVE_MPI MPI::Init(argc, argv); // Undo some MPI init shenanigans chdir(getenv("PWD")); #endif #ifdef HAVE_PETSC PetscInitialize(&argc, &argv, NULL, PETSC_NULL); // PetscInitializeFortran needs to be called when initialising PETSc from C, but calling it from Fortran // This sets all kinds of objects such as PETSC_NULL_OBJECT, PETSC_COMM_WORLD, etc., etc. PetscInitializeFortran(); #endif TESTNAME(); #ifdef HAVE_MPI MPI::Finalize(); #endif return 0; }
int main(int argc,char **args) { PetscErrorCode ierr; PetscInt m = 10; int fcomm; Vec vec; ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr; /* This function should be called to be able to use PETSc routines from the FORTRAN subroutines needed by this program */ PetscInitializeFortran(); ierr = VecCreate(PETSC_COMM_WORLD,&vec);CHKERRQ(ierr); ierr = VecSetSizes(vec,PETSC_DECIDE,m);CHKERRQ(ierr); ierr = VecSetFromOptions(vec);CHKERRQ(ierr); /* Call Fortran routine - the use of MPI_Comm_c2f() allows translation of the MPI_Comm from C so that it can be properly interpreted from Fortran. */ fcomm = MPI_Comm_c2f(PETSC_COMM_WORLD); ex7f_(&vec,&fcomm); ierr = VecView(vec,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = VecDestroy(&vec);CHKERRQ(ierr); ierr = PetscFinalize(); return ierr; }
int main(int argc, char* argv[]) { if (argc == 1) Usage(); // Initialize PETSc/MPI for command line options and engines that // require it. char help[] = "Alquimia advective, nondispersive reactive transport driver"; PetscInitialize(&argc, &argv, (char*)0, help); PetscInitializeFortran(); char input_file[FILENAME_MAX]; strncpy(input_file, argv[1], FILENAME_MAX-1); // Parse the input file. TransportDriverInput* input = TransportDriverInput_New(input_file); if (input == NULL) alquimia_error("transport: error encountered reading input file '%s'.", input_file); // Set up output. DriverOutput* output = NULL; if (AlquimiaCaseInsensitiveStringCompare(input->output_type, "python")) output = PythonDriverOutput_New(); else if (AlquimiaCaseInsensitiveStringCompare(input->output_type, "gnuplot")) output = GnuplotDriverOutput_New(); // Create a TransportDriver from the parsed input. TransportDriver* transport = TransportDriver_New(input); // Run the simulation. int status = TransportDriver_Run(transport); // Get the solution out of the driver and write it out. if (output != NULL) { double final_time; AlquimiaVectorString var_names = {.size = 0}; AlquimiaVectorDouble var_data = {.size = 0}; TransportDriver_GetSoluteAndAuxData(transport, &final_time, &var_names, &var_data); DriverOutput_WriteMulticompVector(output, input->output_file, var_names, var_data); FreeAlquimiaVectorString(&var_names); FreeAlquimiaVectorDouble(&var_data); } // Clean up. TransportDriverInput_Free(input); TransportDriver_Free(transport); PetscInt petsc_error = PetscFinalize(); if (status == EXIT_SUCCESS && petsc_error == 0) printf("Success!\n"); else printf("Failed!\n"); return status; }
int main(int argc, char **argv) { int val = 0; set_global_debug_level_fc(&val); set_pseudo2d_domain_fc(&val); #ifdef HAVE_MPI MPI::Init(argc, argv); // Undo some MPI init shenanigans chdir(getenv("PWD")); #endif #ifdef HAVE_PETSC PetscInitialize(&argc, &argv, NULL, PETSC_NULL); PetscInitializeFortran(); #endif #ifdef HAVE_PYTHON // Initialize the Python Interpreter python_init_(); #endif TESTNAME(); #ifdef HAVE_PYTHON // Finalize the Python Interpreter python_end_(); #endif #ifdef HAVE_PETSC PetscFinalize(); #endif #ifdef HAVE_MPI MPI::Finalize(); #endif return 0; }
PETSC_EXTERN void PETSC_STDCALL petscinitializefortran_(int *ierr) { *ierr = PetscInitializeFortran(); }