How can I fix issues with passing values between subroutines in FORTRAN?

  • Context: Fortran 
  • Thread starter Thread starter krishvk
  • Start date Start date
  • Tags Tags
    Fortran Programming
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 4K views
krishvk
Messages
1
Reaction score
0
Hi all,

Greetings.

This could be a basic question, and if it is, pardon me for my ignorance as I am a newbie to FORTRAN. I am trying to modify a FORTRAN code where I have added a subroutine (say SUB1) to calculate a variable, say (QX). What I did is to call this subroutine in another one (called SUB2) where all the input variables, except two, needed to calculate QX is specified / calculated. In order to get the aforementioned two variables, I called the subroutine (lets call it SUB3) dealing with them in the beginning of SUB2. When I am trying to print it out they are not passing the values I expect, but are passing very high values.

What is it that I am doing wrong here? And please note that the two variables from SUB3 are not changed in the subroutine SUB2. I tried to use INTENT(IN) for these variables; and the code in return dumped an error "Error: Symbol at (1) is not a DUMMY variable".

Any suggestion would be appreciated. Thank you for your time.
Cheers.
 
on Phys.org
It would help if you attach some code that doesn't work. You can probably remove all the calcs to make it shorter and easier for other people to understand.

Debugging code that you can see is sometimes hard. Debugging code that you can't see is even harder!
 
Hi krishvk, as AlephZero said, you really need to post some code if we are to figure this out.

I think it's quite likely however that your problem is related to variable "scope". Are you perhaps assigning these values only to "local variables" in one of the subroutines?