Skip to content
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

1990 handle imported variable in kernel extraction #2252

Merged
merged 218 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 208 commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
e34decd
#1990 Added support to handle PSyIR representations of a module.
hiker Jan 24, 2023
3d26f51
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Jan 24, 2023
c205d89
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Jan 30, 2023
6512424
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Jan 30, 2023
d633604
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Jan 31, 2023
945068e
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Jan 31, 2023
131c88c
#1990 Handle module that cannot be parsed by creating an empty FileCo…
hiker Feb 2, 2023
8796a29
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 2, 2023
3e9e54c
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 6, 2023
c3e29d6
Merge branch '2033_new_split_variables_access_info_on_master' into 19…
hiker Feb 6, 2023
986d47c
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 6, 2023
567b829
#1990 Added first test to find external symbols.
hiker Feb 7, 2023
21ade76
#1990 Use BuiltIn instead of LFRicBuiltIn to make the code more generic.
hiker Feb 7, 2023
d8f8eec
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 9, 2023
ea8c9cd
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 13, 2023
9022ee4
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Feb 21, 2023
f78521a
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Mar 6, 2023
a0ce96c
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Mar 21, 2023
4c440f9
#1990 Added function to compute non-local accesses in a routine.
hiker Mar 22, 2023
b28357f
#1990 Added some debug code for now.
hiker Mar 23, 2023
bec1005
#1990 Added some debug code to the examples.
hiker Mar 23, 2023
61590c4
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Mar 26, 2023
15aa712
#1990 Add function-based search for external symbols (wip).
hiker Mar 28, 2023
abd7aa4
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Mar 29, 2023
97b9e68
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Mar 30, 2023
9ce391c
#1990 Remove outdated code.
hiker Mar 30, 2023
43031bc
#1990 Added RoutineInfo to better encapsulate if a module contains se…
hiker Mar 31, 2023
d44cc8c
#1990 Don't distinguish between subroutine and functions.
hiker Mar 31, 2023
a4b1ff1
#1990 Add test function to see if a routine is in a module.
hiker Mar 31, 2023
a36074a
#1990 Support generic interfaces.
hiker Apr 3, 2023
de1c654
#1990 Ignore if a module cannot be parsed.
hiker Apr 3, 2023
a05927e
#1990 Made debug output more useful.
hiker Apr 3, 2023
c3c7614
#1990 Only walk the tree once.
hiker Apr 3, 2023
6604869
#1990 Updated documentation.
hiker Apr 3, 2023
5d296bd
#1990 Start to identify constants.
hiker Apr 3, 2023
7727a12
#1990 Start to add VariableAccess information for external symbols.
hiker Apr 5, 2023
d46d7da
#1990 Add constant for testing.
hiker Apr 5, 2023
0c61d4a
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Apr 11, 2023
1caf311
#1990 Added 'is_written_first' function to SingleVariableAccessInfo.
hiker Apr 11, 2023
7aac43b
#1990 Resolve references and unknown accesses, and sort non-local sym…
hiker Apr 11, 2023
26bb92d
#1990 Use signatures instead of strings for symbols.
hiker Apr 13, 2023
c948913
#1990 Made property an explicit call to be consistent with other code…
hiker Apr 13, 2023
376809f
#1990 Return local and non-local access information.
hiker Apr 13, 2023
3841723
#1990 Support character types in extraction.
hiker Apr 14, 2023
cb6e189
#1990 Convert all routine names to lower case.
hiker Apr 14, 2023
333ee28
#1990 Include module_name in dependency analysis output and pass it t…
hiker Apr 14, 2023
d5a8f35
#1990 Added file missed when updating the extraction libraries.
hiker Apr 14, 2023
be0e39f
#1990 Added new ReadWriteInfo class to encapsulate the information re…
hiker Apr 17, 2023
91a689b
#1990 Added tests for new ReadWriteInfo class.
hiker Apr 17, 2023
600cfae
#1990 Fixed failing tests (except for LFRic ones).
hiker Apr 17, 2023
bad35ac
#1990 Added source path so that module manager can find the modules.
hiker Apr 17, 2023
86f5b4b
#1990 Ignore modules that cannot be found.
hiker Apr 17, 2023
f368ce8
#1990 Use read_write_info.
hiker Apr 17, 2023
10c09b8
#1990 Use better names, add comments.
hiker Apr 17, 2023
ccb9b9e
#1990 Fix name/tag for external written symbol to have _post at the e…
hiker Apr 17, 2023
3b87aac
#1990 Added function to look up symbol information for a module.
hiker Apr 17, 2023
7e28646
#1990 Fix old code to use new ReadWriteInfo class.
hiker Apr 17, 2023
0b885c5
#1990 Support non-local symbols in LFRic driver creation.
hiker Apr 17, 2023
de11c89
#1990 Added more convenienve properties to make porting easier.
hiker Apr 18, 2023
3e4703c
#1990 Fixed failing test.
hiker Apr 18, 2023
c21b312
#1990 Updated example.
hiker Apr 18, 2023
af619aa
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Apr 18, 2023
4da9d3a
#1990 The config file can now take an optional list of modules that t…
hiker Apr 20, 2023
da6078c
#1990 Made code more robust in case of modules that cannot be parsed.
hiker Apr 24, 2023
56cfe53
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Apr 27, 2023
73f8193
Merge branch '1991_better_compilation_support' into 1990_handle_impor…
hiker Apr 28, 2023
346aa2f
#1990 Also handle fparser errors.
hiker Apr 28, 2023
cdf33ce
#1990 Fixed failing test, now that 'constants_mod' can be parsed.
hiker Apr 28, 2023
04f2ff0
#1990 Fixed failing test.
hiker Apr 28, 2023
34a0efa
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker May 2, 2023
c325c06
#1990 Fully declare variables imported from a module so we can query …
hiker May 2, 2023
7b80c8a
#1990 Handle errors happening when a file cannot be parsed.
hiker May 11, 2023
14f4310
#1990 Properly handle local symbols.
hiker May 11, 2023
e4cd04d
#1990 Handle errors better.
hiker May 11, 2023
852f946
#1990 Add expected tag for precision symbols.
hiker May 11, 2023
d435003
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker May 11, 2023
445e908
#1990 Remove public and protected attributes when inlining dependenci…
hiker May 11, 2023
20c627a
#1990 Don't try to read in constant values.
hiker May 11, 2023
6dbbc3b
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 15, 2023
b6fdb57
#2139 Removed unnecessary code.
hiker May 15, 2023
2db5086
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 16, 2023
e1bd1f8
#1990 Removed outdated TODO.
hiker May 16, 2023
a25e908
#1990 Added todo.
hiker May 17, 2023
0bd83b1
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 17, 2023
b25a43a
#1990 Merge the non-local and local-only get_in_out_parameters functi…
hiker May 19, 2023
4631123
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 24, 2023
f28ba24
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 25, 2023
6816b53
Merge branch '2139_encapuslate_in_out_info' into 1990_handle_imported…
hiker May 31, 2023
f92df52
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Jun 14, 2023
a8582a1
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Jun 20, 2023
336fe08
#1990 Fix renamed function: is_local to is_automatic.
hiker Jun 21, 2023
ff6e3fb
#1990 Added tests for driver creation with external symbols.
hiker Jun 21, 2023
64ff91a
#1990 Don't remove pre-processed files, otherwise compilation of exam…
hiker Jun 23, 2023
5c133b6
#1990 Make separate invoke for error (to avoid error messages when no…
hiker Jun 23, 2023
0ebc2c0
#1990 Handle name conflict in extraction with gen_code.
hiker Jun 23, 2023
699862e
#1990 Update psy_data_node_test to cover all newly added lines.
hiker Jun 23, 2023
cde2976
#1990 Handle name clash in lowering functions of the PSyDataNode.
hiker Jun 26, 2023
b5c7a12
#1990 Fixed support for user defined types in extraction.
hiker Jun 26, 2023
6dd5203
#1990 Cover all of module_manager.
hiker Jun 26, 2023
220886c
#1990 Move clear_module_manager_instance into top-level conftest file.
hiker Jun 26, 2023
a9ccbb7
#1990 Updated test.
hiker Jun 26, 2023
88004d8
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Jun 26, 2023
d316ae6
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 2, 2023
6011932
#1990 Test handling of a generic interface.
hiker Aug 3, 2023
6fea986
#1990 Completely cover module_information.
hiker Aug 4, 2023
ba1600f
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 4, 2023
71e4b25
#1990 Ignore automatically created files in example and psyad doc bui…
hiker Aug 4, 2023
9ed718f
#1990 Fix handling of errors in LFRic driver creation.
hiker Aug 7, 2023
5a79bfc
#1990 Started to add routine_info_test to cover all of routine_info.py
hiker Aug 8, 2023
5afea27
#1990 Fixed module manager tests.
hiker Aug 8, 2023
34f9c4c
#1990 Added call to a local and to a subroutine that cannot be found.
hiker Aug 8, 2023
252d9a4
#1990 Added function to test that assignment to the result is not ret…
hiker Aug 8, 2023
648d10f
#1990 Added test for generic interfaces.
hiker Aug 8, 2023
ebb7c8f
#1990 Removed unnecessary fixtures.
hiker Aug 9, 2023
3136713
#1990 Added module function, renamed module_subroutine.
hiker Aug 9, 2023
f7569c7
#1990 Updated to exception-free error handling.
hiker Aug 9, 2023
4e9c557
#1990 Added test for non-local in/out parameter collection.
hiker Aug 10, 2023
2ea1ea5
#1990 Add test for ignoring modules.
hiker Aug 10, 2023
7188c22
#1990 Added test for a subroutine that is supposed to be in a module …
hiker Aug 10, 2023
8353ba6
#1990 Cover resolving functionality, covering 100% of the dependency …
hiker Aug 10, 2023
1a29634
#1990 Removed lines testing for local function that is unnecessary, s…
hiker Aug 10, 2023
ad06d29
#1990 Added option to return original names for renamed symbols in va…
hiker Aug 15, 2023
d2f7a14
#1990 Support returning original names in a reference.
hiker Aug 15, 2023
cb04512
#1990 Use the original name in the driver is a non-local symbol is be…
hiker Aug 15, 2023
52f624a
#1990 Updated documentation of new use-original-name option.
hiker Aug 15, 2023
e1b25b0
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 15, 2023
0b9b0a3
#1990 Added documention on using the extraction and psydata in genera…
hiker Aug 16, 2023
1fee9b3
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 17, 2023
06c3b82
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 23, 2023
866f5cc
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Aug 31, 2023
011ffd9
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Sep 13, 2023
4a28617
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Oct 16, 2023
4990e26
#1990 Fixed test failures caused by changes on master.
hiker Oct 16, 2023
999c8c7
#1990 Fixed missing 'else' statement that disappeared while merging.
hiker Oct 16, 2023
9d5c1e5
#1990 Fixed failing tests.
hiker Oct 16, 2023
759ea1f
#1990 Removed debug print.
hiker Oct 17, 2023
7e4df70
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Oct 17, 2023
92a78dd
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Oct 17, 2023
d5ddf46
#1990 Removed incorrect comment.
hiker Oct 17, 2023
19b37f8
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Oct 30, 2023
ab47c73
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 2, 2023
6e0765a
#1990 Use Routine instead of RoutineInfo for non-local variables.
hiker Nov 2, 2023
9df1bac
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 2, 2023
8bec63b
#1992 Replace usage of RoutineInfo class.
hiker Nov 2, 2023
9d1c8a0
#1990 Fix handling of intrinsics (which were reported as unknown func…
hiker Nov 3, 2023
5d1ef41
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 8, 2023
7e4119d
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 8, 2023
1dcff85
#1990 Fixed earlier merging error with read_kernel_data_mod.
hiker Nov 9, 2023
3b812a8
#1990 Remove the usage of get_psyir in DepTools, since it don't work …
hiker Nov 14, 2023
a304bab
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 14, 2023
74a6301
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 15, 2023
afc81c4
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 22, 2023
dae8bc3
2296 Remove now unnecessary import outside toplevel.
hiker Nov 22, 2023
5c3100a
#1990 Fix circular import.
hiker Nov 22, 2023
8b9f4a0
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 22, 2023
db0fe9a
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Nov 23, 2023
2ad96a2
#1990 Re-fixed handling of intrinsics ... which had disappeared.
hiker Nov 23, 2023
8afb8de
#1990 Move more functionality into CallTreeUtils.
hiker Dec 6, 2023
89c6da4
#1990 Removed debug output.
hiker Dec 6, 2023
086e0af
#1990 Removed print statements.
hiker Dec 6, 2023
b42723e
#1990 Completely cover _compute_all_non_locals.
hiker Dec 7, 2023
b25b6f5
#1990 Cover all of call_tree_utils.
hiker Dec 7, 2023
4734839
#1990 Simplified dependency tool test, which is now mostly covered in…
hiker Dec 7, 2023
c3823d7
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 8, 2023
76320da
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 12, 2023
bfbc8ed
#1990 Updated some comments and test names.
hiker Dec 12, 2023
676b4c0
#1990 Updated some comments and test names.
hiker Dec 12, 2023
6cc8242
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 12, 2023
5cd226a
#1990 Fixed failing test.
hiker Dec 12, 2023
be0d3dd
#1990 Ignore ifcore module.
hiker Dec 14, 2023
27f13ba
#1990 Properly handle generic interfaces.
hiker Dec 14, 2023
1d28c07
#1990 Detect and ignore constants used from other modules.
hiker Dec 14, 2023
ddc3cf5
#1990 Remove some kind of left-over test, likely a results of merge c…
hiker Dec 14, 2023
2cc0f0c
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 14, 2023
e1dfde1
#1990 Handle name clash between local variable and module variable in…
hiker Dec 15, 2023
ed39906
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 15, 2023
9be69a7
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 18, 2023
5706bfd
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Dec 22, 2023
43bf301
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 11, 2024
66df0be
#1990 Added forgotten lowercasing of module name to avoid a module na…
hiker Jan 11, 2024
c993dc3
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 15, 2024
19c992f
#1990 Fixed comment.
hiker Jan 15, 2024
373beed
#1990 Fixed problems caused by refactoring in 2296.
hiker Jan 15, 2024
f8a7440
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 15, 2024
292d28b
#1990 Updated code to refactoring in 2296 - ModuleInfo.get_psyir() no…
hiker Jan 15, 2024
c34c41f
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 16, 2024
a9f3132
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 24, 2024
8bed1fa
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Jan 30, 2024
161ff78
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Feb 16, 2024
9ef9351
Merge branch '2296_add_routine_info' into 1990_handle_imported_variab…
hiker Feb 21, 2024
08e1f55
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Feb 22, 2024
8e76af2
#1992 Avoid adding a library into the library.
hiker Feb 27, 2024
f338623
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Feb 29, 2024
0f5b83c
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Mar 26, 2024
a112d1b
#1990 Errors are now handled/happening in CallTreeUtils.
hiker Mar 27, 2024
91a33f8
#1990 Constants are detected and discarded earlier, so remove unused …
hiker Mar 27, 2024
d28e89e
#1990 Added another test for coverage.
hiker Mar 28, 2024
73d0a6d
#1990 Fixed coverage.
hiker Apr 2, 2024
9f5ead6
#1990 Moved read_kernel_data_mod into the API subdirectories, so all …
hiker Apr 5, 2024
39dd0e1
#1990 Fixed comments, documentation and coding style.
hiker Apr 5, 2024
fdb9c4a
#1990 Handle missing option parameter, added tests.
hiker Apr 8, 2024
9f8f01c
#1990 Added optional compilation of drivers created during testing.
hiker Apr 8, 2024
cad7270
#1990 Updated comments.
hiker Apr 8, 2024
82c4123
#1990 Use find_or_create in symboltable.
hiker Apr 9, 2024
086abae
#1990 Add search path to error message
hiker Apr 9, 2024
5764371
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Apr 9, 2024
5cfb95b
#1990 Fixed makefiles for LFRic example.
hiker Apr 9, 2024
fc32b93
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker Apr 10, 2024
f0b2c0d
#1190 Fix typos introduced by search&replace.
hiker May 8, 2024
f26abf9
#1990 Remove LFRic-specific setting.
hiker May 9, 2024
3755fe4
#1990 Removed debug print.
hiker May 9, 2024
c7afd3a
#1990 Removed insecure code that removed public/private.
hiker May 9, 2024
2b8d770
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker May 9, 2024
0855909
#1990 Updated documentation.
hiker May 9, 2024
db09e60
#1990 Make sure that read_kernel_data_mod is created before running P…
hiker May 9, 2024
e6c51f2
Merge remote-tracking branch 'origin/master' into 1990_handle_importe…
hiker May 10, 2024
0ffa366
Merge branch 'master' into 1990_handle_imported_variable_in_kernel_ex…
arporter May 13, 2024
8e85eac
#2252 update changelog and UG
arporter May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/psyclone.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ VALID_PSY_DATA_PREFIXES = profile, extract, read_only_verify, nan_test
OCL_DEVICES_PER_NODE = 1

