I am using a very old Fortran 77 code from third party (also very bugged). I have compiled with
FFLAGS=-O0 -Wall -g -fbacktrace -pedantic -Wextra
I am getting the warning in the title at runtime:
At line <number> of file <namefile>.f (unit=6, file='stdout')
Fortran runtime warning: Extension: $ descriptor
I would like to figure out what that means.
You should always show the code line number in the error or warning message, to which the line points.
The role of $ in
write(*,'(a$)') "string"
is to avoid going to the next line after printing "string" on the screen.
However, the descriptor is non-standard and therefore you are warned about this by the compiler.
The standard way is to use non-advancing input/output:
write(*,'(a)', advance="no") "string"
Related
I am having some issues with a makefile I am creating for a school project. I am compiling and assembling a C file and a SPARC assembly file (respectively) and linking them. I'm working in a Unix environment. Here is the makefile:
proj09.exe: proj09.driver.o proj09.support.o
<tab>gcc -Wall proj09.driver.o proj09.support.o -o proj09.exe
proj09.driver.o: proj09.driver.c /user/cse320/Projects/project09.support.h
<tab>gcc -Wall -c proj09.driver.c /user/cse320/Projects/project09.support.h
proj09.support.o: proj09.support.s
<tab>gcc -Wall proj09.support.s
When I try to make it, though, I get a reader error, specifically:
"Fatal error in reader: proj09.makefile, line 2: Unexpected end of line seen"
Now I know that usually this means that something is formatted incorrectly, but I have no idea what it could be in this case. Also, I am not 100% sure that this is the correct code for the makefile (specifically the assembling of my support.s file, and the linking of both files). I apologize if this is a repeat question, I looked through the archives beforehand and couldn't find anything of use. Any help would be greatly appreciated!
EDIT: I don't see why this would make a difference, but I am using gedit to actually write the code and then transferring the files into SSH for linking.
As Joachim told you, the lines should be indented by tab, not by spaces, so the second line should look like:
[TAB]gcc -Wall proj09.driver.o proj09.support.o -o proj09.exe[NEWLINE]
where [TAB] means TAB character.
Also there shouldn't be any spaces after the command. That's why I've put [NEWLINE] char.
Aside from the spaces and tabs, this doesn't generate an object file, shouldn't even compile (unless it has main()):
gcc -Wall proj09.support.s
You should use -c here too:
gcc -Wall -c proj09.support.s
Note: if you're working on Unix/Linux lose the .exe
This is a follow up to add “extern C” as a compiler option for a symbol? and mockinterface's suggestion.
Using clang, -x c allow me to treat a subsequent file as a C file. However, it treats all subsequent files a s C files, including object files. For example, the following:
/usr/local/bin/clang++ /usr/local/ssl/fips-2.0/lib/fipscanister.o -x c /usr/local/ssl/fips-2.0/lib/fips_premain.c
-Wall -Wextra main.o /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a -o main.exe -Wl,--no-demangle -ldl
main.o:1:1: error: expected unqualified-id
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003>
^
main.o:1:9: warning: null character ignored [-Wnull-character]
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003>
^
main.o:1:10: warning: null character ignored [-Wnull-character]
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003><U+0000>
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003>
^
main.o:1:9: warning: null character ignored [-Wnull-character]
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003>
^
main.o:1:10: warning: null character ignored [-Wnull-character]
<U+007F>ELF<U+0002><U+0001><U+0001><U+0003><U+0000>
...
From the earlier question, I need the -x c fips_premain.c because if fips_premain.c is compiled with a C++ compiler, then I get unresolved symbols. (And fips_premain.c is sequestered by the FIPS process so it cannot be changed).
I tried switch back to native with -x native (similar to -march), but that produced an error.
How do I switch back to "native" treatment of subsequent files for linking?
You will need to rearrange your compile command such that main.o is befor -x c (since -x c tells the compiler that "no matter what extension I use, the following files are C source files" - so Clang tries to compile main.o as a source file, and failing as you can tell...)
You can do this by using clang -c fips_premain.c, and using fips_premain.o in the line that links things.
In other words, -x c followed by
-x language
Treat subsequent input files as having type language.
I haven't tested it, but it may work to do -x none after your .c file too - gcc manual says that this should work if the Clang compatibility to gcc works as it should. Edit: Can confirm that -x none does what can be expected.
I'm trying to compile bitcoin on my EC2 instance, and I've run into a problem I can't figure out. The build script stops on the following command
g++ -c -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -DUSE_UPNP=1 -DUSE_IPV6=1 -I/home/ec2-user/bitcoin/src/leveldb/include -I/home/ec2-user/bitcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -I"/home/ec2-user/bitcoin/src" -I"/home/ec2-user/bitcoin/src/obj" -I"/usr/local/include" -I"/usr/include/openssl" -MMD -MF obj/alert.d -o obj/alert.o alert.cpp
by returning the following error(s)
In file included from /usr/include/sys/socket.h:40:0,
from compat.h:19,
from netbase.h:11,
from util.h:27,
from alert.h:13,
from alert.cpp:11:
/usr/include/bits/socket.h:231:5: error: expected identifier before numeric constant
/usr/include/bits/socket.h:231:5: error: expected ‘}’ before numeric constant
/usr/include/bits/socket.h:231:5: error: expected unqualified-id before numeric constant
In file included from compat.h:19:0,
from netbase.h:11,
from util.h:27,
from alert.h:13,
from alert.cpp:11:
/usr/include/sys/socket.h:254:1: error: expected declaration before ‘}’ token
I've tried compiling with the -std=c++0x option set, but it made no difference. That was the only thing I've been able to come up with.
I'd wager that some header file you have is #defineing a macro that interferes with socket.h. Are you able to compile a program that only includes <sys/socket.h>, with no other inclusions?
The next thing to check is to look at /usr/include/bits/socket.h and see what's on line 231 (where the first error occurs). If the code looks ok, then the next step is to see what the preprocessed source looks like. To get the preprocessed output, replace the -c option with -E on the command line, and change the -o obj/alert.o option to -o alert.ii to put the preprocessor output into the file alert.ii.
If you compare the content of alert.ii with /usr/include/bits/socket.h, you can see if it's getting compiled as expected or not. In particular, if there's a macro which defines something into something unexpected, you'll see code which is clearly wrong at the location the compiler is pointing out.
I've been testing out clang-llvm to see if it is worth it to mention to my school's IT department to add it to the machines we students program on. For all of our assignments, we are required to compile using g++ -Wall -W -pedantic-errors *.cpp, so I just converted the command to clang++ -Wall -W -pedantic-errors. I got some output that I wasn't expecting:
Attempting to compile...
In file included from test_library.cpp:6:
In file included from ./test_library.h:64:
In file included from ./library.h:167:
./library.hpp:20:23: warning: unused variable 'e' [-Wunused-variable]
catch(Exception & e)
^
Whereas the GCC compiler does not give an error about unused variables in the catch block. Is there anything I can do so that Clang does not freak out about unused variables in try/catch blocks while keeping the command similar to the g++ one?
Clang-LLVM(v2.7) GNU GCC(v4.4.4) Fedora 13
I kinda agree with Mike, but for getting-off-the-ground's sake, try this:
clang++ -Wall -W -pedantic-errors -Wno-unused-variable
I haven't used llvm much but I think the point of the [-Wunused-variable] in the diagnostic is to tell you that you can shut that warning up with -Wno-unused-variable.
What's wrong with catching exception with "catch(Exception &)" if you are not using the variable? You compilers AND your code reviewers will be happier.
I am not a Fortran programmer (just a short experience), but I need to compile a program partly written in F77. Someone has compiled it with Absoft compiler before me, but now I need to repeat the procedure on another machine with g77. For Absoft, the makefile has
f77 -f -w -O -B100 -B108 -c *.f
mv *.f flib && mv *.o olib
f77 -B100 -o runme olib/*.o clib/*.o -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11 -L$PVM_ROOT/lib/$PVM_ARCH -lfpvm3 -lpvm3 -L$ABSOFT/lib -lU77
I have modified these lines to be
g77 -w -O -B100 -B108 -c *.f
mv *.f flib && mv *.o olib
g77 -B100 -o runme olib/*.o clib/*.o -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11 -L$PVM_ROOT/lib/$PVM_ARCH -lfpvm3 -lpvm3 -lgfortran -lgfortranbegin
But I get the following error messages
somefile.f:(.text+0x93): undefined reference to `for_open'
somefile.f:(.text+0xf4): undefined reference to `for_write_seq_fmt'
somefile.f:(.text+0x128): undefined reference to `for_write_seq_fmt_xmit'
somefile.f:(.text+0x454): undefined reference to `for_read_seq'
How can I fix this?
UPDATE1
If I add -libifcore to the end of the last line (linker), then I get
/usr/bin/ld: cannot find -libifcore
I have located the library
$ find /opt/intel/* -name 'libifcore*'
/opt/intel/fce/9.1.036/lib/libifcore.a
/opt/intel/fce/9.1.036/lib/libifcore.so
/opt/intel/fce/9.1.036/lib/libifcore.so.5
/opt/intel/fce/9.1.036/lib/libifcore_pic.a
/opt/intel/fce/9.1.036/lib/libifcoremt.a
/opt/intel/fce/9.1.036/lib/libifcoremt.so
/opt/intel/fce/9.1.036/lib/libifcoremt.so.5
/opt/intel/fce/9.1.036/lib/libifcoremt_pic.a
But even if I do the following in the source directory
$ export PATH=$PATH:/opt/intel/fce/9.1.036/lib/
$ ln -s /opt/intel/fce/9.1.036/lib/libifcore.so
it is not found.
Moreover, it is the same machine where I get another problem How to pass -libm to MPICC? libimf.so: warning: feupdateenv is not implemented and will always fail
It seems that the compiler should find the library, if needed
$ echo $LD_LIBRARY_PATH
/opt/intel/fce/9.1.036/lib:/opt/intel/cce/9.1.042/lib:/usr/local/lib/openmpi:/usr/local/lib:/usr/lib:
Absoft accepted an extended version of Fortran 77 that is not completely compatible with the extended version of Fortran 77 accepted by g77.
So there is no guarantee that you can do this without editing the code. I seem to recall that the Absoft compiler accepted a handy initialization syntax that can not be replicated with g77.
If you want to compile & link using g77, the easiest way is to use the command "g77". (What compiler does f77 invoke on your computer? Try "f77 -v" or similar to find out...) It should automatically find the g77 Fortran-specific libraries. You should not need to explicitly link to Fortran libraries, and especially not to the libraries of gfortran, which is a different compiler. You could also compile & link with gfortran -- it will probably recognize that the source code is Fortran 77 and compile appropriately if the files have the correct file type, otherwise you will have to use options -- for this compiler, use the command "gfortran".
With g77 and gfortran it should not need Intel libraries -- maybe f77 is connected to ifort, the Intel compiler, on your computer?
Edited later:
I suggest trying something simpler first to test your setup.
Try this FORTRAN 77 program as file "junk.f"
C234567
write (6, *) "Hello World"
stop
end
Try this command:
g77 junk.f -o junk.exe
Run it via:
./junk.exe
This will test whether g77 is working.
it looks like you are trying to link with libifcore.
Edit:
You can include this library by adding
'-lifcore' to your compiler options. To quote the gcc tutorial
In general, the compiler option -lNAME will attempt to link object files with a library file ‘libNAME.a’ in the standard library directories.
why do you use g77 and not gfortran?
what do you mean with multiprocessing? openmp or vectorized?
you can use openmp with the gfortran compiler and when you want to use vector mode like the ifort compiler does, you have to specify sse explicitly in the compiler options.
It seems that the problem was in an error in one of the source files, which wasn't a big deal for Absoft compiler. g77 was giving a warning about it, but compiling this file and producing the original errors (mentioned in the question) without a binary.
When I tried ifort, compilation of that file was aborted, but other files were compiled and a binary was created.
fortcom: Error: somefile.f, line 703: An extra comma appears in the format list. [)]
& (1p5e12.3,5h ...,))
-------------------------^
compilation aborted for somefile.f (code 1)
When I removed the extra comma, then both compilers have compiled everything and created binaries, although ifort produced a number of warnings.
Then, when I tried to run both binaries, the one made by Intel comiler was working fine, but the one by g77 was behaving very strange and didn't really do what I wanted.
So now the original problem is resolved, however the code doesn't run in multiprocessing mode, so the binary is unfortunately useless for me.