View previous topic :: View next topic |
Author |
Message |
mike.smartcam
Joined: 02 Aug 2014 Posts: 40 Location: Lancashire, United Kingdom
|
Posted: Fri Nov 21, 2014 11:53 am Post subject: Run-time ERROR |
|
|
When running my program I am getting the following error:
Error 14 Attempt to alter an actual argument that is constant, an expression, an INTENT(IN) argument, or a DO variable
[/list][/list] DCHK - in file mainline.f95 at line 317 [+0132]
CCHK - in file mainline.f95 at line 774 [+1a08]
SREAD - in file mainline.f95 at line 3208 [+33a8]
OP1_OPT1 - in file mainline.f95 at line 4911 [+11c4]
M_OPT1 - in file mainline.f95 at line 2898 [+1cd4]
main - in file mainline.f95 at line 156 [+1914]
The first routine DCHK looks like this:
Code: | LOGICAL FUNCTION DCHK(STG,LEN,SIGN)
!$$$$$$ ! *c26
IMPLICIT NONE
CHARACTER STG*(*),DIG(0:12)*1,NUMS*60
INTEGER LEN,I,SRTP,P,DEC
DOUBLE PRECISION SIGN
LOGICAL T_DCHK
DATA DIG/'.','1','2','3','4','5','6','7','8','9','0',' ','-'/
PRINT *,'************** START OF FUNCTION DCHK ****************'
T_DCHK = .TRUE.
LEN = 60
SIGN = 1.0 |
were Line 317 is the last line displayed above.
Does anyone have any ideas what the problem is please? _________________ Regards
Mike |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Fri Nov 21, 2014 12:27 pm Post subject: |
|
|
As far as I know, SIGN is an intrinsic function in Fortran 95, so it cannot be used as a variable name. Maybe your code will work if you rename the variable.
Wilfried |
|
Back to top |
|
|
mike.smartcam
Joined: 02 Aug 2014 Posts: 40 Location: Lancashire, United Kingdom
|
Posted: Fri Nov 21, 2014 4:33 pm Post subject: |
|
|
I have changed the variable name through-out from SIGN to PT_SIGN but still get the same problem? _________________ Regards
Mike |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Nov 21, 2014 6:10 pm Post subject: |
|
|
Can you show us some code that shows what is happening to SIGN when DCHK is called.
Better still, post a short working program that illustrates the error. |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Fri Nov 21, 2014 6:10 pm Post subject: |
|
|
There isn't anything intrinsically wrong with using SIGN as the variable name.
You are allowed to override the names used for intrinsic functions etc in Fortran (which doesn't have any pre-defined keywords).
In the code posted, the issue may be that the actual argument corresponding to SIGN(where the logical function is called) is a constant or an expression instead of a variable (or a variable that cannot be changed such as one with the INTENT(IN) attribute).
So look at this line (2nd in your traceback list)
CCHK - in file mainline.f95 at line 774
Ahh I posted at the same time as Paul.
David. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mike.smartcam
Joined: 02 Aug 2014 Posts: 40 Location: Lancashire, United Kingdom
|
Posted: Wed Nov 26, 2014 12:08 pm Post subject: |
|
|
Apologies for the delay in responding I have been trying to resolve the problem but without success.
I have posted the files which produce the problem at:
https://www.dropbox.com/sh/rx7cam71dnhp7nz/AABPTwDXAkD_kRrQKAXda442a?dl=0
All files should be copied into the folder c:\FS
The source file reports a number of missing symbols but the program does not require them and it builds a working .exe file.
When run a command window will open which reports some information then asks for user input.
The first two question should be answered as option 1
The next few question just require a return to use the programmed default until the program asks for 'Total Feedscrew Length', this requires a value of say 99
After pressing return the problem will be displayed _________________ Regards
Mike |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Wed Nov 26, 2014 2:43 pm Post subject: |
|
|
As per my post above the error is in function CCHK at line 779 in your Problem.F95 file.
Look at line 779:
Code: |
T_CCHK = DCHK(T_STG,T_LEN,0D0)
|
Your function DCHK attempts to write to the third dummy argument (originally called SIGN but now called PT_SIGN). But you cannot assign a value to the third argument in this call because it is a constant (You can't change the value of 0D0).
I haven't bothered to run your code with the other files you uploaded, to me the error is quite obvious just looking at the Fortran code. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mike.smartcam
Joined: 02 Aug 2014 Posts: 40 Location: Lancashire, United Kingdom
|
Posted: Wed Nov 26, 2014 3:40 pm Post subject: |
|
|
Thanks for that davidb.
Would I be correct in assuming that if the code was wrtten as follows it would work ok:
Code: | arg3 = 0D0
T_CCHK = DCHK(T_STG,T_LEN,arg3) |
_________________ Regards
Mike |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Wed Nov 26, 2014 4:20 pm Post subject: |
|
|
Quite possibly. Certainly the run-time error should disappear but I haven't thought through what your code is actually doing. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
mike.smartcam
Joined: 02 Aug 2014 Posts: 40 Location: Lancashire, United Kingdom
|
Posted: Fri Nov 28, 2014 11:04 am Post subject: |
|
|
That fixes the problem, I just did not realize that passing the argument in that format effected the syntax for usage.
Thanks to everyone for their input, most appreciated. _________________ Regards
Mike |
|
Back to top |
|
|
|