Open rouson opened 6 years ago
I just fixed a typo in my TEST_SOURCE_DIR
definition so that it now reads
TEST_SOURCE_DIR = ftgDir + '/../test_drivers'
and a colleague pointed out the configure_fortrancallgraph.py
file, where I have set
fcgDir = os.path.dirname(os.path.realpath(__file__))
ASSEMBLER_DIRS = fcgDir + '/../project'
SOURCE_DIRS = fcgDir + '/../project'
I then moved hello.f90
to the above project
directory and get the following:
$ mkdir ../project
$ mv hello.f90 ../project
$ cd ../project
$ gfortran -save-temps -g -o hello hello.f90
$ cd ../fortrantestgenerator
$ ./FortranTestGenerator.py -c messages save_message
usage: FortranTestGenerator.py [-h] [-b] [-c] [-r] [-cf CONFIGFILE]
[module] [subroutine]
FortranTestGenerator.py: error: Subroutine __messages_MOD_save_messages not found!
In case it helps, I'm using gfortran
8.1.0 built from source after applying a very small patch to the compiler to fix a bug. I wonder what versions of gfortran
you've tested and I wonder if the name mangling scheme has changed -- seems unlikely but there's a remote chance the name mangling might have been adjusted when gfortran
added support for Fortran 2008 submodules sometime around version 6 or 7.
FYI, I then deleted an erroneous s
in the invocation of fortrantestgenerator and verified that the object file contains the mangled subroutine name that fortrantestgenerator reports as missing:
$ nm hello.o
0000000000000008 B _F.messages_MOD_recording
U free
U _gfortran_os_error
U _gfortran_runtime_error_at
U _gfortran_set_args
U _gfortran_set_options
U _gfortran_st_write
U _gfortran_st_write_done
U _gfortran_transfer_character_write
000000000000035c T main
000000000000028c t MAIN__
U malloc
U memmove
U memset
0000000000000000 T __messages_MOD_recorded_message
0000000000000000 B __messages_MOD_recording
0000000000000189 T __messages_MOD_save_message
00000000000000a0 r options.3.3801
U realloc
0000000000000010 b slen.1.3794
$ cd ../fortrantestgenerator/
$ ./FortranTestGenerator.py -c messages save_message
usage: FortranTestGenerator.py [-h] [-b] [-c] [-r] [-cf CONFIGFILE]
[module] [subroutine]
FortranTestGenerator.py: error: Subroutine __messages_MOD_save_message not found!
Thanks a lot for your request, @rouson. You are right, such a tutorial would be nice, but I cannot promise that I will be able to realize it soon.
Regarding your own efforts: FortranCallGraph assumes that every module is located in a file with the same name unless not specified otherwise, so you have to put messages
into a file called messages.f90
or add the following to your config_fortrancallgraph.py
:
SPECIAL_MODULE_FILES = {'messages': 'hello.f90'}
I'm excited about the prospects of applying fortrantestgenerator on two projects and finally diving in after some initial intimidation. It would be really helpful for the documentation to include the generation of a unit test for a "Hello, world!" program in a new
GETTING_STARTED.md
file for a target audience that is unfamiliar withpython
.I used
pip
to installcheetah3
, downloaded the other prerequisites to the same directory as fortrantestgenerator, and builtserialbox2
usingcmake
:Now I am struggling to generate a unit test for the following "Hello, world!" program:
At Step 8. Create capture code in the fortrantestgenerator README.md, I substituted the Fortran module name
messages
formy_module
and the subroutine namesave_message
formy_subroutine
. I get the following error:so then I edited the
TEST_SOURCE_DIR
definition in config_fortrantestgenerator.py to readIt would be great if a working default value were included in the version of config_fortrantestgenerator.py in the repository. Barreling forwarded with the above edit yields
but neither
SOURCE_DIRS
norASSEMBLER_DIRS
is defined in config_fortrantestgenerator.py and neither is mentioned in the README.md so now I'm doing recursivegrep
on these variable names and pondering how much further to venture down the rabbit hole without a flashlight. Thanks for any help you can provide.