Can You Use Nested Subroutines in Fortran95 and How Do You Link Them?

  • Context: Fortran 
  • Thread starter Thread starter dichotomy
  • Start date Start date
  • Tags Tags
    Fortran Program
Click For Summary
SUMMARY

In Fortran95, nested subroutines are not permitted; subroutines cannot be defined within other subroutines. However, Fortran95 supports returning arrays from subroutines, which can be achieved using the appropriate interface. The INTERFACE-END INTERFACE construct is essential for linking subroutines in the main program. This discussion highlights the need for clear structuring when implementing algorithms like Gauss-Seidel iteration and Gauss-Jordan elimination.

PREREQUISITES
  • Understanding of Fortran95 syntax and structure
  • Familiarity with subroutines and functions in Fortran95
  • Knowledge of array handling in Fortran95
  • Basic concepts of numerical methods, specifically Gauss-Seidel and Gauss-Jordan elimination
NEXT STEPS
  • Research the INTERFACE-END INTERFACE construct in Fortran95
  • Learn about array passing techniques in Fortran95
  • Study the implementation of Gauss-Seidel iteration in Fortran95
  • Explore best practices for structuring Fortran95 programs
USEFUL FOR

Fortran developers, numerical analysts, and anyone implementing algorithms in Fortran95, particularly those working with linear equations and array manipulations.

dichotomy
Messages
24
Reaction score
0
basic question really...can you have subroutines nested within subroutines? or are there any other types of subprograms within fortran95 other than functions and subroutines? (need one that can pass back an array)

if you can [use subs within subs], how do you link them? like in the main program you have to use an INTERFACE-END INTERFACE construction to link to the subroutine...

ta in advance
 
Technology news on Phys.org
Not sure about subroutines within a subroutine, gut feeling is that it won't work. As for returning an array, that is possible.
 
erm...could you elaborate? I'm writing a program that solves linear equations with gauss seidel iteration (and gauss/gauss jordan elimination), so there's a main program which calls the various methods as subroutines...

except within the gauss seidel subroutine I want to separate a bit which makes the matrix diagonally dominant(ish)...obviously after rearranging the rows the matrix needs to be passed back to the gauss seidel subroutine.
 

Similar threads

  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K