CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

A problem in FORTRAN programming

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2006, 01:05
Default A problem in FORTRAN programming
  #1
Behafarid
Guest
 
Posts: n/a
Hello friends. I have a problem in FORTRAN programming. I need to divide a larg zone into several parts but I can't define a matrix bigger than (4*1600*500) because the program fails and There is not any message to understand the reason of the error. I realy dont know what I have to do. PLEASE HELP ME. Thank you very much. By.
  Reply With Quote

Old   August 15, 2006, 07:27
Default Re: A problem in FORTRAN programming
  #2
TG
Guest
 
Posts: n/a
You are probably having a memory problem.

1)put the matrix into its own named common block

2)If that does not work, you might try building it as a 64bit code.
  Reply With Quote

Old   August 16, 2006, 05:52
Default Re: A problem in FORTRAN programming
  #3
Behafarid
Guest
 
Posts: n/a
Hello.

Thank you very much for your help but I didn't understand what exactly I have to do know. Please explain me more. As I asked my friends, It is a common problem in CFD programming but none of them could help me. Thank again.

Best regards. Behafarid
  Reply With Quote

Old   August 16, 2006, 07:39
Default Re: A problem in FORTRAN programming
  #4
peter
Guest
 
Posts: n/a
what is your compiler and platform and your physical memory size, i think it is not serious problem and resolved very easily.
  Reply With Quote

Old   August 16, 2006, 11:11
Default Re: A problem in FORTRAN programming
  #5
Renato.
Guest
 
Posts: n/a
First of all, let me do a simple calculation:

4*1600*500 = 3200000 coeficients

assuming double precision (8 bytes per coeficient) -- and that you're not spending more memory in other parts of your program -- you'll need

3200000 * 8 = 25600000 Bytes

or about 24.4 MBytes

(if I'm not wrong in my calc) It doesn't seem to be hard allocate such array.

Is this array inside a subroutine? You can be running into stack size problems.

Have you tried to allocate this array statically or dynamically?

Regards

Renato.

  Reply With Quote

Old   August 16, 2006, 12:09
Default Re: A problem in FORTRAN programming
  #6
Steve
Guest
 
Posts: n/a
Your problem is almost certainly stack size related. If you delare a variable inside a function, it'll use stack memory unless forced to use heap. To make it use heap memory, make it static. (e.g. in a COMMON block, defined in a DATA statement).
  Reply With Quote

Old   August 16, 2006, 13:16
Default Re: A problem in FORTRAN programming
  #7
Renato.
Guest
 
Posts: n/a
Try the following examples (using Fortran 90 sintax)

program foo real*8, allocatable :: a( n = 4*1600*500 allocate(a(n)) call SomeRoutine(a,n) deallocate(a) end program

subroutine SomeRoutine(a,n) ! You must avoid the use of the array size here. It always causes stack problems real*8 :: a(1) ... end subroutine

! --- END OF THE FIRST EXAMPLE ---

The same thing could be done with modules

module SomeData real*8, allocatable :: a( end module SomeData

program foo use SomeData n = 4*1600*500 allocate(a(n)) call SomeRoutine deallocate(a) end program

subroutine SomeRoutine use SomeData ... end subroutine

! --- END OF THE SECOND EXAMPLE ---

Here the array "a" is made accessible through the use of the module

Good lucky ;o)

Renato.

  Reply With Quote

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
flow driven problem - fortran Matjaz CFX 4 April 11, 2011 14:52
fortran code problem ztdep Main CFD Forum 5 September 8, 2009 05:22
Fortran problem MM Main CFD Forum 8 June 12, 2007 10:27
C++ fortran mixed programming: allocatable array vito Main CFD Forum 1 April 19, 2005 12:11
'C' or FORTRAN or 'C++' Yogesh Talekar Main CFD Forum 20 October 21, 1999 05:00


All times are GMT -4. The time now is 03:45.