I’m relatively new to preCICE and the community, and I’d like to ask for advice on an internal coupling setup using our in-house solver MESHFREE (written in Fortran).
Both coupled participants use MESHFREE, and I’m doing a volume–volume fluid–fluid coupling between air and water.
Setup:
- Both participants: MESHFREE (same solver, two instances: “air” and “water”)
- Coupling type: volume–volume coupling (air - water)
- Implementation: Fortran module bindings of preCICE (since MESHFREE is written in Fortran)
The problem appears in the last time synchronization window, when both solvers are finishing:
-
The air solver reaches the end time
Tendfirst. -
As soon as it reaches
Tend, the air side callsprecicef_finalizeand after that MPI_Finalize on the MESHFREE side, which closes the communication. -
As a result, the water side hangs, because it still expects data in the last synchronization window but the MPI channels are already closed on the air side.
To avoid this, I changed the behavior so that the MPI communication channels on the air side are only closed when both solvers have reached Tend.
#Normal termination routine- Logic
call precicef_finalize() # Each solver calls this
if (precice_L_SecondTermination) then #G.var-->True, only when called 2nd time
!Free up memory before exit
call mffree(precice_vertexIDs)
call mffree(precice_vertices)
call mffree(precice_writeData)
call mffree(precice_readData)
! Close the MPI-ranks only when the second participant also has a normal termination
call SYS_exit(EXIT_SUCCESS) #Call MPI_Finalize()
else
precice_L_SecondTermination = .true. #First solver, No MPI_Finalize()
endif
With this change,
-
Both participants terminate normally.
-
The logs from MESHFREE and preCICE show no abnormal termination (see attached files).
Question:
Has anyone experienced a similar issue when using internal coupling (both participants inside the same code base) especially in the last synchronization window ?
Any feedback or suggestions would be very welcome.