hi there,
I have what is probably a very stupid question :
why use DIMENSION statements to define arrays, when simply writing indices
seems to be sufficient ?
or is it ?
thanks
G.
|
|
0
|
|
|
|
Reply
|
tperzo (4)
|
9/13/2004 1:52:05 PM |
|
news <tperzo@wanadoo.fr> wrote:
>hi there,
>I have what is probably a very stupid question :
>why use DIMENSION statements to define arrays, when simply writing indices
>seems to be sufficient ?
>or is it ?
I generally agree with you and rarely use DIMENSION statements. But they
can be convenient if you have several arrays with the same shape:
real, dimension(2,5) :: a,b,c,d
is more concise and easier to modify than
real :: a(2,5),b(2,5),c(2,5),d(2,5)
One could use DIMENSION when there are several ALLOCATABLE arrays with the
same number of dimensions, writing the slightly shorter
real, allocatable, dimension(:,:,:) :: a,b,c
instead of
real, allocatable :: a(:,:,:),b(:,:,:),c(:,:,:)
I think Walt Brainerd, one of the creators of the F (Fortran 95 subset) language,
which requires DIMENSION, has said that writing DIMENSION explicitly makes
it easier to find array declarations in code.
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
|
|
0
|
|
|
|
Reply
|
beliavsky (2207)
|
9/13/2004 12:13:38 PM
|
|
"beliavsky@aol.com" <beliavsky@127.0.0.1:7501> wrote in message
news:41458ef2$1_1@127.0.0.1...
>
> news <tperzo@wanadoo.fr> wrote:
> >hi there,
> >I have what is probably a very stupid question :
> >why use DIMENSION statements to define arrays, when simply writing
indices
> >seems to be sufficient ?
> >or is it ?
>
> I generally agree with you and rarely use DIMENSION statements. But they
> can be convenient if you have several arrays with the same shape:
>
> real, dimension(2,5) :: a,b,c,d
>
etc.
Correct, but that's not a DIMENSION statement, that's a DIMENSION attribute.
I think OP may have meant
DIMENSION a(2,5),b(2,5),c(2,5),d(2,5)
which, as we all know, in the absence of an IMPLICIT NONE statement, can
lead one to forget the type specification, with potentially disastrous
consequences.
Regards,
Mike Metcalf
|
|
0
|
|
|
|
Reply
|
michael.metcalf (122)
|
9/13/2004 12:47:28 PM
|
|
On Mon, 13 Sep 2004 13:47:28 +0100, "Michael Metcalf"
<michael.metcalf@t-online.de> wrote:
[snip]
>DIMENSION a(2,5),b(2,5),c(2,5),d(2,5)
>
>which, as we all know, in the absence of an IMPLICIT NONE statement, can
>lead one to forget the type specification, with potentially disastrous
>consequences.
But in the absence of IMPLICIT NONE, those are all real. No need to
look back at the top of the program to see what they are.
Ken Plotkin
|
|
0
|
|
|
|
Reply
|
kplotkin (368)
|
9/13/2004 11:42:48 PM
|
|
Ken Plotkin <kplotkin@nospam-cox.net> wrote in message news:<31cck0t3d3aesbkg1tmcqeotto62p4q7tk@4ax.com>...
> On Mon, 13 Sep 2004 13:47:28 +0100, "Michael Metcalf"
> <michael.metcalf@t-online.de> wrote:
>
> [snip]
> >DIMENSION a(2,5),b(2,5),c(2,5),d(2,5)
> >
> >which, as we all know, in the absence of an IMPLICIT NONE statement, can
> >lead one to forget the type specification, with potentially disastrous
> >consequences.
>
> But in the absence of IMPLICIT NONE, those are all real. No need to
> look back at the top of the program to see what they are.
>
> Ken Plotkin
For the program
integer a
dimension a(2)
end
you DO need to look at the top of the program to know what kind of
variable 'a' is. By writing
integer a(2)
end
the information about 'a' is in one place. One wouldn't use 'a' as an
integer variable in a real program, but I think it is better to
localize information by using REAL, INTEGER, CHARACTER, or LOGICAL in
array declarations.
|
|
0
|
|
|
|
Reply
|
beliavsky (2207)
|
9/14/2004 1:00:56 PM
|
|
In article <31cck0t3d3aesbkg1tmcqeotto62p4q7tk@4ax.com>, Ken Plotkin
<kplotkin@nospam-cox.net> writes
>On Mon, 13 Sep 2004 13:47:28 +0100, "Michael Metcalf"
><michael.metcalf@t-online.de> wrote:
>
>[snip]
>>DIMENSION a(2,5),b(2,5),c(2,5),d(2,5)
>>
>>which, as we all know, in the absence of an IMPLICIT NONE statement, can
>>lead one to forget the type specification, with potentially disastrous
>>consequences.
>
>But in the absence of IMPLICIT NONE, those are all real. No need to
>look back at the top of the program to see what they are.
>
>Ken Plotkin
>
The compiler knows they are real. We have no way of telling, other than
by trusting the programmer to have self-imposed coding standards for
variable names, whether they should have been double precision, logical
or even character. It's much easier to forget to put a declaration in
than it is to type the wrong one, and without IMPLICIT NONE, almost
impossible to detect.
Catherine.
--
Catherine Rees Lay
To email me, use my first name in front of the "at".
|
|
0
|
|
|
|
Reply
|
spamtrap9533 (138)
|
9/15/2004 8:40:07 AM
|
|
beliavsky@aol.com wrote:
(snip)
> integer a(2)
> the information about 'a' is in one place. One wouldn't use 'a' as an
> integer variable in a real program, but I think it is better to
> localize information by using REAL, INTEGER, CHARACTER, or LOGICAL in
> array declarations.
Well, a could be an INTEGER variable in a program that only
used integer variables. I know a program that started out
INTEGERA,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
There is some advantage to using I though N to start
variable names, even in languages without Fortran's type rules.
-- glen
|
|
0
|
|
|
|
Reply
|
gah (12236)
|
9/16/2004 4:48:50 AM
|
|
In article <RW82d.97838$3l3.71366@attbi_s03>, glen herrmannsfeldt
<gah@ugcs.caltech.edu> writes
>beliavsky@aol.com wrote:
>
>(snip)
>
>> integer a(2)
>
>> the information about 'a' is in one place. One wouldn't use 'a' as an
>> integer variable in a real program, but I think it is better to
>> localize information by using REAL, INTEGER, CHARACTER, or LOGICAL in
>> array declarations.
>
>Well, a could be an INTEGER variable in a program that only
>used integer variables. I know a program that started out
>
> INTEGERA,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
>
>There is some advantage to using I though N to start
>variable names, even in languages without Fortran's type rules.
>
>-- glen
>
I first learnt to program aged about 12, in BASIC on a ZX81. At the time
I thought it strange that all the sample programs used
FOR I = 1 TO N
It took another 9 years before I found out where it came from!
Catherine.
--
Catherine Rees Lay
To email me, use my first name in front of the "at".
|
|
0
|
|
|
|
Reply
|
spamtrap9533 (138)
|
9/21/2004 10:09:41 AM
|
|
|
7 Replies
31 Views
(page loaded in 0.133 seconds)
Similiar Articles: Dimensioning, line selection question - comp.cad.solidworks ...I am having trouble selecting lines in a drawing when dimensioning. When I 'hover" over a line with the mouse, I don't get any graphical feedback from... Changing Dimension Text - comp.cad.microstationI'm new at programing How would I select the text I want to change ... Changing Dimension Text - comp.cad.microstation... Post Question | Groups ... comp.cad ... "inspection dimensions" - comp.cad.solidworksI know that you can check a box to put an oval around a dimension to designate it as ... is really a general drafting question, rather than a Solidworks "how-to" question. Dimensioning a Hexagon - comp.cad.solidworksIn the event that this is a dumb question, this group has my apologies. I am always having a problem dimensioning a hexagon. It seems that if I add m... Modifying dimension font size - comp.cad.solidworksHi, This is probably a really simple question (as I do a drawing about once a year). How do I modify the size of a dimensions text globally? (tried... convert 3D matrix into 2D - comp.soft-sys.matlabHi, i still cant find a way to convert a 3 dimension matrix (1x10x3) into 2 dimension ... Respected Sir, We have gone through the MATLAB site and found you asking query ... Dimension to quadrant? - comp.cad.solidworksWhen in a sketch, I cannot figure out how to dimension to an arc's quadrant. ... Post Question | Groups | ... Dimension diameter in detail view - comp.cad.solidworksI'm looking to add a diameter or radius dimension to my detail view. The center line ... Post Question | Groups | ... Dimension text display in sketches - comp.cad.solidworks ...... Post Question | Groups | ... This is how dimension text appears when you disable the setting in tools, options ... Query: How to add a checkbox control in Tab [ Win 32 project, None ...Box size around Basic dimensions - comp.cad.solidworks Query: How to add a checkbox control in Tab [ Win 32 project, None ... double clicked it step 3: increased size of ... Download: Analysis Services Many-to-Many Dimensions: Query ...This best practices white paper discusses three many-to-many query performance optimization techniques, including how to implement them, and the performance testing ... Microsoft OLAP by Mosha Pasumansky : Querying dimensions in MDXIn this article we will discuss and evaluate different methods Analysis Services 2005 provides for accessing dimension members. Requirements, flexibility and ... 7/25/2012 3:36:58 AM
|