-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add array checking support for check
interface
#20
base: main
Are you sure you want to change the base?
Conversation
The select type logic is not really that much shorter than having several duplicated procedures for dealing with one-dimensional arrays. The test failures might be related to a routine which is guarded in the fpm case ( |
item => array | ||
do i = 1, size(array) | ||
select type (item) | ||
type is (integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you would agree to add fypp
in this project, but I think it could be helpful for such a structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it can be made work with all three build system (fpm, meson and CMake), I would be fine, however there is currently no way to support this intrinsically with fpm.
34248e5
to
f08ef22
Compare
f08ef22
to
41d8652
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20 +/- ##
==========================================
- Coverage 71.51% 66.41% -5.11%
==========================================
Files 2 2
Lines 481 655 +174
Branches 296 436 +140
==========================================
+ Hits 344 435 +91
Misses 23 23
- Partials 114 197 +83 ☔ View full report in Codecov by Sentry. |
At the beginning, I tried to implement multiple procedures for dealing with one-dimensional arrays, which probably added 600+ lines of code for By the way, now CI says: only Starting character ... (86/89)
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f5170f1cd57 in ???
#1 0x7f5170f1bfbd in ???
#2 0x7f51707ad0bf in ???
#3 0x7f51708f5764 in ???
#4 0x406bc1 in __testdrive_MOD_check_string
at /src/test_drive.F90:1561
#5 0x40284c in __testdrive_MOD_check_double_array
at /src/test_drive.F90:2099
#6 0x40e02f in test_char
at /test/test_check_array.F90:1434
#7 0x40cb26 in run_unittest
at /test/test_drive.F90:402
#8 0x40d20f in __testdrive_MOD_run_testsuite
at /test/test_drive.F90:346
#9 0x4202d2 in tester
at /test/main.f90:62
#10 0x4203e5 in main
at /test/main.f90:18 |
@awvwgk, @jvdp1, maybe the latest commit will make us more satisfied:
It would be nice to see that call check(error, reshape(array, [size(array)], expected, ...) PS. In terms of efficiency, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a check for the shape of the arrays to avoid out-of-bounds access in case the expected
array is larger than the actual
or elements remain unchecked in case the actual
array is larger.
Thank you for review. This commit has added a check on the size of the array. Since my native language is not English, if there are some mistakes in the text, please point them out. summary:
(Hope it doesn't add too much code burden.) |
Hello. Just want to state that I find this new feature quite useful, actually a must. I am using it, with success, in my own code since yesterday (I was about to write something similar myself at least for dp arrays). |
There is nothing fundamentally blocking this patch, if you want to move this forward, feel free to help out with the code review. |
@awvwgk, I only have a superficial understanding of the PR/review/approval process. But there is a first time for everything, and I am happy to learn. Could I ask you to point me in the right direction? How exactly can I help? How do I start the process? Thanks... and sorry for the beginner questions. |
My main concern is that although the current solution caters to the coding paradigm of Not supporting arrays is fine if we stick to |
@zoziha, for sure, this new feature adds a non-negligible number of new functions and code lines, but IMO this burden is outweighed by the benefits of the feature itself. Moreover, IMO, the maintainability issue is not really due to this new addition, but something that was already there. For instance, the functions
Note sure if this change is of any computational benefit, but it does seem more explicit. |
@HugoMVale, yes, I agree with you. In the existing Fortran grammar, if some generic features are to be supported, certain trade-offs are often required. |
Description
Method: In order to avoid introducing double the number of
check
interfaces in testdrive for array checking, this PR uses class(*) to characterize the parameters. (+238 lines of code)To close #19 , array checking is supported in this PR, but two problems are found, mainly ingfortran <= 10
,Problem 1:gfortran <= 10
seems to have limitations in the support ofclass(*)
andassociate(pointer => array)
;Problem 2: Thereshape
ofgfortran <= 10
may have adaptability problems withclass(*)
.After some adjustments, the above two problems are avoided, the content of this PR can theoretically passgfortran >= 7
compilers. This means that if we want to support array checking and there is no better way, we need to remove support forgfortran 6
and add support forgfortran 12
.Help: But I can't solve the problem withcmake
andmeson
config files, their CI always tells me that something went wrong, hope to get help, @awvwgk .(Solved)