PetscInitialize() must be called before PetscFinalize() (SOLVED) - D-Flow Flexible Mesh - Delft3D
intro story D-Flow FM
D-Flow Flexible MeshD-Flow Flexible Mesh (D-Flow FM) is the new software engine for hydrodynamical simulations on unstructured grids in 1D-2D-3D. Together with the familiar curvilinear meshes from Delft3D 4, the unstructured grid can consist of triangles, pentagons (etc.) and 1D channel networks, all in one single mesh. It combines proven technology from the hydrodynamic engines of Delft3D 4 and SOBEK 2 and adds flexible administration, resulting in:
An overview of the current developments can be found here. The D-Flow FM - team would be delighted if you would participate in discussions on the generation of meshes, the specification of boundary conditions, the running of computations, and all kinds of other relevant topics. Feel free to share your smart questions and/or brilliant solutions!
======================================================= | Sub groups
|
Message Boards
PetscInitialize() must be called before PetscFinalize() (SOLVED)
michael schaferkotter, modified 2 Years ago.
PetscInitialize() must be called before PetscFinalize() (SOLVED)
Youngling Posts: 15 Join Date: 9/6/16 Recent Postscompiled r8765 with petsc-3.4.5 using MPI
(simple) partition the domain using:
$DFM_DIR/dflowfm --partition:ndomains=$NDOMAINS:icgsolver=6 $MDUFILE
results in the creation of:
${AREA_NAME}_0000.mdu, ${AREA_NAME}_0001.mdu, ..., ${AREA_NAME}_$NDOMAINS-1.mdu
and the corresponding ${AREA_NAME}_*_net.nc files.
however, a log message appears:
PetscInitialize() must be called before PetscFinalize()
https://lists.mcs.anl.gov/pipermail/petsc-users/2016-August/030221.html
indicates that the error code for PetscInitialize() was _not_ checked, the program continued running util it reached PetscFinalize(), where it could not handle the state since PETSc was not properly initialized.
the dflowfm code:
src/engines_gpl/dflowfm/packages/dflowfm_kernel/src/solve_petsc.F90
79 !> initialze PETSc
80 subroutine startpetsc()
81 #ifdef HAVE_PETSC
82 use m_petsc
83 use m_flowparameters, only: Icgsolver
84 implicit none
85 PetscErrorCode :: ierr = PETSC_OK
86
87 if ( icgsolver.eq.6 ) then
88 call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
89 call PetscLogBegin(ierr)
90 end if
91 #endif
92
93
94 return
95 end subroutine startpetsc
99 !> initialze PETSc
100 subroutine stoppetsc()
101 #ifdef HAVE_PETSC
102 use m_petsc
103 use m_flowparameters, only: Icgsolver
104 implicit none
105 PetscErrorCode :: ierr = PETSC_OK
106
107 if (Icgsolver.eq.6) then
108 call killSolverPETSC()
109 call PetscFinalize(ierr)
110 end if
111 #endif
112 return
113 end subroutine stoppetsc
recommendations?
michael schaferkotter, modified 2 Years ago.
RE: PetscInitialize() must be called before PetscFinalize()
Youngling Posts: 15 Join Date: 9/6/16 Recent PostsPROBLEM SOLVED:
the issue seemed to be with the optimization level -O3 in the PrgEnv-gnu (cray xc40).
debugging with valgrind elicited an 'unrecognized instruction'.
vi ./src/utils_lgpl/deltares_common/packages/deltares_common/src/geometry_module.f90 +370
370 csphi = dcos(0.5d0*(yy1+yy2))
review of other issues of this ilk, coupled with experience, led to review of the optimization levels.
http://valgrind.org/docs/manual/quick-start.html
Compile your program with -g to include debugging information so that Memcheck's error messages include exact line numbers. Using -O0 is also a good idea, if you can tolerate the slowdown. With -O1 line numbers in error messages can be inaccurate, although generally speaking running Memcheck on code compiled at -O1 works fairly well, and the speed improvement compared to running -O0 is quite significant. Use of -O2 and above is not recommended as Memcheck occasionally reports uninitialised-value errors which don't really exist.
after reducing the optimization level and a recompile, this issue did not occur.
further study is needed:
1. determine the maximum optimization level tolerated with this programming environment
2. compile under other PrgEnv-intel, PrgEnv-cray
Xiaohui Wang, modified 2 Years ago.
RE: PetscInitialize() must be called before PetscFinalize() (SOLVED)
Youngling Posts: 1 Join Date: 10/2/18 Recent PostsHi,
I also meet the problem with PetscInitialize() must be called before PetscFinalize() when I try to parallel run the model. Do I understand correctly that you changed the dflowfm code to correct the error? How can I do that I don't have the source code?
Best wishes
Xiaohui