Prev: Looking for some advice on string passing and dealing with hardcodedconstants
Next: Pointers to overlapping data as dummy argumemts
From: Vito on 12 May 2010 17:39 Hi to all, I am trying to search a solution of this problem. I use fortran to solve a set of equations in an iterative loop. My data are 12 matrixes like this COMPLEX*16 Z1(4096,2048) In each loop, after other operations, I need to perform a FFT calling an external library that needs the data as a single row vector. So in the statement part of my code I use the command EQUIVALENCE (X1,Z1) where X1 is a complex array 4096*2048. At the moment this is better I am able to do. Consider I typically have 5000 iterations of 12 complex matrixes with forward and bakward FFT. Now, I need to assign the dimension of the matrixes dynamically, so I can create the .exe and use an input file to determine the dimension of my problem, but the EQUIVALENCE statement is not usable with an allocable data like COMPLEX*16, allocatable :: Z1(:,:). I see in previous post I can use RESHAPE, or additional temporary variables, but I have here the double problem of a very big RAM memory needs and execution time. In fact, at the moment this problem uses 2-3 GB of RAM and the execution time are something like 24 hours. If I understand well, the use of RESHAPE or additional variable will double, at least, both RAM needs and execution time. I will be very grateful If anybody has any suggestion. Vito
From: glen herrmannsfeldt on 12 May 2010 18:39 Vito <vito.roppo(a)gmail.com> wrote: > I am trying to search a solution of this problem. > I use fortran to solve a set of equations in an iterative loop. > My data are 12 matrixes like this > COMPLEX*16 Z1(4096,2048) > In each loop, after other operations, I need to perform a FFT calling > an external library that needs the data as a single row vector. > So in the statement part of my code I use the command > EQUIVALENCE (X1,Z1) Except for the case of assumed shape (where the dummy array is dimensioned (:) or (:,:)) just put the two dimensional array name in the CALL statement. That was standard Fortran 66, and still is in 2003, and I believe 2008. Note that it is also often done between COMPLEX actual arrays and REAL dummy arrays. While the standard might not say that works, it usually does. > where X1 is a complex array 4096*2048. > At the moment this is better I am able to do. > Consider I typically have 5000 iterations of 12 complex matrixes with > forward and bakward FFT. > Now, I need to assign the dimension of the matrixes dynamically, > so I can create the .exe and use an input file to determine the > dimension of my problem, > but the EQUIVALENCE statement is not usable with an allocable data > like > COMPLEX*16, allocatable :: Z1(:,:). You can pass an assumed shape or allocatable array to an assumed size dummy. If you don't reallocate it in the FFT routine (and that would be unusual for FFT) then there is no reason to use an allocatable dummy. > I see in previous post I can use RESHAPE, or additional temporary > variables, but I have here the double problem of a very big RAM > memory needs and execution time. RESHAPE may or may not actually allocate a temporary array. It might just change the descriptor to describe the new array. > In fact, at the moment this problem uses 2-3 GB of RAM and the > execution time are something like 24 hours. > If I understand well, the use of RESHAPE or additional variable > will double, at least, both RAM needs and execution time. If you use the arguments to actually change the order of the array elements it is likely to need a temporary. As EQUIVALENCE doesn't do that, I will assume that you don't need to do that. In the case of an assumed shape dummy, using RESHAPE in the call, it shouldn't need to create a temporary. I haven't looked to see if any compilers actually do or not. You will find out fast (or slow if you have enough swap space) if it tries to allocate a 2GB temporary array. > I will be very grateful If anybody has any suggestion. Did you try the previous suggestions? -- glen
From: Gary L. Scott on 12 May 2010 19:58
On 5/12/2010 5:39 PM, glen herrmannsfeldt wrote: > Vito<vito.roppo(a)gmail.com> wrote: > >> I am trying to search a solution of this problem. >> I use fortran to solve a set of equations in an iterative loop. >> My data are 12 matrixes like this > >> COMPLEX*16 Z1(4096,2048) > >> In each loop, after other operations, I need to perform a FFT calling >> an external library that needs the data as a single row vector. >> So in the statement part of my code I use the command > >> EQUIVALENCE (X1,Z1) > > Except for the case of assumed shape (where the dummy array > is dimensioned (:) or (:,:)) just put the two dimensional array > name in the CALL statement. That was standard Fortran 66, and > still is in 2003, and I believe 2008. > > Note that it is also often done between COMPLEX actual arrays > and REAL dummy arrays. While the standard might not say that > works, it usually does. > >> where X1 is a complex array 4096*2048. >> At the moment this is better I am able to do. >> Consider I typically have 5000 iterations of 12 complex matrixes with >> forward and bakward FFT. >> Now, I need to assign the dimension of the matrixes dynamically, >> so I can create the .exe and use an input file to determine the >> dimension of my problem, >> but the EQUIVALENCE statement is not usable with an allocable data >> like > >> COMPLEX*16, allocatable :: Z1(:,:). > > You can pass an assumed shape or allocatable array to an assumed > size dummy. If you don't reallocate it in the FFT routine > (and that would be unusual for FFT) then there is no reason to > use an allocatable dummy. > >> I see in previous post I can use RESHAPE, or additional temporary >> variables, but I have here the double problem of a very big RAM >> memory needs and execution time. > > RESHAPE may or may not actually allocate a temporary array. > It might just change the descriptor to describe the new array. > >> In fact, at the moment this problem uses 2-3 GB of RAM and the >> execution time are something like 24 hours. >> If I understand well, the use of RESHAPE or additional variable >> will double, at least, both RAM needs and execution time. > > If you use the arguments to actually change the order of the > array elements it is likely to need a temporary. As EQUIVALENCE > doesn't do that, I will assume that you don't need to do that. > > In the case of an assumed shape dummy, using RESHAPE in the > call, it shouldn't need to create a temporary. I haven't looked > to see if any compilers actually do or not. You will find out > fast (or slow if you have enough swap space) if it tries to > allocate a 2GB temporary array. > >> I will be very grateful If anybody has any suggestion. > > Did you try the previous suggestions? > > -- glen The other suggestions aren't showing up on my supernews server...they were on Google earlier when I looked though. |