An error when use the function setMeshaccessregion

I’m trying to follow a tutorial on modifying Fortran’s solverdummy to use the “Direct access to received meshes”Direct access to received meshes. But when I call this subrountine

CALL precicef_set_mesh_access_region(meshID, boundingBox)

, an error always occurs.

The given Mesh ID “XXXX” is unknown to preCICE

I uploaded my code and config file, can anyone help me?
precice-config.xml (1.1 KB) (2.3 KB)

This is the respective part of your fluid code:

  CALL precicef_action_write_initial_data(writeInitialData)
  CALL precicef_action_read_iter_checkp(readItCheckp)
  CALL precicef_action_write_iter_checkp(writeItCheckp)

  WRITE (*,*) 'DUMMY: Starting Fortran solver dummy...'
  config = 'precice-config.xml'
  participantName = 'Fluid'
  meshName = "Solid-Mesh"
  WriteDataName = "Force"

  rank = 0
  commsize = 1
  dt = 1
  numberOfVertices = 3
  WRITE (*,*) 'Before precicef_create'
  CALL precicef_create(participantName, config, rank, commsize)
  WRITE (*,*) ' after precicef_create'

  CALL precicef_get_dims(dimensions)
  CALL precicef_get_mesh_id(meshName, meshID)
  CALL precicef_get_data_id(writeDataName,meshID,writeDataID)

  boundingBox(1) = 0.0d0 ! lower x bound
  boundingBox(2) = 4.0d0 ! upper x bound
  boundingBox(3) = 0.0d0 ! lower y bound
  boundingBox(4) = 4.0d0 ! upper y bound
  boundingBox(5) = 0.0d0 ! lower y bound
  boundingBox(6) = 4.0d0 ! upper y bound

  ! Allocate dummy mesh with only one vertex
  ! CALL precicef_set_mesh_access_region(0, boundingBox)
  CALL precicef_set_mesh_access_region(meshID, boundingBox)

Besides the three early/unneeded calls to the action subroutines in the beginning, I don’t see any clear issue, comparing to the documentation: Direct access to received meshes | preCICE - The Coupling Library

Are you sure it comes from this call and not for the rest of the code?

This is the error you are getting: precice/ValidationMacros.hpp at v2.5.0 · precice/precice · GitHub

@DavidSCN may be able to help, I am not very familiar with this feature yet.

Thanks for your reply, yes this error is from this code, it is reported before initialization, I don’t know if it’s because of the reason I use Fortran code or something else, I’m looking for the reason further, but I don’t know enough about precice.

I further tested the same idea by setting up the program using C++ code, and found that the program could run normally. Therefore, I suspect that there might be an issue with the binding of the precicef_set_mesh_access_region(meshID, boundingBox) subroutine in Fortran, or it could be the incorrect format of the boundingBox when I made the call. I have uploaded the C++ code that runs successfully for your reference, and I would appreciate it if you could take a look. Thank you!
precice-config.xml (1.1 KB) (2.4 KB)

1 Like

Very good step to try the same in C++, it helps.

Comparing to the fortran solverdummy, I don’t see anything clearly wrong either. It could indeed be an issue with the Fortran bindings, but we need to check some things first.

Could you check which meshID you get after

  CALL precicef_get_mesh_id(meshName, meshID)

and which meshID the error message returns? Are they the same, or different? (suggested by @DavidSCN)

yes, I check the meshID, it get zero value after call precicef_get_mesh_if. This step no error message. They are same in two solver.

I am confused: In your first post, you wrote that:

Don’t you get this error message anymore?

The interesting part is not if the two solvers have the same mesh ID, but if you get the same ID in the error message and by the precicef_get_mesh_id().