I have a fortran program and Code::Blocks IDE is complaining a line is truncated, so how do I specify this is free form fortran source code in Code::Blocks.
From the 'Build log' tab, here is an excerpt of the warnings and failures:
-------------- Build: Debug in swat_cb (compiler: GNU Fortran Compiler)---------------
mingw32-gfortran.exe -Jobj\Debug\ -Wall -g -c C:\Users\TZ\f90apps\SWAT\src\biozone.f -o obj\Debug\src\biozone.o
Warning: Nonconforming tab character in column 1 of line 2
Warning: Nonconforming tab character in column 1 of line 126
Warning: Line truncated at (1)
C:\Users\Tong.Zhai\f90apps\SWAT\src\biozone.f:167.72:
if(sep_tsincefail(j)>0) sep_tsincefail(j) = sep_tsincefail(j) +
1
Error: Syntax error in expression at (1)
line2 is an empty line, but has a 'tab' character at the beginning
line126 is as follows:
<tab>implicit none
line167 is as follows:
if(sep_tsincefail(j)>0) sep_tsincefail(j) = sep_tsincefail(j) + 1
line167 is the first of many errors saying the line is truncated at just after the last plus sign (+), which is column 71
Thanks to #VladimirF's hint, I found the place for setting the free form flag in CB for Fortran programs, here is the menu options to get to it:
Project -> Build options... to bring up the 'Project build options' dialog.
From the 'Compiler Flags' tab, scroll down to the 'Fortran dialect' group, where you can check the following two options:
In free form an entire line is meaningful [-ffree-line-length-none]
The free form layout used by the source files [-ffree-form]
After checking these, I recompiled the project and those errors about line truncated are gone.
Related
Eclipse expert help needed! I have set up a makefile project to compile and link HCS12 code using the free codewarrior tools. It all seems to work well, but the only error/warning/information output I can get is to the console, with nothing being scanned from the console into the Problems window. I set up a regular expression error parser(Window -> Preferences -> C/C++ -> Build -> Settings -> Error Parsers) to scan the console for the appropriate information. If I search the console output (click in output and F) using find/replace with "regular expressions" checked, I find the warnings and errors--they just never get to the Problems tab.
I have enabled the error parser in (Project->Properties->C/C++ Build->Settings->ErrorParsers).
Somewhere I read that I need to enable this in C/C++ Makfile settings--but I cannot fine any settings which include the name "Makefile"; did I set up my project wrong??
Any suggestions or ideas on how to get my parsed errors into the problems window?
Eclipse Luna, Windows 7 professional.
It seems that the Regex parser for Eclipse (at least the older version I am currently using) assumes you start at the beginning of a line of text and end at the end of a line of text. My compiler errors were spanning multiple lines; I found a switch in the compiler which allowed it to output the errors in "microsoft format", which was then on a single line.
the new warning line looks like
.\CODE\LIBCODE\CodeLibraries\Drivers\CI2C1.C(312): WARNING C1801: Implicit parameter declaration for 'CI2C1_OnMasterBlockSent'
regex that works is now
[^"\n]\([^"(])((\d+)): WARNING C(\d+):([^\n]*)
of particular note is the [^"\n]*\ at the beginning of the regex expression, which matches all characters from the beginning of the line until the last \ is found--this is the piece I was missing. Eclipse Kepler is rather unforgiving about the regex it requires.
and we have
File $1 (just the file name--eclipse adds the path mysteriously if the file is in a code directory of the project)
Line $2 (gathers the line number of the error)
Descrioption $4 ( I ignore WARNING and the warning number, and capture the description of the error to the end of the line)
I now have a useful and somewhat more modern IDE to work with ancient code which grew from the assembly code over many years and was never parsed out into libraries or restructured into modern levels of abstraction.
I am looking to perform matrix exponentials, which apparently the Expokit library is suitable for. Sadly unlike Lapack or OpenMP this is not easily installed from Cygwin or Mingw for Windows. Therefore I have downloaded the library from here, however once unpacked it consists purely of .f files with little guidance on how to use them. The only site I've found online isn't much use (Fortran Wiki), as it doesn't give any indication of how the Expokit library is linked.
I would greatly appreciate any guidance on how to install Expokit on Windows, or alternatively on Ubuntu if Windows is not suitable.
Making the change suggested by ripero and running 'make sample_d' on Ubuntu I get the log shown below. I assume this means the sample has been compiled successfully, but I have no idea how this enables me to use Expokit as a library in my Fortran programs. Could someone please provide guidance on this?
XX:~/programs/expokit/expokit/fortran$ make sample_d
f77 -O3 -c blas.f
blas.f:404:72:
10 assign 30 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:409:19:
20 go to next,(30, 50, 70, 110)
1
Warning: Deleted feature: Assigned GOTO statement at (1)
blas.f:411:72:
assign 50 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:420:72:
assign 70 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:427:72:
assign 110 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1621:72:
10 assign 30 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1628:19:
go to next,(30, 50, 70, 90, 110)
1
Warning: Deleted feature: Assigned GOTO statement at (1)
blas.f:1630:72:
assign 50 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1639:72:
assign 70 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1644:72:
100 assign 110 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1671:72:
85 assign 90 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1689:16:
go to next,( 50, 70, 90, 110 )
1
Warning: Deleted feature: Assigned GOTO statement at (1)
f77 -O3 -c lapack.f
f77 -o sample_d sample_d.o clock.o expokit.o mataid.o blas.o lapack.o
Your Fortran compiler fails to compile file sample_d.f due to a non-standard format statement. The source code of the same file provides instructions for how to fix it if this happens:
9001 format( <mprint>(1X,D11.4) )
*--- Some compliers (e.g., g77) generate 'Unsupported FORMAT specifier'
* with the specification above. In this case, simply use this form:
* 9001 format( 5(1X,D11.4) )
If you comment the first line above (add a * as the first character of the line) and uncomment the last line (remove the leading *), the error should disappear.
I don't think there is a particular significance to running make sample_d other than ensuring that the object files are created and that a sample program can be compiled and linked against them in order to create a working binary.
First, you should be aware that you have compiled Expokit and one of the sample programs using what their Makefile calls case 3, where the required BLAS and LAPACK subroutines are provided by files blas.o and lapack.o, respectively, compiled from their .f counterparts provided by Expokit.
# Among the 3 possibilities below, uncomment the appropriate
# case for your environment and comment the others.
# case 1: works when LAPACK and BLAS are installed.
OBJLIBS =
LIBS = -llapack -lblas
# case 2: works when LAPACK is not installed but BLAS is.
#LIBS = -lblas
#OBJLIBS = lapack.o
# case 3: works when neither LAPACK nor BLAS are installed.
#OBJLIBS = blas.o lapack.o
#LIBS =
If your system already has BLAS and LAPACK libraries, they very likely are more optimized than the ones in blas.o and lapack.o, and you probably will want to change the case in the Makefile (add/remove leading # to comment/uncomment the appropriate definitions of OBJLIBS and LIBS) so that you can use the system BLAS and LAPACK.
In order to use Expokit in your Fortran programs, you need to call from your source code the relevant subroutines (see the Expokit paper and the source code of expokit.f and mataid.f in order to read about the provided subroutines) and then the simplest is to add to your linking line the following
object files: expokit.o mataid.o followed by all the object files listed in the active OBJLIBS variable in the Expokit Makefile, if any; and
libraries: all the ones listed in the active LIBS variable in the Expokit Makefile, if any.
I'm new to Eclipse. Despite its best efforts I got it to compile and run a
Hello World program. I am now trying to bring in a simple program I wrote that worked on MS Visual Studio 2010.
A user in reddit learnprogramming said I was missing a quotation mark in my make file, but I am using automatic make files. I don't know how to write my own and would rather work on the other 50 things wrong with the program. The Eclipse make file help page is technobabble to me.
I think Eclipse is not trying to build the files in the correct order, but I cannot find how to change the build order or how to point it towards the correct file to begin with. When I created the files in Eclipse, I hit "New Class" and then just copied and pasted in the old files. There are no red or yellow flags in the left margin indicating there are any problems. The file with the main method is Tier.cpp, but I believe it's trying to start with Player.cpp.
The compiler error is the very user friendly and easy to read:
01:31:42 **** Incremental Build of configuration Debug for project VanillaWoW ****
make all
Building file: ../VanillaWoWSource/Player.cpp
Invoking: Cross G++ Compiler
g++ -I"C:\cpp\boost_1_66_0\boost" -I"C:\cyg\bin"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\backward"
-I"C:\cyg\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\x86_64-pc-cygwin"
-I"C:\cyg\usr\include" -I"C:\cyg\usr\include\w32api"
-I"c:\cpp\boost_1_66_0\" -I"C:\cyg\lib\gcc\x86_64-w64-mingw32\6.4.0\include\c++"
-O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"VanillaWoWSource/Player.d"
-MT"VanillaWoWSource/Player.o"
-o "VanillaWoWSource/Player.o" "../VanillaWoWSource/Player.cpp"
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [VanillaWoWSource/subdir.mk:26: VanillaWoWSource/Player.o] Error 1
I don't understand why it's throwing an error on line 26 of an object file that I didn't think it had fully even created yet. I don't know what /bin/sh: -c refers to, and I don't know which file it's hitting the end of file on.
Full code is at :
https://docs.google.com/document/d/185sOHxk3wKAnl6N0oCSvlJZB7WUTY8gEtZCsLIr1q0o/edit?usp=sharing
Now I formatted up your error messages, I can see the problem:
-I"c:\cpp\boost_1_66_0\" -I"C:\cyg\lib\gcc\x86_64-w64-mingw32\6.4.0\include\c++"
Note the boost_1_66_0\" - the trailing backslash escapes the quote character, so the text colouring goes wonky. Look where you set up paths and either remove the trailing backslash, or better, use forward slashes throughout. Windows will accept them, and you won't get bitten by mysterious escape problems.
I'm not sure why getting C++ set up is so difficult for you. It might have something to do with you using Eclipse -- it's really more of a Java IDE, and I'd suggest using something that's built for C++. When I was starting C++, I wrote with Code::Blocks and it worked great for me. I'd suggest switching to that.
C++ is a lower level language than Java. It's arguably more difficult to program in because of that. Although I do think the brunt of your issue is more because of the environment you're coding in.
I want to compile a source code but I have trouble in compile.
cc -O2 -Olimit 2000 -g -migrate -assume -Zp1 noaligned_objects ...
cc: error: 2000: No such file or directory
cc: error: noaligned_objects: No such file or directory
cc: error: unrecognized command line option ‘-migrate’
cc: error: unrecognized command line option ‘-assume’
cc: error: unrecognized command line option ‘-Zp1’
Start with compiling it with no system-specific flags (i.e. by using gcc possibly with -I, -L, and -l flags and nothing else). If the program in question is portable enough, then it will be a matter of getting all dependencies available for it.
Once you are able to build it, see if it runs as expected (ignore performance). If it doesn't, that would be a good time to look at the flags you used on DEC to see if it requires any special treatment when building. This is where you either make the program portable or try to get the equivalent behavior using gcc on the target architecture of your choice.
Finally, once the program builds and runs, that would be a good time to see if you want to use any optimization flags (hint: you don't have to. If it runs fine, leave it the way it is).
I have a user report (unfortunately can't verify it due to lack of appropriate machine) that the C preprocessor (cpp) command on Mac OS X 10.6.4 doesn't remove C++/C99 double slash // comments from files it processes, no matter what option it's given. This is the gcc version:
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Is it possible to somehow cause it to remove such comments, as one would expect from a C++ preprocessor (this is needed because cpp is used as part of another tool).
I've found a formula that works with the cpp command: try cpp -xc++ (note the lack of spaces between -x and c++).
$ printf '/* block comment */\n// line comment\nnot a comment\n' | cpp -xc++
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
not a comment
contrast:
$ printf '/* block comment */\n// line comment\nnot a comment\n' | cpp -x c++
i686-apple-darwin10-gcc-4.2.1: c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: c++: No such file or directory
i686-apple-darwin10-gcc-4.2.1: warning: '-x -x' after last input file has no effect
i686-apple-darwin10-gcc-4.2.1: no input files
Now '-x c++' is SUPPOSED to work, and DOES work on my Linux box (with gcc 4.4, but I recall it working as long ago as gcc 2.95) so it seems that Apple broke it.
I really must reemphasize the importance of providing a complete, precise test case for questions like these. It did not occur to me yesterday to look for Apple having introduced a bug, because I know that wilx's answer should have worked, and in the absence of a precise description of what the OP's user tried, it was far more likely that they had something else on their actual command line that was negating it. If the command line and error messages I show above were provided in the original question, that would have targeted everyone's attention much more effectively.
Try adding either -x c++ or -x c -std=c99 to the command line.
One partial solution that appears to work is invoke gcc -E instead of cpp.
-E Preprocess only; do not compile, assemble or link
This indeed strips // comments on Mac OS X.
However, I'm still curious why there are problems with cpp itself.