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

AI Thread Summary
The discussion revolves around a FORTRAN programming issue where a user is attempting to modify code by adding a subroutine (SUB1) to calculate a variable (QX). The user calls this subroutine within another (SUB2), which requires two additional variables sourced from a third subroutine (SUB3). The user encounters unexpected high values when printing these variables, despite not modifying them in SUB2. Suggestions from other participants emphasize the importance of sharing code for better troubleshooting and highlight that the problem may stem from variable scope, specifically whether the variables are being assigned to local variables within the subroutines. The use of INTENT(IN) is also mentioned, with an error indicating a potential misuse of dummy variables.
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.
 
Technology news 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?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
59
Views
11K
Replies
5
Views
3K
Replies
4
Views
2K
Replies
5
Views
8K
Replies
4
Views
2K
Replies
11
Views
2K
Replies
2
Views
2K
Back
Top