# Symbols imported from the following modules will be ignored when parsing
# and will not produce a warning message if they cannot be found
IGNORE_MODULES = netcdf, mpi
# and will not produce a warning message if they cannot be found.
# ifcore is an intel-specific traceback library that is used by LFRic
IGNORE_MODULES = netcdf, mpi, ifcore
arporter marked this conversation as resolved.
Show resolved Hide resolved

# Settings specific to the LFRic (Dynamo 0.3) API
# ===============================================
Expand Down
43 changes: 42 additions & 1 deletion doc/user_guide/psy_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ linking the verification library. The application which uses the
read-only-verification library needs to link in the infrastructure
library anyway.

.. note:
.. note::
It is the responsibility of the user to make sure that the infrastructure
files used during compilation of the read-only-verification library are
also used when linking the application. Otherwise strange and
Expand Down Expand Up @@ -255,3 +255,44 @@ An executable example for using the LFRic read-only-verification library is
included in ``tutorial/practicals/LFRic/building_code/4_psydata`` directory,
see `this link for more information
<https://github.com/stfc/PSyclone/tree/master/tutorial/practicals/LFRic/building_code/4_psydata>`_.


.. _integrating_psy_data_lfric:

Integrating PSyData Libraries into the LFRic Build Environment
--------------------------------------------------------------
The easiest way of integrating any PSyData-based library into the LFRic
build environment is:

