Fortran subroutine overloading with submodules - fortran

I'm learning Fortran and using the Intel compiler.
Here is some code that I wrote. I want to define the print_array interface in the arraytools module, and all the specific implementations (e.g. print_array_rp) should go into a seperate sub-module. The following works, but if I split the implementation into a submodule, I get a huge amount of compiler errors (I suppose it cant find the implementation anymore).
module arraytools
use precision
implicit none
interface print_array
module procedure print_array_rp
end interface
contains
subroutine print_array_rp(arr, fmt_in)
! ... Implementation not important
end subroutine
end module
How do I split print_array_rp off into a sub-module? I don't want to use #include instead.

Submodules are not implemented in current Fortran compilers (unless you happen to be using the Cray compiler).
Only the Cray Fortran compiler implements the entire Fortran 2008 standard (thanks to VladimirF for pointing this out). Among the most poorly supported features among the other compilers are submodules.
The Fortran 2008 status wiki page (last modified Nov 2014 at the time of this post) lists Cray Fortran 8.1.1 as supporting submodules and Absoft 14, gfortran 4.8, HP, ifort 14.1, NAG 5.3.1, Oracle, Pathscale 4 and pgi 14.1 as not supporting submodules. As far as I am aware, none of these compilers has added support for submodules since then.
As noted in the comments below by Steve "Dr. Fortran" Lionel, Intel Fortran will gain submodule support in version 16 to be released later this year.

Related

Possible issue when attempting to use an older gfortran 4.6 version compiler

When a .mod file isn't found by the compiler as in... " set_mod.mod isn't a GFORTRAN module file.." Is this a compiler or simply a remake issue of a new compiler onto a cluster??
The gfortran contributors try to maintain backwards compatibility of the module file format between different versions of the compiler. Unfortunately, there are situations where compatibility cannot be maintained. For example, the introduction of user-defined derived type IO caused an incompatibility, so the module file version number was bumped. Best practice would be to use the same compiler major version number to compile all code (e.g., 4.6.2 and 4.8.3 should be ok). If you jump to a new major version number, recompile everything.

Integration of Rcpp in c++ with bcc compiler

