Community
cancel
Showing results for 
Search instead for 
Did you mean: 
fobermaier
Beginner
44 Views

Problems compiling preprocessor code

Hello,

I'm investigating to use a hash map implementation I found on github (https://github.com/jl2922/fhash).
The project -as is- compiles fine on my linux machine using gfortran.

If I add the relevant files to an empty intel visual fortran project, enable preprocessing the compiler produces lots of errors all around lines like the following:

public :: fhash_type__/**/SHORTNAME

https://github.com/jl2922/fhash/blob/master/fhash.f90#L21

It seems that the preprocessor includes a whitespace:
error #5082: Syntax error, found IDENTIFIER 'INTS_DOUBLE' when expecting one of: , (/ ( <END-OF-STATEMENT> ;
  public :: fhash_type__ ints_double

If I remove all "/**/" , the compiler produces only 5 errors, all of them being "The procedure whose second dummy argument has the ALLOCATABLE or POINTER attribute cannot be invoked via defined assignment (=) [INTS_PTR_ASSIGN]"

If I change the defined assignment function to not use pointer assingment, the project still does not compile because now there are two of this errors 

error #5509: Declaration of module 'FHASH_MODULE__SHORTNAME' conflicts with a previous declaration
module fhash_module__SHORTNAME

I'm Compiling with Intel(R) Visual Fortran Compiler 18.0.2.185 [IA-32]... 

Thanks in advance

Felix

 

0 Kudos
2 Replies
IanH
Black Belt
44 Views

Replacing a comment with a single space is the standard behaviour for the C preprocessor.  A vendor specific "Fortran preprocessor" may have different rules, but then it is vendor specific.

The dummy argument for the right hand side in the defined assignment having the pointer attribute is an error with that source.

The approach taken with this code assumes that a uniquely named module will be generated for each type - when you delete the /**/SHORTNAME part you break that assumption. 

You might be able to chop the module statement out of the fhash.f90 file, and set up the naming yourself, i.e.

....

module you_choose_the_name_manually
! Delete the opening module statement out of the included file
#include "fhash.f90"

...

I prefer to just avoid the preprocessor, and rely instead on Fortran INCLUDE and use statement renaming for this sort of stuff, but there are some limitations.

fobermaier
Beginner
44 Views

I was able to follow your advice and make the precompiler fhash.f90 in the specific type modules.

The code compiles all right, works all right but compared to the original benchmark in fhash_test.f90 it takes more than twice as long.
Any idea what could be the cause for this?

Thanks in advance

Felix

Reply