Hello I am new to FORTRAN programming and now going through INTEGERS.
I have the following code Snippet
CHARACTER*14 METFIL
+ / 'WKPLT.MET' /
CHARACTER*127 IBC
CHARACTER*2 ICOD(6)
INTEGER *2 JIS (6)
+ / Z2533, Z2524, Z256B, Z4538, Z332B, Z3F5E /
When I am compiling using g77 I am getting the error "Invalid declaration of or reference to symbol `z2533' at (^) [initially seen at (^)]" . Can anyone help me regarding this.
Hey I tried to compile your code using g77 . I changed the following
INTEGER *2 JIS (6)
+ / Z'2533', Z'2524', Z'256B', Z'4538', Z'332B', Z'3F5E' /
This was as per agentp's comment above . Hope this helps
Related
After running the following code, I got this error. But I don't know what the error means and how to solve it?
code with the error :
you missed multiplying (*) after (h), which python is considering as function which is obviously not found. Change the code in line number to below code
volume = 1/3 * 22/7 * h * (R1*R1 +R2*R2 +R1*R2)
I am try to compile FORTRAN 77 code and I have problems like this.
integer row(nnzmax+nszero),column(nnzmax+nszero),
+ ireg(nximax),florsm(nzimax)/nzimax*2/
real lambda,imodel(nximax,nzimax),dm(nmmax),
+ dum1(nmmax),dum2(nmmax),data(ndmax+nsconst),
+ anz(nnzmax+nszero),ibmodel(nximax,nzimax),
+ smwz(nzimax)/nzimax*-1./,spwz(nzimax)/nzimax*-1./
Error on line 50: attempt to give DATA in type-declaration
Error on line 52: attempt to give DATA in type-declaration
I used to work with this code,but it has been compiled with Intel Fotran Compiler. I have moved to other country so I do not have ifort installed here. I am using fort77 now. Should I try with some compilation options or?I have used this script to compile app .f from this folder.
#! /bin/csh -f
set list=`ls *.f`
set FLAG="-o"
echo $list
foreach file (${list})
echo $file
f77 ${file} ${FLAG} ${file:r}
mv ${file:r} ../bin/.
end
I have changed declarations like this:
integer row(nnzmax+nszero),column(nnzmax+nszero),
+ ireg(nximax),florsm(nzimax),
+ data florsm /nzimax*2/
real lambda,imodel(nximax,nzimax),dm(nmmax),
+ dum1(nmmax),dum2(nmmax),data(ndmax+nsconst),
+ anz(nnzmax+nszero),ibmodel(nximax,nzimax),
+ data smwz /nzimax*-1./,
+ data spwz /nzimax*-1./
But still I got
Error on line 50: attempt to give DATA in type-declaration
Error on line 53: attempt to give DATA in type-declaration
Error on line 385: Declaration error for smwz: used as variable
Error on line 385: Declaration error for smwz: may not appear in namelist
Error on line 385: Declaration error for spwz: used as variable
Error on line 385: Declaration error for spwz: may not appear in namelist
This fragment, and the later similar ones
florsm(nzimax)/nzimax*2/
looks like a non-standard way of initialising a variable with a sort-of data statement merged into the declaration. A more standard approach would separate the two, something like
florsm(nzimax)
...
data florsm /nzimax*2/
One of the beauties of working with the Intel Fortran compiler is its long history; along the way it has picked up, and continues to accept, all sorts of non-standard features. I'm guessing that this is one of those and is not acceptable to the other compiler you mention.
Of course, this seems to be what the error statement seems to be telling us.
A standard replacement might be
florsm(nzimax) = 2
but that takes advantage of a Fortran 90 feature which something called fort77 might not understand either.
I am very new Fortran and I am doing some elementary practice. I have installed Plato latest edition. I found this program in the net, and try to compile it
program dotprod
implicit none
real :: c
real, dimension(3) :: a, b
print*,'Enter first vector'
read*, a
print*,'Enter second vector'
read*, b
c = a(1)*b(1) + a(2)*b(2) + a(3)*b(3)
print*,'Dot product = ', c
end program dotprod
Plato shows no sign of error when I build and compile, but when I try to run the program the following error message shows up: the executable does not exist.
can anyone help me explain how to handle this error ?
thanks
Maybe your file name is too long. I had the same error message, and then I saved the file using another shorter name and suddenly it worked... I also tried your code and it works on my Plato (FTN95 Personal Edition (FTN95PE) version 7.20) on windows 10.
This is a problem on spoj.com (http://www.spoj.com/problems/PRIC/) .We have to check whether numbers of the sequence : ai=( a(i-1)+1234567890 ) mod 2^31 are prime or not, 1st number is 1.
My code is given below (Please try to ignore the clumsiness.) based on sieve of eratosthenes .
The PROBLEM : We have to print "prime(1) or not(0)" for sequence upto i=33,333,333 , My code works perfectly fine for i( c3 in the code) values upto 8000 or so and after that (e.g c3>19000 ) it starts giving The SIGFPE error . Now i googled about the error , it has something to do with division/ mod by 0. But why is it that code works for c3 values upto 9000 but not beyond that?
Depending on your compiler and development environment, you should read up on the concept of a Debugger. This answer has a guide to use gdb. If you are using Visual Studio, Code::Blocks or any other IDE, look up the debugging features. For instance how to set a breakpoint or step into/out of/over a function call for instance, watching or changing variables etc. (I'm mentioning these things to give you vital hints for Google search-words, wink wink nudge nudge).
EDIT:
Copy-pasted the code and saved it, compiled with gcc -g for debug symbols and -lm to link the math library, I ran it through gdb and it gave me this output:
Program received signal SIGFPE, Arithmetic exception.
0x0000000000400707 in sieve (prime=0x6626a0) at t.c:43
43 if (a%prime2[j]==0){
This tells you to look at line 43, at the if statement that uses a modulo operation. This seems to be the place you are doing the modulo zero.
Do note that line 43 in the document I got when I copy-pasted your code from Stackoverflow, may not be line 43 in your document.
EDIT2:
Hey my answer was unaccepted! - why was that :) ?
This is hopefully a simple linker issue but I've spent hours searching and haven't moved forward in that time. I'm trying to use
#include <cmath>
double aA = 2;
double result = pow((double)2.0,(double)aA);
I get no error messages and it compiles without issue. But an unrelated grid I'm drawing with openGL doesn't display. If i substitute the aA for 2 then it displays the grid. Like
#include <cmath>
double aA = 2;
double result = pow((double)2.0,(double)2);
This outputs 4 as expected. The previous example outputs nothing. It's as if the program hangs but there are no errors.
This computation isn't used anywhere and in fact just sits in main (or anywhere else) and the variables are unique and are unused.
I'm using code::blocks and minGW GNU GCC compiler in Windows 7. -g -Wall - WExtra
Rendering with glew + freeglut and everything else works until i use a variable with pow.
I've tried every combination of casting I can think of and I've tried powf with the exact same result. I'm using sqrt and other functions so believe that the inclusion is working. I've also tried math.h but get the same problem.
I have never wished to see an error message from a compiler more so than I do right now.
So 1. Why am I not getting an error when it looks like its stopping the whole program in its tracks?
And 2. What have I missed to get pow() working with variables?
Update : After creating a new project and trying it out I have no issues so there must be something in my setup that's interfering. I'll keep experimenting. Thanks for the quick responses things sure move fast around here!
Update 2:
Very strange.
float aAs = 1.0;
float amplitudeA = (float)pow((float)2.,(float)aAs);
char str[50];
int test = (int) (amplitudeA);
sprintf (str, "out - %d", test);
MessageBox(NULL,str,NULL,NULL);
This outputs 2 in the message box. Then my grid draws and the program behaves. If i comment out only the message box like so:
float aAs = 1.0;
float amplitudeA = (float)pow((float)2.,(float)aAs);
char str[50];
int test = (int) (amplitudeA);
sprintf (str, "out - %d", test);
//MessageBox(NULL,str,NULL,NULL);
No drawing of my grid. What could be causing this?
char str[50];
int test = (int) (1);
sprintf (str, "out - %d", test);
MessageBox(NULL,str,NULL,NULL);
float aAs = 1.0;
float amplitudeA = (float)pow((float)2.,(float)aAs);
Swapping the message box over recreates the issue. No grid drawn. It's as if focus needs to be taken away from the program when I'm using a variable in pow. I'm completely baffled.
Another Update : I temporarily got around it by writing my own simple powerOf function. But now I'm having the same issue with the cos() function.
Can anyone tell me if there is something wrong with that image? This issue has to stem from incorrect linking. Is that what you would expect from hovering over coz in code::blocks with gcc?
This a error that occurs only when running through the program with a bad cos call. Interesting that I've been using cos for camera calculations since I started this app with no issue.
Error #667: UNADDRESSABLE ACCESS: reading 0x00000003-0x00000007 4 byte(s)
# 0 ntdll.dll!RtlImageNtHeader +0x124c (0x77ca43d0 <ntdll.dll+0x343d0>)
# 1 ntdll.dll!RtlImageNtHeader +0x422 (0x77ca35a7 <ntdll.dll+0x335a7>)
# 2 ntdll.dll!RtlImageNtHeader +0x30d (0x77ca3492 <ntdll.dll+0x33492>)
# 3 KERNEL32.dll!HeapFree +0x13 (0x775e14dd <KERNEL32.dll+0x114dd>)
# 4 atioglxx.dll!atiPPHSN +0x11afaa (0x66538f3b <atioglxx.dll+0xeb8f3b>)
# 5 atioglxx.dll!DrvSwapBuffers +0x33fb (0x6569b9cc <atioglxx.dll+0x1b9cc>)
# 6 atioglxx.dll!DrvSwapBuffers +0x3cad (0x6569c27e <atioglxx.dll+0x1c27e>)
# 7 atioglxx.dll!DrvSwapBuffers +0x7c57 (0x656a0228 <atioglxx.dll+0x20228>)
# 8 atioglxx.dll!DrvSwapBuffers +0x12c (0x656986fd <atioglxx.dll+0x186fd>)
# 9 atioglxx.dll!DrvValidateVersion +0x28 (0x65697c19 <atioglxx.dll+0x17c19>)
#10 OPENGL32.dll!wglSwapMultipleBuffers +0xc5d (0x66c8af0b <OPENGL32.dll+0x3af0b>)
#11 OPENGL32.dll!wglSwapMultipleBuffers +0xe45 (0x66c8b0f3 <OPENGL32.dll+0x3b0f3>)
Note: #0:00:05.233 in thread 3136
Note: instruction: mov 0x04(%ecx) -> %ecx
Solved. There was an uninitialized variable that was sitting at the bottom of the vertex buffer object I was using to draw the grid. For whatever reason feeding a variable to one of the math functions caused unexpected results in this buffer object.
Thanks to Angew an Kos for pointing me towards memory.