I am editing an old project that uses fixed form Fortran and compiling with IVF compiler. The current issue I have is with continuation lines in a list:
format(//, 10x,'*******************************************',/, &
10x,'* DIAGONALS OF THE RESIDUAL COV. MATRIX *',/, &
10x,'*******************************************',//, &
2x,'MEASUREMENT',7X,' RESIDUAL COVARIANCE', /)
For some reason, the ampersand is not working for me and I keep getting the error:
unrecognized token '&' skipped
For smaller lines, increasing the fixed form line length and making the two lines one worked but there are instances where the lines are too large for this. The code was written around 15 years ago and in fixed form Fortran but I am unfamiliar with Fortran and how the new compiler and settings affect the code.
Converting to free form causes a series of errors with other formatting and the code does not seem broken so I do not think converting to free form is necessary. I have tried other methods of indenting, such as an ampersand at the end of a line and at the beginning of next, an asterisk, and a slash that other forums suggested using and they produce the error:
error #5082: Syntax error, found END-OF-STATEMENT when expecting one
of: <HOLLERITH_CONSTANT> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM>
<CHARACTER_CONSTANT> ) ...
Is there some sort of formatting I am missing or is there any settings I could edit to fix these errors?
In fixed form Fortran, you continue a line with any character in column 6 of the next line, not an & at the end of the 1st line. Try:
format(//, 10x,'*******************************************',/,
c 10x,'* DIAGONALS OF THE RESIDUAL COV. MATRIX *',/,
c 10x,'*******************************************',//,
c 2x,'MEASUREMENT',7X,' RESIDUAL COVARIANCE', /)
Or use the compiler switch -free with .for or .f
Or use the compiler switch -fixed -132 with a .F90 .
In your case I would preserve the .f and cp that to .F90 and then explicitly have the makefile compile the .F90 ...
I normally use -fixed -132 with a .F90 as I often have -d-lines that I retain in the code, and I could not get -d-lines. To work with -free.
Related
When compiling cross-compiler tool crosstool-0.43 (for arm9) on the CentOS 7.5 64-bit system, I encountered the following error:
cc -c -o flat_bl.o /home/muhuo/arm-linux-project/transplant-test/build-tools/crosstool-0.43/build/arm-9tdmi-linux/gcc-4.1.0-glibc-2.3.2/binutils-2.16.1/gprof/flat_bl.m
/home/muhuo/arm-linux-project/transplant-test/build-tools/crosstool-0.43/build/arm-9tdmi-linux/gcc-4.1.0-glibc-2.3.2/binutils-2.16.1/gprof/flat_bl.m:2:2: error: expected identifier or ??before ??token
% the percentage of the total running time of the
^
I don't know what the *. m file in binutils-2.16.1 is. Whether I need to install some other tools before?
From the picture above, Compiling *.m file with GCC should be wrong.
I need some help. Thanks.
The problem is that there is a builtin '.m.o' suffix rule which triggers with a higher priority than the '.c.o' suffix rule. There was an attempt to disable this rule under PR2587 but because it is an old-style suffix rule this doesn't work.
There are two possible solutions, one is to remove all builtin rules by adding the line .MAKEFLAGS: -r to binutils/gprof/Makefile.in somewhere, or else more correctly change the .SUFFIXES: line in the same file so that the '.m' comes after '.c', thus changing the rule priority.
I'm trying to compile legacy Fortran code with fort77. The command:
fort77 -c leg_code.f leg_code.o
fails with:
Error on line XXX: syntax error
Line XXX reads:
CHARACTER(LEN=10) TREE(2,MAXF)
where MAXF is defined some lines above with:
INTEGER MAXF, MAXC
PARAMETER (MAXF=400, MAXC=20)
If I remove (LEN=10), the code compiles with no issues.
Anyone know the reason for this error?
As noted in the comments, the declaration statement
CHARACTER(LEN=10) TREE(2,MAXF)
is not valid in Fortran 77. This form, declaring a rank-2 array of character of length 10, was introduced to standard Fortran in the Fortran 90 revision.
To declare such a variable in Fortran 77 the alternative form
CHARACTER*10 TREE(2,MAXF)
or
CHARACTER TREE(2,MAXF)*10
would be required. Simply removing the (len=10), as in
CHARACTER TREE(2,MAXF)
declares the variable to be an array of character of length 1, but this is valid in Fortran 77.
In my makefile, I would like to check for the existence of a library and give an informative error message. I created a conditional that should exit the make process when the file is not found:
9: ifeq ($(${JSONLIBPATH}),)
10: JSONLIBPATH = ${ALTJSONLIBDIR}/${LIBJSON}
11: endif
12: ifeq ($(${JSONLIBPATH}),)
13: $(error JSON library is not found. Please install libjson before building)
14: endif
My makefile gets stuck on line 13:
Makefile:13: *** commands commence before first target. Stop.
After line 13, my makefile has its targets.
I tried putting this conditional block into a target (e.g. a target called isJSONLibraryInstalled) but this does not execute correctly.
How would I check for a file's existence and handle the error case, before processing targets? Apologies if this is a dumb question.
First of all, you are looking at the contents of a variable that is named after the current path, which is probably not what you want. A simple environment variable reference is $(name) or ${name}, not $(${name}). Due to this, line 13 is always evaluated.
Second, I think it is choking on the indentation of the $(error ...) expression. While the expression resolves to an empty string, there is still a tab character at the start of the line, which indicates a command, which in turn cannot exist outside a rule.
I think using spaces rather than tabs to indent would work.
When you get Make error messages, always check the Error message documentation
On GNU Make 3.81 (error appears to have been removed from newer versions), it says:
This means the first thing in the makefile seems to be part of a command script: it begins with a TAB character and doesn't appear to be a legal make command (such as a variable assignment). Command scripts must always be associated with a target.
What makes matters more confusing is that "doesn't appear to be a legal make command" part. That explains why in:
a := b
$(error a)
the error happens at line 2 and not 1: make simply accepts statements that it can parse, like the assignment, so the following works:
a := b
a:
echo $a
Note: SO currently converts tabs to spaces in code, so you can't just copy the above code into your editor.
For me it was an unnecessary white space before the connector that was causing this.
On slickEdit I selected the option to view all special character and noticed the black sheep.
You can check whitespaces, spaces and tabs by using VSCode [View > Render Whitespace]
As you can see;
command-1 has a tab (->) and whitespace at the end
command-2 has space at first
command-3/4 has tab+spaces
So, you should remove the whitespaces at the end and apply the same spaces with the same action. e.g: tab like the following;
Hi while i cross compile an startup.s file
(arm-none-eabi-as file.s)
(*-gcc)
I am getting in each commentary line some errors
- junk at end of line, first unrecognized character is /
when i delete the // some comment lines i get
errors about undefined symbols even i defined them at beginning of the file.
anyone know whats wrong?
If you want to use macros or C comments, then you have to preprocess the source file with the C preprocessor. The C preprocessor removes comments and interprets macros. The GNU assembler should run the C preprocessor automatically if the source file name ends with .S, with an uppercase 'S'.
(arm) Assembler does not support // comments or defines, you have to use .equ and # for comments. If you let gcc parse it you can put C isms like that into your assembler. Personally I avoid such C isms and keep the assembler clean. if you cannot do that or need includes with defines for example let gcc pre-process the file before sending it to gas.
I've been tasked with maintaing some legacy fortran code, and I'm having trouble getting it to compile with gfortran. I've written a fair amount of Fortran 95, but this is my first experience with Fortran 77. This snippet of code is the problematic one:
CHARACTER*22 IFILE, OFILE
IFILE='TEST.IN'
OFILE='TEST.OUT'
OPEN(5,FILE=IFILE,STATUS='NEW')
OPEN(6,FILE=OFILE,STATUS='NEW')
common/pabcde/nfghi
When I compile with gfortran file.FOR, all lines starting with the common statement are errors (e.g. Error: Unexpected COMMON statement at (1) for each following line until it hits the 25 error limit). I compiled with -Wall -pedantic, but fixing the warnings did not fix this problem.
The crazy thing is that if I comment out all 4 lines starting with IF='TEST.IN', the program compiles and works as expected, but I must comment out all of them. Leaving any of them uncommented gives me the same errors starting with the common statement. If I comment out the common statement, I get the same errors, just starting on the following line.
I am on OS X Leopard (not Snow Leopard) using gfortran. I've used this very system with gfortran extensively to write Fortran 95 programs, so in theory the compiler itself is sane. What the hell is going on with this code?
Edit: Compiling with g77 gives:
test.FOR: In program `MAIN__':
test.FOR:154:
IFILE='TEST.IN'
1
test.FOR:158: (continued):
common/pabcde/nfghi
2
Statement at (2) invalid in context established by statement at (1)
Er, what context is established at (1)?
I don't think you can put COMMON statements below the executable statements in FORTRAN 77, see the specification, Sec. 3.5.
Just move the COMMON statement close to the beginning of the procedure, before any executable statement.