FUNCTION attribute conflicts with SUBROUTINE attribute

In summary, The conversation discusses the use of Runge Kutta with adaptive stepsize from numerical recipes, and the failure messages that occurred when rewriting the code. The issue was traced to a problem with the calling of the function 'derivs', and it was determined that the declaration for the subroutine should be changed to 'external :: derivs'. This solution successfully resolved the problem.
  • #1
Vrbic
407
18
Hello, I'm trying to use Runge Kutta with adaptive stepsize from numerical recipes(page 742, https://websites.pmc.ucsc.edu/~fnimmo/eart290c_17/NumericalRecipesinF77.pdf ). I rewrote code but I have got failure messages both in an attachment. If I cut this subroutine everything is fine also this failure are independent on a definition of function 'derivs' which is causing the problem in calling.
Thank you for any advice.
 

Attachments

  • screen.png
    screen.png
    18.4 KB · Views: 539
  • screen1.png
    screen1.png
    26.7 KB · Views: 360
Technology news on Phys.org
  • #2
Your first image is too small to read. Looking at the second one, in rkck the declaration
Fortran:
double precision, external :: derivs
would be valid for a function, not a subroutine. it should be simply
Fortran:
external :: derivs
 
  • #3
DrClaude said:
Your first image is too small to read. Looking at the second one, in rkck the declaration
Fortran:
double precision, external :: derivs
would be valid for a function, not a subroutine. it should be simply
Fortran:
external :: derivs
Good to know,
Thank you! SOLVED
 

Related to FUNCTION attribute conflicts with SUBROUTINE attribute

1. What does it mean when a function attribute conflicts with a subroutine attribute?

When a function attribute and a subroutine attribute conflict, it means that there is a mismatch between the type of operation being performed and the type of data being used. Functions are used to return a single value, while subroutines are used to perform a series of actions without returning a value. So if a function attribute is used for a subroutine or vice versa, there is a conflict.

2. Why is it important to avoid conflicts between function and subroutine attributes?

It is important to avoid conflicts between function and subroutine attributes because it can lead to errors in the code and unexpected results. The compiler will not be able to correctly interpret the code, resulting in incorrect outputs or even crashing of the program. It is important to understand the purpose and correct usage of each attribute in order to avoid conflicts.

3. How can I resolve a function and subroutine attribute conflict?

The best way to resolve a function and subroutine attribute conflict is to carefully review the code and make sure that the correct attribute is being used for each operation. If needed, the code may need to be rewritten to ensure that the correct attribute is being used. It is also important to understand the difference between functions and subroutines and how they should be used in different situations.

4. Are there any programming languages that do not allow function and subroutine attributes to conflict?

Yes, there are some programming languages that do not allow function and subroutine attributes to conflict. For example, in Python, functions are defined using the "def" keyword and subroutines are defined using the "void" keyword. These keywords cannot be interchanged, preventing any conflict between function and subroutine attributes.

5. Can conflicts between function and subroutine attributes cause performance issues?

Yes, conflicts between function and subroutine attributes can cause performance issues. If the code is not correctly interpreted by the compiler, it may lead to inefficient use of system resources and slower execution of the program. It is important to avoid conflicts in order to ensure optimal performance of the code.

Similar threads

  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
8
Views
3K
Replies
2
Views
2K
  • Sticky
  • Feedback and Announcements
Replies
2
Views
495K
Back
Top