ecmwf / fckit

A Fortran toolkit for interoperating Fortran with C/C++
https://confluence.ecmwf.int/display/fckit
Apache License 2.0
29 stars 13 forks source link

Failure in atlas_fctest_trace #45

Closed DJDavies2 closed 3 weeks ago

DJDavies2 commented 1 month ago

What happened?

I am getting a failure in atlas_fctest_trace like this:

28/208 Test #28: atlas_fctest_trace ........................................Subprocess aborted***Exception: 0.30 sec Runtime Error: /home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_fckit/fckit/src/fckit/module/fckit_C_interop.F90, line 169: Subscript out of range for assumed-size array S - Access to element 256 but actual argument has only 255 elements Program terminated by fatal error /home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_fckit/fckit/src/fckit/module/fckit_C_interop.F90, line 169: Error occurred in FCKIT_C_INTEROP_MODULE:COPY_C_STR_TO_STRING /home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_fckit/fckit/src/fckit/module/fckit_C_interop.F90, line 188: Called by FCKIT_C_INTEROP_MODULE:COPY_C_PTR_TO_STRING /home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_fckit/fckit/src/fckit/Log.F90, line 17: Called by FCKIT_WRITE_TO_FORTRAN_UNIT /home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_atlas/atlas/src/atlas_f/atlas_module.F90, line 246: Called by ATLAS_MODULE:ATLAS_FINAL /home/h01/frwd/cylc-run/mi-be984/work/1/ecbuild_atlas_nag/build/src/tests/runtime//home/h01/frwd/cylc-run/mi-be984/work/1/git_clone_atlas/atlas/src/tests/runtime/fctest_trace.fypp, line 59: Called by FCTEST_ATLAS_TRACE:TESTSUITE_FINALIZE /home/h01/frwd/cylc-run/mi-be984/work/1/ecbuild_atlas_nag/build/src/tests/runtime/fctest_trace_main.F90, line 22: Called by RUN_FCTEST_ATLAS_TRACE

I believe the problem is in fckit though, so I am opening the issue here.

What are the steps to reproduce the bug?

Build and run with NAG.

Version

develop

Platform (OS and architecture)

Linux

Relevant log output

No response

Accompanying data

No response

Organisation

Met Office

wdeconinck commented 1 month ago

Indeed as mentioned in #46 there is the hardcoded limit. I think the change in #46 is good, but I also think we should increase this limit. What is the example limit that would be required for this test to pass?

DJDavies2 commented 1 month ago

I upped the limit to 2550 in copy_c_ptr_to_string and the test passed. Looking at the particular tests, it appears that the string that it is trying to print is a stack trace; it is coming from the atlas finalise/library code (not surprising given which ctest is failing).

I can go through and increase all the limits to 2550 if you like. When these fckit functions were written was it intended that longer strings like stack traces would be passed to them?

Ideally there would be a way of doing this that didn't involve hardcoded limits at all.