- In the LFRic source tree create a new directory under ``infrastructure/source``,
e.g. ``infrastructure/source/psydata``.
- Build the PSyData wrapper stand-alone in ``lib/extract/netcdf/lfric`` (which
will use NetCDF as output format) or ``lib/extract/standalone/lfric`` (which
uses standard Fortran binary output format) by executing ``make``. The compiled
files will actually not be used, but this step will create all source
files (some of which are created by jinja). Do not copy
the compiled files into your LFRic build tree, since these files might be
compiled with an outdated version of the infrastructure files and be
incompatible with files in a current LFRic version.
- Copy all processed source files (``extract_netcdf_base.f90``,
``kernel_data_netcdf.f90``, ``psy_data_base.f90``,
``read_kernel_data_mod.f90``) into ``infrastructure/source/psydata``
- Start the LFRic build process as normal. The LFRic build environment will
copy the PSyData source files into the working directory and compile
them.
- If the PSyData library needs additional include paths (e.g. when using an
external profiling tool), add the required paths to ``$FFLAGS``.
- If additional libraries are required at link time, add the paths
and libraries to ``$LDFLAGS``. Alternatively, when a compiler wrapper
script is provided by a third-party tool (e.g. the profiling tool
TAU provides a script ``tau_f90.sh``), either set the environment variable
``$FC``, or if this is only required at link time, the variable ``$LDMPI``
to this compiler wrapper.

