Closed hkp888 closed 5 years ago
As always with fortran, don't mix compilers where you are using modules.
I.e. compile fdict with intel compiler.
Okay, I made my setup.make file as follows:
FC=ifort FFLAGS = -g
When I create the library, I get this:
VPATH="." ./src/variable.sh
ifort -E -P -x c -I./src -I./src -I. ./src/variable_pp.F90 | sed -f ./src/filter.sed > variable.f90
ifort: command line warning #10155: ignoring option '-x'; argument required
ifort: error #10236: File not found: 'c'
ifort -c -o variable.o -g variable.f90
VPATH="." ./src/dictionary.sh
ifort -E -P -x c -I./src -I./src -I. ./src/dictionary_pp.F90 | sed -f ./src/filter.sed > dictionary.f90
ifort: command line warning #10155: ignoring option '-x'; argument required
ifort: error #10236: File not found: 'c'
ifort -c -o dictionary.o -g dictionary.f90
ar -ru libfdict.a variable.o dictionary.o
ar: creating libfdict.a
ranlib libfdict.a
However, since the library folders are there, I tried compiling my program. It no longer spits out the error from the post above, but I get this:
subroutine1.f90(39): error #6767: No matching user defined OPERATOR with the given type and rank has been defined. [KV]
dict_1 = dict_1 // (key_string .kv. value1 )
---------------------------------^
subroutine1.f90(39): error #6054: A CHARACTER data type is required in this context. [DICT_1]
dict_1 = dict_1 // (key_string .kv. value1 )
----------^
subroutine1.f90(39): error #6303: The assignment operation or the binary expression operation is invalid for the data types of the two operands.
dict_1 = dict_1 // (key_string .kv. value1 )
----------------^
subroutine2.f90(55): error #6285: There is no matching specific subroutine for this generic subroutine call. [ASSIGN]
call assign(some_variable, dict_1, key_string1)
------^
Could these errors be due to the error in the library compilation? ifort: error #10236: File not found: 'c'
?
Could you try simply doing:
make VENDOR=intel
That should work.
Otherwise you could add:
FPP = ifort -E -P -xc
to your setup.make
file.
Thank you, Nick.
This is what I get if I use make VENDOR=intel
to create the library:
VPATH="." ./setup.sh --default
VPATH="." ./src/variable.sh
ifort -E -P -x c -I./src -I./src -I. ./src/variable_pp.F90 | sed -f ./src/filter.sed > variable.f90
ifort: command line warning #10155: ignoring option '-x'; argument required
ifort: error #10236: File not found: 'c'
ifort -c -o variable.o variable.f90
VPATH="." ./src/dictionary.sh
ifort -E -P -x c -I./src -I./src -I. ./src/dictionary_pp.F90 | sed -f ./src/filter.sed > dictionary.f90
ifort: command line warning #10155: ignoring option '-x'; argument required
ifort: error #10236: File not found: 'c'
ifort -c -o dictionary.o dictionary.f90
ar -ru libfdict.a variable.o dictionary.o
ar: creating libfdict.a
ranlib libfdict.a
And if I add FPP = ifort -E -P -xc
to the setup.make, I get:
VPATH="." ./setup.sh --default
VPATH="." ./src/variable.sh
ifort -E -P -xc -I./src -I./src -I. ./src/variable_pp.F90 | sed -f ./src/filter.sed > variable.f90
ifort: command line warning #10130: unknown extension 'c' ignored in option '-x'
ifort -c -o variable.o -g variable.f90
VPATH="." ./src/dictionary.sh
ifort -E -P -xc -I./src -I./src -I. ./src/dictionary_pp.F90 | sed -f ./src/filter.sed > dictionary.f90
ifort: command line warning #10130: unknown extension 'c' ignored in option '-x'
ifort -c -o dictionary.o -g dictionary.f90
ar -ru libfdict.a variable.o dictionary.o
ar: creating libfdict.a
ranlib libfdict.a
Then if I try to link the library and compile my program:
error #7002: Error in opening the compiled module file. Check INCLUDE paths. [DICTIONARY]
use dictionary
----^
error #7002: Error in opening the compiled module file. Check INCLUDE paths. [VARIABLE]
use variable
:(
Which version of the Intel compiler are you using?
I was using 2013.2, but I also tried the 2015 and 2016 versions. It looks like the -xc flag is not recognized. What is its purpose?
The -xc
flag is to force intel compilers to pre-process fortran files as C
source. Not always needed, but sometimes I have found this to be required.
1) You should proceed with the 2nd option in the previous comments. I.e. FPP = ifort -E -P -xc
, although a warning is issued I don't have any problems in the later linking step.
2) I think you are linking incorrectly since the error is that the compiler can't find the module file at all. Could you post all directories and command line for linking with your application?
3) I never answered your PS comment initially. My recommendation for compiling stuff is that your main application has a clear separation of used libraries and the application libraries.
app: app.o
$(FC) -o app app.o $(LIBS)
FDICT_PATH = /path/to/fdict/parent
FDICT_LIBS = -L$(FDICT_PATH) -lfdict
FDICT_INC = -I$(FDICT_PATH)
INCLUDE += $(FDICT_INC)
LIBS += $(FDICT_LIBS)
In this way all paths from different sub-projects are clearly separated. I hope this clarifies
Sorry for the delay. I could only get back to this post now.
The way I've been trying to link is with the lines below in a file called build.sh
located in my application directory (/project/). The library directory fdict-master
is inside my Fortran application directory:
#!/bash/bin
FDICT_PATH=/project/fdict-master/
FDICT_LIBS=-L$(FDICT_PATH) -lfdict
FDICT_INC=-I$(FDICT_PATH)
INCLUDE+=$(FDICT_INC)
LIBS+=$(FDICT_LIBS)
ifort -O3 -openmp -c -traceback *.f90
ifort -O3 -openmp -c -traceback *.F90
ifort -O3 -openmp -o NU_Trans *.o $(LIBS)
Then I run it with source build.sh
You should probably do:
#!/bash/bin
FDICT_PATH=/project/fdict-master/
FDICT_LIBS=-L$(FDICT_PATH) -lfdict
FDICT_INC=-I$(FDICT_PATH)
INCLUDE+=$(FDICT_INC)
LIBS+=$(FDICT_LIBS)
ifort -O3 -openmp -c -traceback *.f90 $(INCLUDE)
ifort -O3 -openmp -c -traceback *.F90 $(INCLUDE)
ifort -O3 -openmp -o NU_Trans *.o $(LIBS)
I must say that I compiled and installed the library following the initial guidelines in the readme section of this repository:
FC=gfortran FFLAGS = -g
make
.make PREFIX=/path/to/fdict install
My fortran project, however, is compiled with ifort in a bash file as follows:
ifort -O3 -openmp -c -traceback *.f90 ifort -O3 -openmp -o project_name *.o
I tried modifying the bash file to link the library as follows:
ifort -O3 -openmp -c -I$"/path/to/include/" -traceback *.f90 ifort -O3 -openmp -o project_name *.o $"/path/to/lib/libfdict.a"
However I get this error:
This module file was not generated by any release of this compiler. [DICTIONARY] use dictionary
The same error is shown foruse variable
.P.S.: I know you recommended using the code below in a makefile to link the library to the program, but I do not understand how to do it. In what folder do I create this makefile? How does this interact with my program?
FDICT_PATH = /path/to/fdict/parent FDICT_LIBS = -L$(FDICT_PATH) -lfdict FDICT_INC = -I$(FDICT_PATH)
Thank you