|
[Sponsors] |
multi-dimensional dynamic array allocation for multi-block solver using fortran |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 24, 2012, 05:48 |
multi-dimensional dynamic array allocation for multi-block solver using fortran
|
#1 |
New Member
Manokaran K
Join Date: Sep 2011
Posts: 4
Rep Power: 15 |
I am converting my CFD solver to multi-block solver. I had used dynamic array allocation for the single block solver, but for multi-block, the dynamic array allocation syntax is not clear to me. I tried a sample code, but end up in error "Error: Expression at (1) must be scalar". I also don't know how to pass the multi dimensional allocated array to subroutines. Please, suggest solution, regards
common/iteration/nb integer, dimension (,allocatable::nib,njb,nkb real, dimension (:,:,:,,allocatable::x,y,z allocate (nib(nb),njb(nb),nkb(nb)) do l=1,nb ni=nib(l) nj=njb(l) nk=nkb(l) allocate (x(l,ni,nj,nk),y(l,ni,nj,nk),z(l,ni,nj,nk)) enddo call gridatt (x,y,z,nib,njb,nkb) deallocate(x,y,z,nib,njb,nkb) end c subroutine gridatt (x,y,z,nib,njb,nkb) common/iteration/nb integer, dimension (nb)::nib,njb,nkb real, dimension (nb,nib,njb,nkb)::x,y,z return end
__________________
mano |
|
June 24, 2012, 16:03 |
|
#2 |
Member
Mohammad Reza Hadian
Join Date: Mar 2009
Location: Yazd, Iran
Posts: 52
Rep Power: 17 |
you can not declare an array with variable values for different indexes. thry should be fixed values. i know in this way you waist some amount of memory but there is no way ( as i know). your code should be like this:
common/iteration/nb integer, dimension ( : ),allocatable::nib,njb,nkb real, dimension (:,:,:,: ),allocatable::x,y,z allocate (nib(nb),njb(nb),nkb(nb)) c calculate maximum value of ni, nj and nk in all blocks and store them in MaxNi,MaxNj and MaxNk respectively allocate(x(nb,MaxNi,MaxNj,MaxNk),y(nb,MaxNi,MaxNj, MaxNk),z(nb,MaxNi,MaxNj,MaxNk)) call gridatt (x,y,z,MaxNi,MaxNj,MaxNk) deallocate(x,y,z,nib,njb,nkb) end c subroutine gridatt (x,y,z,MaxNi,MaxNj,MaxNk) common/iteration/nb integer, dimension (nb)::MaxNi,MaxNj,MaxNk real, dimension (nb,MaxNi,MaxNj,MaxNk)::x,y,z return end |
|
June 25, 2012, 11:24 |
|
#3 |
New Member
Manokaran K
Join Date: Sep 2011
Posts: 4
Rep Power: 15 |
Thank you for your comments.
Well, your suggestion is to use maximum value in i,j,k direction from all blocks. It will work, but sometimes, if the block size varies drastically, this may not be optimum and giving the boundary conditions will be a tough job.
__________________
mano |
|
June 25, 2012, 11:50 |
|
#4 |
Member
Mohammad Reza Hadian
Join Date: Mar 2009
Location: Yazd, Iran
Posts: 52
Rep Power: 17 |
yes, you are right. but as i know there is no other way. if you want to use the memory efficiently, you should use one array and put the values of different blocks in continuous series. then you can access to any every variables of every block by knowing the size of its previous blocks. i think the following paper can help you in this way. note that the programming of this method is not easy.
Lien, F.S., Chen, W.L. and Leschziner,M.A. (1996). “A Multiblock Implementation of Non-Orthogonal Collocated Finite Volume Algorithm for Complex Turbulent Flows”, Int. J. Numer. Methods Fluids, 23, 567-588. |
|
June 25, 2012, 22:01 |
|
#5 |
New Member
Manokaran K
Join Date: Sep 2011
Posts: 4
Rep Power: 15 |
Thank you very much. Regards
__________________
mano |
|
Tags |
dynamic array, fortran, mult-block |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFX11 + Fortran compiler ? | Mohan | CFX | 20 | March 30, 2011 19:56 |
[Commercial meshers] Icem Mesh to Foam | jphandrigan | OpenFOAM Meshing & Mesh Conversion | 4 | March 9, 2010 03:58 |
compressible two phase flow in CFX4.4 | youngan | CFX | 0 | July 2, 2003 00:32 |