@FortranFan
s = ( allocated(x) ? size(x) : expr )
IMHO, that’s a poor way since it is verbose enough when used for each allocatable array. In addition, it could not be very easy to be used in other array-related functions such as lbound, ubound, etc. As you have already mentioned, I also believe that expr
is really important to get defined/set correctly to avoid any misleading outcome. From what I have seen, it would not be very easy. Unfortunately, Fortran does not provide any generic escape value such as undefined
, NaN
, etc, if I am not wrong.
@FortranFan
Here is the basic truth.
As regards RTFM, let me ask to all: How many of you have read the manual of your new car before driving it from the show room to your home? How many of you have read the manual of the coffee machine found in the company you work for? We all use the common sense to use and we expect to get reasonable “outcomes/results” from that object/device/apparatus/etc.
As regards Practitioners, all of us, our families, our friends, etc we enjoy a safe environment to work, play, etc. But when we ask that from a programming language we become annoying persons.
@PierU
Any function related to array
which is unallocated should not be authorised. We do agree on that in different ways. I say “an error should be raised”, others say “Don’t do that because it is not legal as per spec”. In addition, size()
and any other function’s result should not be used for checking if an array is allocated. I just get a memory (last) number (which is the worst of all) which confuses.
efficiency: …
SAFETY FIRST! Next, the rest ones. Especially, in what is published. Otherwise, we keep it in the drawer, laptop, pc, office, laboratory, etc and do not publish it or advertise it.
@everythingfunctional
There is no such thing as the size of an unallocated array … if the code is invalid, it’s allowed to return whatever it wants (or set your computer on fire). You really are asking “How big is this thing I don’t have?”
If the code is invalid language “tools” should alert AND NEXT return whatever it wants!
A quick example how “wrong” you are. You buy an electronic scale. You switch it on and it displays “0”. You “allocate” an apple on it; it displays “50” grams. Next, you remove/deallocate the apple. What do you expect to see on the display? If you continue seeing “50” you will start wondering that something is wrong. Thousand such examples. Feedback is important!
@certik
… Debug build and Release build …
Tfti. I use fpm
which works by default in “debug” profile since I have not set any --flag
. Is it possible to point the importance of the debug
by upgrading debug
to a sub-command with level (eg 1-6) option covering from the slackest (least verbose) to the strictest (most verbose). I will open an issue
requesting that in github.
@kargl
This is definitive. Nonconforming code can produce anything.
So, the scale should display anything when nothing is placed/“allocated” on it?
@certik
And GFortran does, in this case. So there is no problem, as long as we have good compilers.
That’s great! Please, do your best to properly adjust/regulate fpm
debug options because YOU (as instigate/abettor ) and I (as inexperienced practitioner ) have caused a stir w/o reason (50 messages posted so far)!
What about using other array-related functions? Does the compiler give an error when array is not allocated yet?
@certik
(I actually just use -fcheck=all
)
Does fpm
debug profile use -fcheck=all
? Because I have never noticed such an error message on my screen so far.
@all Thanks a lot for your participation and time in our discussion!