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

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)"

Link Copied

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

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.....

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

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.

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

! 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.

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

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.

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