 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
tomdizzle
Joined: 17 Jun 2010 Posts: 2
|
Posted: Thu Jun 17, 2010 10:58 pm Post subject: help! problem calling a subroutine |
|
|
I am a relative novice, I am using FTN95 with PLATO. I have a code with multiple subroutines in the same file, but outside the main program. ie, for illustration
Code: |
PROGRAM
CALL SUBROUTINE A
CALL SUBROUTINE D
CALL SUBROUTINE E
CALL SUBROUTINE C
END PROGRAM
SUBROUTINE A
...
END SUBROUTINE A
SUBROUTINE B
...
END SUBROUTINE B
SUBROUTINE C
...
END SUBROUTINE C
SUBROUTINE D
...
END SUBROUTINE D
SUBROUTINE E
...
END SUBROUTINE E
|
When I run the code it runs fine for most calls to subroutines (i.e. A, D and E), but on C it returns "error 426, CHARACTER dummy argument defined to be larger than actual argument". when i look at the line that the error came up on, it is actually the END SUBROUTINE B, the end statement of another subroutine just before the one that is meant to be called. Furthermore, if I remove the subroutine whose END statement it is reading (as it isn't being used yet) then the error occurs on the END statement of the subroutine preceding that one!
The program is buggy, and was modified just before this happened, but i reverted back to an older version (which didn't have this problem last time it was run) and it now has the same problem.[/code] |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Fri Jun 18, 2010 1:50 am Post subject: Calling a subroutine |
|
|
Post a small example program that will demonstrate the errors that you encountered.
The "code" that you posted cannot be compiled into a running program, nor does it show the types of subroutine arguments that you described. |
|
Back to top |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 Location: Sunderland
|
Posted: Fri Jun 18, 2010 12:43 pm Post subject: |
|
|
If you are doing something like:
Code: |
character*80 a
call sub1(a)
end
subroutine sub1(dummy)
character*100 dummy
len_dummy = 100
end
|
That would leave the last 20 characters of "dummy" unfilled by the data in the main program "a" variable, and would probably be filled by data from any main program data which was defined immediately after the definition of "a".
Try using:
Code: |
character*80 a
call sub1(a)
end
subroutine sub1(dummy)
character*(*) dummy
len_dummy = len(dummy)
end
|
Regards
Ian |
|
Back to top |
|
 |
tomdizzle
Joined: 17 Jun 2010 Posts: 2
|
Posted: Mon Jun 21, 2010 2:44 pm Post subject: |
|
|
thanks guys,
mecej4, the code is too long to post here, and the problem doesn't seem to happen on some smaller codes with subroutines I've used.
Ian, thanks for the comment, I will look through to see if i'm doing anything like that.
There are two big things that are confusing me;
1) the subroutine is called 3 times prior to the error, and runs fine. But if the error is something like that Ian described then that would make sense.
2) the line that the error report points to in the code is the END SUBROUTINE line of a different subroutine , i.e. not at all to do with the subroutine it claims is causing the error! and the subroutine to which this END statement applies is in no way linked to thesubroutine that is apparently causing the error. Furthermore, in the sourcecode the END statement in question is directly above the subroutine being called, so if i change the order of subroutines in the sourcecode, the error comes up for whichever END statement directly precedes the problem subroutine (even if it is the END PROGRAM statement)
In other possibly related matter, I thought I'd go back to the original version of the code to see if I could retrace my steps and now PLATO gives an 'access violation error' when I try to build! this was not happening previously and i don't see how my code could be causing such a problem during building. Is FTN95 particularly buggy? in other words could it be my compiler? is it worth reinstalling? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|