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

NAG compiler complains when swap function is called on identical inputs #397

Closed
ekluzek opened this issue Jun 3, 2023 · 2 comments · Fixed by #391
Closed

NAG compiler complains when swap function is called on identical inputs #397

ekluzek opened this issue Jun 3, 2023 · 2 comments · Fixed by #391
Labels

Comments

@ekluzek
Copy link
Collaborator

ekluzek commented Jun 3, 2023

The NAG compiler on izumi complains about the following in nr_utils.f90

 ! private subroutine
 SUBROUTINE swap(a,b)
 INTEGER(I4B), INTENT(INOUT) :: a,b
 INTEGER(I4B) :: dum
 dum=a
 a=b
 b=dum
 END SUBROUTINE swap

It complains about the change in a dummy argument changing another dummy argument at the same time.

There must be some way to override this protection or maybe there is an intrinsic that does this same thing?

Completion(send) Runtime Error: /fs/cgd/data0/erik/ctsm_worktree/mizuroute/components/mizuRoute/route/build/src/nr_utils.f90, line 163: Assignment to A affects dummy argument B
Program terminated by fatal error
/fs/cgd/data0

@ekluzek ekluzek added the bug label Jun 3, 2023
@ekluzek
Copy link
Collaborator Author

ekluzek commented Jun 4, 2023

This is because of the -C=alias option for the nag compiler. In the makefile we have -C=all, which turns it and other compiler checking options on.

I tried adding the "volatile" attribute and that still aborted the same way.

@ekluzek
Copy link
Collaborator Author

ekluzek commented Jun 5, 2023

OK, it turns out the problem isn't the swap function itself, it's if the swap function is called with arguments that are the same (i.e. a==b). In this case the swap would be OK, but it doesn't really need to be done. So the change needed is to NOT call swap when a==b.

@ekluzek ekluzek changed the title NAG compiler doesn't like swap function NAG compiler complains when swap function is called on identical inputs Jun 5, 2023
ekluzek added a commit to ekluzek/mizuRoute that referenced this issue Jun 5, 2023
@ekluzek ekluzek linked a pull request Jun 5, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants