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

Hi, this isnt really a compiler related question but rather a general fortran question, i have a piece of code that my friend has sent me and in doing so he does this peice of code in which he allocates a bc condition to a whole row but the way in which he does this is confusing because hes write u(:,1) = 20 and u(:,ny) = 40 in which he gets the first row to be 20 and the top or the last row to be 40. Im confused because fortran is a col-maj indexing which means that it should be u(1,:) = 20 for the bottom and u(ny,:) = 40 for the last row.

https://gyazo.com/9ac5341f1010ce7e656580107f0fad7b

https://gyazo.com/5a4b07f4e27617c95a4b513bba8a3149

https://gyazo.com/5bd22ffabb986b4b4e3ffb779edaaf1c

Link Copied

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

The subscript convention for two-dimensional arrays is the same in many programming languages as in linear algebra. The first index, starting with 1, is the row number, and the second index is the column number. Thus, u(:,1) is the first column and u(:,ny) is the last column. Row 1 is written at the 'top', and column 1 is written at the left, again as in linear algebra.

Different conventions may be used for screen pixel coordinates, etc.

The question of "row-major" or "column-major" arises only when one tries to map a 2-D array to a 1-D array.

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

The question of "row-major" or "column-major" arises only when one tries to map a 2-D array to a 1-D array.

This was a real problem in the 70's when we had limited memory and people often used a single vector to hold a lot of the data and not have a lot of wasted zeros

You would see really weird indexing loops

I undid one of those a few years ago for some 1970 code and it takes days.

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

You appear to solving a heat problem on a sheet. if you matrix is square then the two solutions left to right or down to up will be the same if you have one edge cold and the opposite edge hot, so setting the boundary conditions relies on knowing how you assigned them in the first place.

You just have to understand your boundary conditions.

1 1 1

- --------

40 40 40

is the same problem as

1 - 40

1 - 40

1 - 40

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

if the second graph is the answer - I would have a deal of difficulty accepting that answer as a long term solution - I assume the problem has a boundary on the left and the right that does not allow heat flow

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

Yes you are right there are neumann bcs on all edges except for the top and bottom edges which have dirichlet bcs of 20 and 40. im still trying to make sense of this in my mind cause i cant get over the fact that fortran is supposed to be col-maj.

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

I would stop worry about the column major stuff, you are reading to much into what you have been taught and not enough into trust your gut and see what happens.

Your solution as color coded is something you need to look at and ask yourself does it look correct. The results do not look correct. There are four internal corners, these map one line of constant temp at the top onto the top of the web line, the lengths in between vary so unless you have some sort of weird material the constant heat contours should be elliptical or some such shape and not straight lines.

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

Coco, if you have Neumann B.C. on the left and right, and the beam is very long (in the z-direction), the temperature distribution is one-dimensional. The temperature varies linearly from 20 at one flange to 40 at the other. No computer is needed to solve such a 1-D problem.

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

@Coco ,

Given what you posted, "this isnt really a compiler related question but rather a general fortran question ..", please also consider this Fortran Discourse site for wider feedback on general Fortran related topics:

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

glad to see "also" in your answer. Even though this is the Intel Fortran forum, it's also a great place to ask generic Fortran questions given the high activity of experts in the forum.

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