Hi I`m looking for a library in c++ which i compile with the borland compiler bcc32.
Before I tried to take the benefits of RInside but unfortunately it´s only working with gcc-compiler and can´t be used in my programming environment, wich is Embarcadero.
Is it possible to use Rcpp with a bcc32 compiler?
Are there compatitible librarys on the market doing statistical calculations in c++
I hope you can help me. Thanks.
Part 1: no. From the Rcpp FAQ:
1.3. What compiler can I use. On almost all platforms, the GNU
Compiler Collection (or gcc, which is also the name of its
C language compiler) has to be used along with the corresponding
g++ compiler for the
C++ language. ...
The
clang
and
clang++
compilers from the LLVM project can
also be used ...
The Intel
icc
family has also been used successfully as its output
files can also be combined with those from
gcc
.
If it's not on that list, it's not supported.
Part 2: off topic for StackOverflow.

Is Fortran 77 supported by GNU gfortran?

I have come across a book which contains code written in Fortran 77. I wanted to compile and test some of them, and was wondering how well GNU gfortran supports legacy Fortran. I have Ubuntu 14.04 operating system.
Yes gfortran allows for fortran 77 see the docs standard compile options should work but may give warnings. you can set the flag
-std=legacy
to disable warnings that are caused from fortran77 features.

How to install a simple Intel C/C++ compiler on a 64-bit Ubuntu system?

I need to compile c/c++ code, by running a build.sh file.
The instruction on the program (that i want to run) says it needs to be compiled by a Intel's compiler1.
After searching on the net I came across information on what to do.
Some people said that we must install first a 32-bit libraries:
https://help.ubuntu.com/community/InstallingCompilers
Others said that we must, first of any installation, change some things:
http://software.intel.com/en-us/articles/using-intel-compilers-for-linux-with-ubuntu
In the other hand, Intel's page show many suites:
http://software.intel.com/en-us/c-compilers
while the only thing that I want is simply Intel's C/C++ compiler.
Can somebody be so gentle to give me the directions on how to install a Intel's compiler on a 64-bit Ubuntu system?
Footnote 1 / Editor's note: other x86 compilers including GCC and clang (and MSVC on Windows), support Intel's SSE/AVX intrinsic functions, but Intel's compiler comes with some libraries such as SVML (e.g. SIMD sin and exp) and MKL which some code might need. Other compilers can be used with SVML if you have it installed separately.
In short, it's worth trying with other compilers, especially if you understand why something says it needs to be compiled by ICC, if getting ICC would be inconvenient. But you might (or might not) be missing out on performance for packages that detect what's available instead of just erroring.
for non commercial use you can download it from Intel
EDIT:
the Intel® System Studio 2016 includes a c++ compiler.
I've tried the 32-bit version of it, the non-commecial one. I don't think it differ from the 32-bit on basic stuff related to installation. Open this and go to compilers and libraries section and you will see the C/C++ compiler. After download it read the files in doc folder; it includes how to install/use/get a key to compiler etc.
You need to install gcc compiler through apt-get install gcc
Look on example here: Install GCC

C++ compilers and back/front ends

For my own education I am curious what compilers use which C++ front-end and back-end.
Can you enlighten me where the following technologies are used and what hallmarks/advantages they have if any?
Open64 - is it back-end, front-end, or both? Which compilers use it? I encounter it in CUDA compiler.
EDG - as far as I can tell this is a front-end use by Intel compilers and Comeau. do other compilers use it? I found quite a few references to it in boost source code.
ANTLR - this is general parser. Do any common compilers use it?
Regarding compilers:
with front-end/back-end does gcc compiler suite uses? does it have common heritage with any other compiler?
what front-end/back-end PGI and PathScale compilers use?
what front-end/back-end XL compiler uses (IBM offering).
in-depth links on the Internet or your personal know-how would be great.
I did some Google searching, but information I generally encountered was rather superficial.
Thanks.
EDG is a front-end used by Intel and Comeau. See EDG's list of customers for other users.
ANTLR is a parser generator. I'm not aware of any C++ compiler built around a parser that was built with ANTLR (that doesn't mean it couldn't exist though).
GCC is a suite of compilers, with front ends for C, C++, Fortran, Ada, Java, etc., and back-ends for more processors than I'd care to think about.
Open64 is also a suite of compilers including several front-ends (for C, C++, Fortran, and possibly others I don't remember at the moment) and back-ends (targeting X64, Itanium, ARM, and, again, probably others I don't remember and/or don't know about). I believe its origin (pun noted by not intended) is SGI's compiler(s). I seem to remember reading something hinting that Open64 was derived from some version of the GCC front end(s), but offhand I don't know 1) how similar it remains to GCC internally, or 2) the version of GCC from which it derived -- but it's been around long enough that I'd guess it was GCC 3.x at the most recent, and quite possibly GCC 2.x.
I believe PathScale has created at least one compiler derived from Open64, but they may have others as well.
As far as I know, IBM's compiler is entirely their own creation. I'd guess IBM's (now discontinued) VisualAge for C++ shared some heritage/development/code with XL C++, but don't know that for sure, and can't even begin to guess at the extent of it, even assuming it's true.
The Clang project provides new front-ends for C/C++/Objective C on top of the LLVM backend. The LLVM project also provide a LLVM-gcc, using the GCC front end and the LLVM backend. The DragonEgg project seeks to replace the GCC backend with LLVM.
The Codeplay VectorC, Sieve and Offload compilers use a custom front-end and back-end
with front-end/backend does gcc compiler suite uses? does it have common heritage with any other compiler?
The acronym “GCC” stands for “GNU compiler collection” (originally “GNU C compiler”) and this already gives a hint: GNU compilers are a collection of compilers, most notably for C and C++ but also for Fortran, Objective-C and others. They share a common back-end and intermediate representation that was developed for GCC specifically.
The front-ends are all custom-written for the GCC. Some were contributed by third parties, most notably the Objective-C front-end, which was contributed by Apple.
Visual studio uses EDG for its intellisense engine.