.. warning::
Only one PSyData library can be integrated at a time. Otherwise there
will be potentially several modules with the same name (e.g.
``psy_data_base``), resulting in errors at compile time.

.. note::
With the new build system FAB this process might change.
36 changes: 21 additions & 15 deletions doc/user_guide/psyke.rst
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,8 @@ code, it will create an output file for each instrumented code region.
The same logic for naming variables (using ``_post`` for output variables)
used in :ref:`extraction_for_gocean` is used here.

As in the case of e.g. :ref:`read-only verification
<psydata_read_verification>`, this library uses the pared-down LFRic
infrastructure located in a clone of PSyclone repository,
``<PSYCLONEHOME>/src/psyclone/tests/test_files/dynamo0p3/infrastructure``.
However, this needs to be changed for any user (for instance with
PSyclone installation). Please refer to the relevant ``README.md``
documentation on how to build and link this library.
Check :ref:`integrating_psy_data_lfric` for the recommended way of linking
an extraction library to LFRic.

The output file contains the values of all variables used in the
subroutine. The ``LFRicExtractTrans`` transformation can automatically
Expand Down Expand Up @@ -495,14 +490,6 @@ optimisation of a stand-alone kernel.
stores the variable names and will not be able to find a variable
if its name has changed.

.. note:: If the kernel, or any function called from an extracted kernel
should use a variable from a module directly (as opposed to supplying
this as parameter in the kernel call), this variable will not be
written to the extract data file, and the driver will also not try to
read in the value. As a result, the kernel will not be able to
run stand-alone. As a work-around, these values can be added manually
to the driver program. Issue #1990 tracks improvement of this situation.

