Skip to content

Fix null pointer to mesh #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Fix null pointer to mesh #102

merged 1 commit into from
Jun 24, 2024

Conversation

JamieJQuinn
Copy link
Collaborator

@JamieJQuinn JamieJQuinn commented Jun 24, 2024

After compiling with nvfortran, the code would fail during runtime with the following error:

Parallel run with            1 ranks
0: Null pointer for mesh%geo (/home/jjquinn/projects/xcompact/x3d2/src/xcompact.f90: 71)

--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[8151,1],0]
  Exit code:    127
--------------------------------------------------------------------------

The compilation and run steps on Sylvain's Kolmogorov machine are:

cmake -DCMAKE_BUILD_TYPE=Debug -B build -DCMAKE_Fortran_COMPILER=mpif90
cmake --build build -j18
mpirun -n 1 build/src/xcompact

This PR removes the allocatable attribute on mesh and changes both mesh and its contained geo and par members to type instead of class. I'm don't know this feature of Fortran well enough to explain why this works but it fixes the problem...

Additional nonsense: The unit test that uses the same pattern or allocatable + class passes fine. No idea why.

…table attribute. Fixes bug when compiling with nvfortran where pointer to mesh is reported as null during runtime.
@JamieJQuinn JamieJQuinn requested a review from Nanoseb June 24, 2024 16:06
@Nanoseb
Copy link
Collaborator

Nanoseb commented Jun 24, 2024

Ah yes, it makes some sense. If you have a class, because it could be of any extended type of this class, you need to explicitly allocate it to the right type. Because here we only have a single type for this class, I believe the other compilers make the assumption that's the one we want to allocate.

Changing to type makes it unambiguous.

@JamieJQuinn JamieJQuinn merged commit 01aa51e into main Jun 24, 2024
2 checks passed
@JamieJQuinn JamieJQuinn deleted the jq/fix-nvidia-mesh-error branch June 24, 2024 16:26
ia267 pushed a commit to ia267/x3d2 that referenced this pull request Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants