LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2006, 08:57 PM   #1
ArthurHuang
Member
 
Registered: Jan 2006
Posts: 174

Rep: Reputation: 30
One fortran programming problems.


Hi, in fortran 90, there is a sentense:

allocate( a(-10:10, 15:15,1,1) );

What's the dimension of a, three?
If I want to translate this into C, how can I write the malloc function.

Thanks a lot!
 
Old 03-26-2006, 09:56 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
It's been quite a while since I did any Fortran, but that looks like a one dimensional array, with 31 elements. On the other hand, to reference any of the 31 elements, you'd need to specify four indices, the last three being 15,1,1.

In C, something like float a[1][1][1][31]; would, I think, allocate the same amount of storage, and a macro like #define A[1,j,k,l]=a[l-1][k-1][j+15][i-15] would let you use A[i,15,1,1] to refer to a[0][0][0][i].

But just using float a[31]; and ignoring the last three indices seems simpler.

Of course, if you're using an allocate, you probably want a malloc in C, but that's fairly straightforward.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
Gnu Fortran versus Intel Fortran tomatoefish Linux - Software 3 02-20-2006 01:31 PM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM
Some programming problems frostmagic Programming 20 10-10-2003 10:31 AM
problems installing FORTRAN compiler in SuSeE 8.2 rich442 Linux - Software 0 06-25-2003 09:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration