Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change rank of allocatable arrays

Status
Not open for further replies.

Rob321

Programmer
Feb 20, 2017
3
US
HI,

Say I have a 50x50 allocatable array and I want to change this to a 100x1 allocatable array. What is the best way to do this? I am using the reshape command but it does not work well with allocatable arrays.

This is a simple question and I suspect there is a simple solution.

My current block of code looks something like this:

do QindIC= 1, NqIC
allocate(q0p(NsFA(QindIC), NqIC))
do FAindIC= 1, NsFA(QindIC)
q0p(FAindIC, QindIC)= qfinalICT(QindIC)%qfinalICvalT(FAindIC, QindIC)
end do
q0pp= reshape(q0p, (/sum(NsFA:))), ppnull/))
deallocate(q0p)
end do

This results in a "segmentation fault - invalid memory reference" error. Any help would be much appreciated.

Please let me know what you think.

Thank you,

Robert
 
You have a 50 X 50 ARRAY OR 2500 ELEMENTS. You are attempting to reshape them into a 100 element array. How is that going to work?

Bill
Lead Application Developer
New York State, USA
 
That was a bad example. Either way, I solved the problem using the pack intrinsic function.

Thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top