The LFRic kernel driver will inline all required external modules into the
driver. It uses a ``ModuleManager`` to find the required modules, based on the
assumption that a file ``my_special_mod.f90`` will define exactly one module
Expand Down Expand Up @@ -531,6 +518,25 @@ paths (infrastructure files and extraction library) for the compiler, but
these flags are actually only required for compiling the example program, not
for the driver.

Restrictions of Kernel Extraction and Driver Creation
#####################################################
A few restrictions still apply to the current implementation of the driver
creation code:

- Distributed memory is not yet supported. See #1992.
- The extraction code will now write variables that are used from other
modules to the kernel data file, and the driver will read these values in.
Unfortunately, if a variable is used that is defined as private,
the value cannot be written to the file, and compilation will abort.
The only solution is to modify this file and make all variables public.
This mostly affects ``log_mod.F90``, but a few other modules as well.
arporter marked this conversation as resolved.
Show resolved Hide resolved
- For now, the created driver modifies the attributes of all variables so that
they can be written when reading in the modified values. This
means that the driver will at least compile and work, but the previously
mentioned work is still required for the extraction process (TODO #2536).
- The new build system FAB will be able to remove ``private`` and
``protected`` declarations in any source files, meaning no manual
modification of files is required anymore (TODO #2536).

Extraction for NEMO
++++++++++++++++++++
Expand Down
25 changes: 8 additions & 17 deletions examples/gocean/eg5/extract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,16 @@ INF_INC = $(INF_DIR)/src
INF_LIB = $(INF_DIR)/src/lib_fd.a
ifeq ($(TYPE), netcdf)
EXTRACT_DIR ?= $(PSYROOT)/lib/extract/netcdf/dl_esm_inf
READ_DIR ?= $(PSYROOT)/lib/extract/netcdf
F90FLAGS += $$(nf-config --fflags)
LDFLAGS += $$(nf-config --flibs)
GENERATED_FILES += main-init.nc main-update.nc
else
EXTRACT_DIR ?= $(PSYROOT)/lib/extract/standalone/dl_esm_inf
READ_DIR ?= $(PSYROOT)/lib/extract/standalone
GENERATED_FILES += main-init.binary main-update.binary

endif

LIB_NAME = lib_extract.a
READ_KERNEL_DATA = $(READ_DIR)/read_kernel_data_mod.o \


# The two kernels used in the application.
Expand All @@ -91,16 +88,16 @@ DRIVER_UPDATE = driver-main-update
.PHONY: transform compile run

run: compile
./extract_test
./driver-main-init
./driver-main-update
./$(NAME)
./driver-main-init.$(TYPE)
./driver-main-update.$(TYPE)

compile: transform $(NAME) $(DRIVER_INIT).$(TYPE) $(DRIVER_UPDATE).$(TYPE)

transform: psy.f90


F90FLAGS += -I$(INF_INC) -I$(EXTRACT_DIR) -I$(READ_DIR)
F90FLAGS += -I$(INF_INC) -I$(EXTRACT_DIR)

alg.f90 psy.f90: test.x90 extract_transform.py
$(PSYCLONE) -nodm -api "gocean1.0" -s ./extract_transform.py\
Expand All @@ -112,15 +109,15 @@ $(NAME): $(INF_LIB) $(EXTRACT_DIR)/$(LIB_NAME) $(KERNELS) alg.o psy.o

#TODO #1757: $(INF_LIB) is required because of the meta-data in the
# kernel - once this is fixed, $(INF_LIB) can be removed.
$(DRIVER_INIT).$(TYPE): $(KERNELS) $(DRIVER_INIT).o $(READ_KERNEL_DATA)
$(DRIVER_INIT).$(TYPE): $(KERNELS) $(DRIVER_INIT).o
$(F90) $(KERNELS) $(DRIVER_INIT).o -o $(DRIVER_INIT).$(TYPE) \
$(INF_LIB) $(READ_KERNEL_DATA) $(LDFLAGS)
$(INF_LIB) $(EXTRACT_DIR)/$(LIB_NAME) $(LDFLAGS)

#TODO #1757: $(INF_LIB) is required because of the meta-data in the
# kernel - once this is fixed, $(INF_LIB) can be removed.
$(DRIVER_UPDATE).$(TYPE): $(KERNELS) $(DRIVER_UPDATE).o $(READ_KERNEL_DATA)
$(DRIVER_UPDATE).$(TYPE): $(KERNELS) $(DRIVER_UPDATE).o
$(F90) $(KERNELS) $(DRIVER_UPDATE).o -o $(DRIVER_UPDATE).$(TYPE) \
$(INF_LIB) $(READ_KERNEL_DATA) $(LDFLAGS)
$(INF_LIB) $(EXTRACT_DIR)/$(LIB_NAME) $(LDFLAGS)

# The dl_esm_inf library
$(INF_LIB):
Expand All @@ -138,8 +135,6 @@ psy.o: $(KERNELS)
# directory will fail.
$(DRIVER_INIT).f90: psy.f90
$(DRIVER_UPDATE).f90: psy.f90
$(DRIVER_INIT).o: $(READ_KERNEL_DATA)
$(DRIVER_UPDATE).o: $(READ_KERNEL_DATA)

# Dependency to INF_LIB to make sure the mod file are available
$(KERNELS): $(INF_LIB)
Expand All @@ -152,10 +147,6 @@ $(KERNELS): $(INF_LIB)
$(EXTRACT_DIR)/lib_kernel_data_netcdf.a:
make -C $(EXTRACT_DIR)

$(READ_KERNEL_DATA):
make -C $(READ_DIR)

allclean: clean
make -C $(INF_DIR) clean
make -C $(EXTRACT_DIR) clean
make -C $(READ_DIR) clean
21 changes: 7 additions & 14 deletions examples/lfric/eg17/full_example_extract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GENERATED_FILES += driver-main-init driver-main-init.F90 \
F90 ?= gfortran
F90FLAGS ?= -Wall -g -ffree-line-length-none

OBJ = main_psy.o main_alg.o testkern_w0_kernel_mod.o
OBJ = main_psy.o main_alg.o testkern_w0_kernel_mod.o dummy_mod.o

ifeq ($(TYPE), netcdf)
EXTRACT_DIR ?= $(PSYROOT)/lib/extract/netcdf/lfric
Expand All @@ -71,7 +71,6 @@ endif
EXEC = extract.$(TYPE)
EXTRACT_NAME ?= _extract
EXTRACT_LIB = $(EXTRACT_DIR)/lib$(EXTRACT_NAME).a
READ_KERNEL_DATA_OBJ = $(EXTRACT_DIR)/../read_kernel_data_mod.o
LFRIC_PATH ?= $(PSYROOT)/src/psyclone/tests/test_files/dynamo0p3/infrastructure
LFRIC_NAME=lfric
LFRIC_LIB=$(LFRIC_PATH)/lib$(LFRIC_NAME).a
Expand Down Expand Up @@ -101,19 +100,16 @@ $(EXTRACT_LIB): $(LFRIC_LIB)
# Dependencies
main_psy.o: testkern_w0_kernel_mod.o $(EXTRACT_LIB) $(LFRIC_LIB)
main_alg.o: main_psy.o
testkern_w0_kernel_mod.o: $(LFRIC_LIB)
testkern_w0_kernel_mod.o: dummy_mod.o $(LFRIC_LIB)

driver-main-update: LFRIC_INCLUDE_FLAGS += -I $(EXTRACT_DIR)/..
driver-main-update: driver-main-update.o $(READ_KERNEL_DATA_OBJ)
driver-main-update: driver-main-update.o
$(F90) $(F90FLAGS) $(LFRIC_INCLUDE_FLAGS) driver-main-update.o \
$(LDFLAGS) -o driver-main-update
$(LDFLAGS) -o driver-main-update

driver-main-init: LFRIC_INCLUDE_FLAGS += -I $(EXTRACT_DIR)/..
driver-main-init: driver-main-init.o $(READ_KERNEL_DATA_OBJ)
driver-main-init: driver-main-init.o
$(F90) $(F90FLAGS) $(LFRIC_INCLUDE_FLAGS) driver-main-init.o \
$(LDFLAGS) -o driver-main-init

driver-main-update.o driver-main-init.o: $(READ_KERNEL_DATA_OBJ)
$(LDFLAGS) -o driver-main-init

%.o: %.F90
$(F90) $(F90FLAGS) $(LFRIC_INCLUDE_FLAGS) -c $<
Expand All @@ -126,12 +122,9 @@ driver-main-update.o driver-main-init.o: $(READ_KERNEL_DATA_OBJ)

main_alg.f90: main_psy.f90

$(READ_KERNEL_DATA_OBJ):
$(MAKE) -C $(EXTRACT_DIR)/..

%_psy.f90: %.x90
${PSYCLONE} -s ./extract_transform.py \
-d . -d $(EXTRACT_DIR) -d $(EXTRACT_DIR)/.. \
-d . -d $(EXTRACT_DIR) \
-d $(LFRIC_PATH) \
-nodm -opsy $*_psy.f90 -oalg $*_alg.f90 $<

Expand Down
67 changes: 67 additions & 0 deletions examples/lfric/eg17/full_example_extract/dummy_mod.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
! BSD 3-Clause License
!
! Copyright (c) 2023-2024, Science and Technology Facilities Council
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
!
! * Redistributions of source code must retain the above copyright notice, this
! list of conditions and the following disclaimer.
!
! * Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!
! * Neither the name of the copyright holder nor the names of its
! contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! -----------------------------------------------------------------------------
! Author J. Henrichs, Bureau of Meteorology

! This simple module is used to showcase and test the extraction of non-local
! module variables with the driver extraction.

arporter marked this conversation as resolved.
Show resolved Hide resolved
module dummy_mod
integer :: dummy_var1
real :: dummy_var2
real :: dummy_var3 = 3

public :: dummy_code

interface dummy_code
module procedure dummy_code_1, dummy_code_2
end interface

contains

subroutine dummy_code_1(a)
implicit none
integer :: a
dummy_var1 = dummy_var1 + 1
end subroutine dummy_code_1

subroutine dummy_code_2(a)
implicit none
real :: a
dummy_var1 = dummy_var1 + 1
end subroutine dummy_code_2

integer function dummy_func(a)
implicit none
integer :: a
dummy_func = a+1 + dummy_var2
end function dummy_func

end module dummy_mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
! Modified by J. Henrichs, Bureau of Meteorology
! Modified by I. Kavcic, Met Office


module testkern_w0_kernel_mod

use argument_mod
Expand All @@ -40,8 +41,15 @@ module testkern_w0_kernel_mod

use constants_mod

! This is used to showcase the ability of the kernel extraction
! to write and for the driver creation to read non-local module variables
! when importing them in the module scope
use dummy_mod, only: dummy_var1, dummy_code
arporter marked this conversation as resolved.
Show resolved Hide resolved

implicit none

integer, public :: some_other_var
integer, parameter :: some_other_const = 123
private

type, public, extends(kernel_type) :: testkern_w0_kernel_type
Expand All @@ -64,6 +72,10 @@ module testkern_w0_kernel_mod
subroutine testkern_w0_code(nlayers, fld1, fld2, chi1, chi2, chi3, &
some_logical, ndf_w0, undf_w0, map_w0)

! This is used to showcase the ability of the kernel extraction
! to write and for the driver creation to read non-local module
! variables when importing them in the kernel itself.
use dummy_mod, only: dummy_var2, dummy_var3, dummy_func, dummy_code
implicit none

integer(kind=i_def), intent(in) :: nlayers
Expand All @@ -75,12 +87,19 @@ subroutine testkern_w0_code(nlayers, fld1, fld2, chi1, chi2, chi3, &
integer(kind=i_def), dimension(ndf_w0) :: map_w0

integer(kind=i_def) :: i, k
real(kind=r_def) :: some_r

call dummy_code(1)
some_r = 0
do k=0, nlayers-1
do i=1, ndf_w0
fld1(map_w0(i)+k) = fld1(map_w0(i)+k) + fld2(map_w0(i)+k)
some_r = some_r + 1
fld1(map_w0(i)+k) = fld1(map_w0(i)+k) + fld2(map_w0(i)+k) &
+ dummy_func(i)
if (some_logical) then
fld1(map_w0(i)+k) = fld1(map_w0(i)+k) + 1
fld1(map_w0(i)+k) = fld1(map_w0(i)+k) + 1 + dummy_var1 + dummy_var2 &
+ some_other_var + some_r + dummy_var3 &
+ some_other_const
endif
end do
end do
Expand Down
1 change: 1 addition & 0 deletions lib/extract/netcdf/dl_esm_inf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
read_kernel_data_mod.f90
Loading
Loading