Closed millerta closed 2 months ago
These files are in /src directory and were used to setup and test the wrappers. lg_example.cpp lg_example_fortran.f90
The routines can be called by using user_sub.f and compiling. Attached is an example. user_sub.f.txt
See code on branch tam-debug The code flow of msgtty and dotask makes debug more difficult. The error of losing the first word actually happens when msgtty is called a second time from the command stack routines. At this point the first word or "command" has already been parsed and the second call has the command missing. The error has happened already, in passing parameters to dotask() which should not have called msgtty in efforts to solve the commands.
I added dotask_test() and associated c-fortran wrappers and files to enable testing of the c-fortran wrappers. This code is same as dotask, but avoids the command routines and does nothing except report what dotask has received from fortran or cpp routines that call it.
Running this new wrapper shows there is a size error in the parameter passed from cpp to fortran dotask_test() parameter err is declared as int_ptrsize which dotask expects as integer 8. But in cpp sizeof(err) shows 4
This is fixed by adding type_sizes.h which defines int_ptrsize as size as null which is 8. This is sometimes corrected by compilers, but in some newer compilers it is not.
Inside C wrapper lg_dotask_test
received string: 123456789
string length: 9
sizeof strlen: 8
sizeof err: 4
sizeof hidden length: 8
sending parameters to FORTRAN dotask_test
send string: 123456789; finish
string length: 17
Begin FORTRAN dotask_test
parameter integer size: 8
received string: 123456789;
length: 10
The files added and modified for dotask c-fortran testing include:
new fortran dotask_test.f - dotask_test copy of dotask without global commands
lg_c_wrappers.cpp - DOTASK_TEST wrapper to fortran dotask_test
lg_c_interface.h - declare C lg_dotask_test
lg_f_interface.h: - declare fortran extern void DOTASK_TEST
CMakeLists.txt - add DOTASK_TEST to symbols for name mangling in fc_mangle.h
The following commands have been added to msgtty for testing during execution.
test (no second word) - easy test using createpts to check executable
test list - list available options
cpp - call dotask and c-fortran wrappers using get_info calls to get pointers from fortran
fortran - call dotask and get_info pointers used by cpp
dotask - call dotask_test which avoids global commands and just tests dotask parameters
Update files to include:
#include "type_sizes.h"
For any file that use int_ptrsize. This allowed dotask to correctly interpret the int_ptrsize as being 8.
The clipped buffer is showing up on some compilers and probably is related to strlen value being incorrect.
From Jeffrey on a mac:
For example, calling
leads to
This doesn’t happen with clang, but it is happening now with all gcc compilers I’ve tried.