CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Dynamical memory allocation for multiblock? (http://www.cfd-online.com/Forums/main/4737-dynamical-memory-allocation-multiblock.html)

peter.zhao May 16, 2002 04:49

Dynamical memory allocation for multiblock?
 
Dear everyone:

I want to use memory dynamical allocation of Fortran90 for multiblock calculation in order to save memory, but I encounter a problem. As for coordinates of every block, if I use the below statement,

real,allocatable::x(:,:,:,:)

allocate(nblock,ni,nj,nk,stat=err)

where nblock denotes number of blocks,ni,nj,nk are the dimension of a block. I must allocate same dimension ni,nj and nk for every block, which leads to redundant memory allocation especially when the differences of sizes of blocks are very remarkable.

Does anyone have a better method to deal with this situation? All comments are appreciated!

Thanks in advance.

Petri Majander May 16, 2002 07:22

Re: Dynamical memory allocation for multiblock?
 
Hello !

I think that it is a common practise to allocate the variables as one-dimensional table(s). This way you do not need to waste memory space. I use 1-D tables in the whole code but it is possible to use 3-D tables in the subroutines even if the memory space is allocated as 1-D table(s) in the main program.

Best regards

Petri M

peter.zhao May 20, 2002 05:58

Re: Dynamical memory allocation for multiblock?
 
Petri Majander, Thank you very much!


All times are GMT -4. The time now is 23:33.