FUNCTION attribute conflicts with SUBROUTINE attribute

  • Context: Fortran 
  • Thread starter Thread starter Vrbic
  • Start date Start date
  • Tags Tags
    Function Subroutine
Click For Summary
SUMMARY

The forum discussion addresses a conflict between the FUNCTION and SUBROUTINE attributes in Fortran, specifically when implementing the Runge Kutta method with adaptive stepsize as described in Numerical Recipes. The user encountered failure messages due to incorrect declarations in their code. The solution involves changing the declaration of 'derivs' from double precision, external :: derivs to external :: derivs, which resolves the issue.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with numerical methods, specifically Runge Kutta
  • Knowledge of function and subroutine attributes in Fortran
  • Access to Numerical Recipes documentation
NEXT STEPS
  • Review Fortran function and subroutine declarations
  • Study the implementation of Runge Kutta methods in Fortran
  • Explore adaptive stepsize techniques in numerical analysis
  • Consult the Numerical Recipes book for additional examples
USEFUL FOR

This discussion is beneficial for Fortran developers, numerical analysts, and anyone implementing numerical methods in programming, particularly those working with the Runge Kutta method.

Vrbic
Messages
400
Reaction score
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: 624
  • screen1.png
    screen1.png
    26.7 KB · Views: 448
Technology news on Phys.org
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
 
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
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
38K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K