Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development Tools (Compilers, Debuggers, Profilers & Analyzers)
- Intel® Fortran Compiler
- Trying to understand how dimension works

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

zechar__nathan

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-07-2020
04:09 PM

2 Views

Trying to understand how dimension works

Hello, I'm trying to understand the difference between the following lines of code, as the output appears to be the same.

Version 1

complex(kind=c_double_complex), dimension(1:4,1:8,1:16) :: Z

Version 2

complex(kind=c_double_complex), dimension(4,8,16) :: Z

When I print Z the output is exactly the same. Complex, all zeros.

print *, Z

I'm transcribing this code into another language, and I'm trying to understand why "dimension(1:4,1:8,1:16)" is used instead of "dimension(4,8,16)"

4 Replies

Highlighted
##

In Fortran the start index is 1 by default. The 1:4 is the same as 4. The 1: is redundant. I would guess the coder was more familiar with a language where 0 is the start index.....

andrew_4619

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-09-2020
12:37 AM

2 Views

In Fortran the start index is

Highlighted
##

Or, the coder employed 0-base arrays in many places elsewhere in the code, and wanted to emphasize that in this place a different base index was being used. We would have to see the whole code to judge.

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-09-2020
04:26 AM

2 Views

Or, the coder employed 0-base

Highlighted
##

JohnNichols

New Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-09-2020
10:40 AM

2 Views

!

! real*4 d(0:nx,0:ny),x(0:nx),y(0:ny),z(1:nc) real*4 trace(0:nx,0:ny), sum(0:nx),XTrace(0:nx,0:ny) real*4 traceR(0:nx,0:ny), XRTrace(0:nx,0:ny) real*4 x1,y1,x2,y2 real*4 xdelta, ydelta, x4,y4,x3,y3, maxX, maxY real*4 zmax,zmin, dist integer*4 i,j, count, counter, k

This is a sample from the program CONREC. Conrec was developed and published in BYTE in about 1986

!

! The following is a simplistic application of the CONREC routine.

! A mathematical function is evaluated over a regular grid of points

! on a computer raster graphics screen.

!

! Paul D. Bourke

!

The original code was not in Fortran and I translated the code into Fortran, I kept the zero indexing so I could check the code easily. There is a web page where this routine has been translated in many languages. I prefer a regular array instead of the triangles that can be a beast.

Each language has a standard index start - so C is usually zero. Thankfully LISP is easier to use but is a beast of language to learn.

You need to be careful - although in Fortran not using a standard Z(30) would be unusual -- but each to their own.

Highlighted
##

JohnNichols

New Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-09-2020
11:08 AM

2 Views

I was mistaken -- I apologize

I was mistaken -- I apologize to Paul Bourke who provided the CONREC code in Fortran -- I translated his Fortran into C#.

I did add a DXF generator to the CONREC program in Fortran.

For more complete information about compiler optimizations, see our Optimization Notice.