Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIST_DETACH_AND_DESTROY #178

Open
lorenzo-mechbau opened this issue May 22, 2019 · 2 comments
Open

LIST_DETACH_AND_DESTROY #178

lorenzo-mechbau opened this issue May 22, 2019 · 2 comments

Comments

@lorenzo-mechbau
Copy link

Since the returned array could contain inconsistent values if LIST%NUMBER_IN_LIST /= LIST%SIZE I added the line
LIST_VALUES(:)=LIST_VALUES(1:NUMBER_IN_LIST)
or
LIST_VALUES(:,:)=LIST_VALUES(:,1:NUMBER_IN_LIST)
after the CALL MOVE_ALLOC(...).

@chrispbradley
Copy link
Member

I'm not sure what the above is trying to do? In general the LIST_VALUES size will be larger than the number in the list. Thus it maybe that the above lines result in an error as the left and right sides don't conform? It will also involve a copy of all the data to itself? When the list is returned the user should only access the 1:numberInList elements?

@lorenzo-mechbau
Copy link
Author

First of all, my bad, the correct lines are without (:) or (:,:):
LIST_VALUES=LIST_VALUES(1:NUMBER_IN_LIST)
I found this trick in my Fortran tutorial under "adjusting an allocatable array" (picture attached).

If the returned array is larger than numberInList, then it could be possible to access elements that have no meaning. As you wrote, one should be very careful to access only the 1:numberInList elements. A workaround that I see at some places is:
CALL LIST_DETACH_AND_DESTROY(BoundaryPlaneNodesList,NumberBoundaryPlaneNodes,IntegerArray,&
& ERR,ERROR,*999)
BoundaryPlaneNodes = IntegerArray(1:NumberBoundaryPlaneNodes)
DEALLOCATE(IntegerArray)
But that requires these two additional lines at every call, and an additional array.

20190523_111336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants