Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort in ubuntu can not read /* */ sign

gumbira__gugum
Beginner
1,136 Views

Hello,

I am trying to install FVCOM in ubuntu with ifort version 18. after setup the libraries, I try to compile the module and when i type make in the terminal this error showed up. Its look like the ifort cannot read this sign /* */ in the fortran module. I attached the mod_prec.f90 also. any help will be great thank you.

make: Circular mod_prec.o <- mod_prec.o dependency dropped.

/usr/bin/cpp -P -C -traditional  -DIFORT -P -C -traditional    -DWET_DRY -DMULTIPROCESSOR    -DLIMITED_NO  -DGCN                                        mod_prec.F > mod_prec.f90
ifort  -c   -I/home/gugum/Documents/fvcom-4.1/FVCOM4.1/FVCOM_source/libs/install/include        mod_prec.f90
mod_prec.f90(1): error #5082: Syntax error, found '/' when expecting one of: <LABEL> <END-OF-STATEMENT> ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
^
mod_prec.f90(16): error #5145: Invalid blank/tab
   <http://www.gnu.org/licenses/>.  */
----------------------------------^
mod_prec.f90(20): error #5145: Invalid blank/tab
   include it implicitly at the start of every compilation.  It must
-----------------------------------------------------------^
mod_prec.f90(27): error #5120: Unterminated character constant
/* glibc's intent is to support the IEC 559 math functionality, real
--------^
mod_prec.f90(27): error #5144: Invalid character_kind_parameter. No underscore
/* glibc's intent is to support the IEC 559 math functionality, real
--------------------------------------------------------------------^
mod_prec.f90(28): error #5145: Invalid blank/tab
   and complex.  If the GCC (4.9 and later) predefined macros
---------------^
mod_prec.f90(30): error #5277: Syntax error, found ',' following statement keyword
   whether the overall intent is to support these features; otherwise,
----------------------------------------------------------------------^
mod_prec.f90(32): error #5145: Invalid blank/tab
   define these macros by default.  */
----------------------------------^
mod_prec.f90(36): error #5145: Invalid blank/tab
/* wchar_t uses Unicode 8.0.0.  Version 8.0 of the Unicode Standard is
------------------------------^
mod_prec.f90(38): error #5276: Unbalanced parentheses
   2015-05-15).  */
-------------^
mod_prec.f90(38): error #5145: Invalid blank/tab
   2015-05-15).  */
---------------^
mod_prec.f90(40): error #5145: Invalid blank/tab
/* We do not support C11 <threads.h>.  */
-------------------------------------^
mod_prec.f90(1): catastrophic error: Could not recover from previous syntax error
compilation aborted for mod_prec.f90 (code 1)
makefile:42: recipe for target 'mod_prec.o' failed
make: *** [mod_prec.o] Error 1

 

 


 

0 Kudos
8 Replies
jimdempseyatthecove
Honored Contributor III
1,136 Views

Look in the IVF (or the Fortran Standard) documentation and you will find that /* ... */ is not a comment indicator.

However, the IVF pre-processor does support these comment indicators. You may get satisfactory results adding -fpp command line option.

!    comment, all forms, anywhere on line
!, C, or *   comment line, fixed form, column 1
 

Jim Dempsey

0 Kudos
gumbira__gugum
Beginner
1,136 Views

I am sorry. I don't understand your explanation. I just compiling the program with a lot of fortran program by typing "make" command in terminal then it compiling the whole fortran program but not the program with this sign /* */. could you please expand a bit in which part I should place -fpp command as you suggested ?. I use intel fortran compiler in ubuntu to compile the program.  

 

Thanks

0 Kudos
Lorri_M_Intel
Employee
1,136 Views

Ah, this is the source of the problem:

/usr/bin/cpp -P -C -traditional  -DIFORT -P -C -traditional    -DWET_DRY -DMULTIPROCESSOR    -DLIMITED_NO  -DGCN                                        mod_prec.F > mod_prec.f90

This is the C PreProcessor, and does not understand Fortran syntax.

It also is changing a file that is seemingly in Fixed-form into one that is considered free-form.

I looked at your actual file, and you should be able to resolve this by:

1) Remove the "cpp" line I referenced here
2) Change the name of the file in your "ifort" line, to mod_prec.F

      I didn't see any conditional compilation in the file. The extension ".F" will cause the Fortran PreProcessor to be automatically invoked, which should remove your C-style comments.

                         --Lorri

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,136 Views

Your make file will likely have a MAKE variable defined that contains the compiler command line options. For example for the optimization level (-O, -O0, -O1, -O2, or -O3). On this variable definition line you would add -fpp. For example,if the make file defines a MAKE variable for specifying the Fortran options (flags) as:

FFLAGS=-O2

You would add -fpp to the list of options:

FFLAGS=-O2 -fpp

Jim Dempsey

0 Kudos
Steve_Lionel
Honored Contributor III
1,136 Views

And since you seemed uncertain about Jim's reply, I will repeat that  /* and */ are NOT valid Fortran syntax and you should not be using them in Fortran source files.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,136 Views

*** note, Intel Fortran has its own pre-processor, named "fpp".

Use fpp instead of cpp.

*** note 2

The Fortran pre-processor will not convert Fixed Form Fortran files (e.g. mod_prec.F) into Free Form Fortran files (e.g. mod_prec.F90).

While you can use the Intel fpp directly to produce an output file for later compilation by ifort, the Intel Fortran compiler accepts the -fpp option which will, for example, pre-process mod_prec.F into <compiler generated temporary file name>.F, thus preserving the Fixed Form format. The temporary file is then used as the Fortran source file to produce the object file.

Jim Dempsey

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,136 Views

This may work (or be close).

ifort -c -fpp -DIFORT -DWET_DRY -DMULTIPROCESSOR -DLIMITED_NO -DGCN -I/home/gugum/Documents/fvcom-4.1/FVCOM4.1/FVCOM_source/libs/install/include mod_prec.F


The above will pre-process, using fpp, and the -Defines the input file mod_prec.F into a temp file.F and then compile that

Jim Dempsey

0 Kudos
mecej4
Honored Contributor III
1,136 Views

A comment about the title of this thread, which seems to convey an expectation that a Fortran compiler should "read /*..*/"... This expectation is wrong.

Remember that whether you use an external preprocessor such as CPP, FPP, etc., or use the compiler's own preprocessor pass (which you can cause to be run by using options such as -fpp), the output of the preprocessor should be valid Fortran source code. If that is not the case, blame the preprocessor, not the compiler. The built-in Fortran preprocessor of a compiler is limited in its capabilities. You should never expect it to be a full-fledged macro processor.

The file that you posted in #1 is not valid Fortran source code. Either you did not take the CPP output, or your CPP did not work as expected. A C preprocessor should not be expected to be able to handle Fortran source with added directives.

0 Kudos
Reply