Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Compile module with fotran code

james_uta
Beginner
2,508 Views
I have a fortran code including module files and fortran source code files as follows
main.f
====================================

PROGRAM MAIN
USE MODDULECOM
USE MODDULEPARA


CALL LOAD_PARA
ALLOCATE(
+ NAMEP(NPM)
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
+ )

STOP
C
END
======================================
load_para.f
======================================

SUBROUTINE LOAD_PARA
USE MODULEPARA
NXM = 200
NYM = 200
NZM = 5
NPM = 4

NBM = NXM * NYM * NZM
END
====================================
modulecom.f
====================================

MODULE MODULECOM


CHARACTER*14,ALLOCATABLE ::
+ NAMEP(:)
CHARACTER*14
+ VERSION

INTEGER, ALLOCATABLE ::
+ NPHASE(:), INDPH(:), IFLASH(:)
+ ,NBLK(:,:), NBLKUP(:,:,:)

END MODULE MODULECOM
================================
modulepara.f
================================
MODULE MODULEPARA
INTEGER
+ NXM, NYM, NZM, NPM, NCM, NWM, NBWM, NS1M
+ ,NPRM, NPFM, NCTM, NHSM, NBM, NBM3, NBPM
+ ,NBPCM, NBNS1M, NCM2, NCMP1, NCPM2, NCMT
+ ,NBPCMT, NCWMT, NBCMT , NWBCM, NREG, NTAB
+ ,NZPM,NUMAUX,IC2,INQUA,INCON,INVEL,NOSWTM
+ ,NUMPRE,NUMOUT,NCVECT,NUMPVT,NHES,NPWM,NCWM
+ ,NCP1W,NST,NCCM, NBCM,IFLIP
END MODULE MODULEPARA
=========================================
makefile
=========================================

FFLAGS = -r8 -O3 -Bstatic
LFLAGS = -r8 -O3 -Bstatic

FMOD = modulecom.f modulepara.f
FSRCS = load_para.f main.f


FOBJM = $(FMOD:.f=.o)
FOBJS = $(FSRCS:.f=.o)
PROG = main.exe
FC = ifort

$(PROG): $(FOBJM) $(FOBJS)
$(FC) $(LFLAGS) -o $(PROG) $(FOBJM) $(FOBJS)

clean :
rm -f *.o main.exe
=========================================
compilation errors
=========================================
ifort -r8 -O3 -Bstatic -c -o modulecom.o modulecom.f
ifort -r8 -O3 -Bstatic -c -o modulepara.o modulepara.f
ifort -r8 -O3 -Bstatic -c -o load_para.o load_para.f
ifort -r8 -O3 -Bstatic -c -o main.o main.f
fortcom: Error: main.f, line 3: Error in opening the Library module file. [MODDULECOM]
USE MODDULECOM
----------^
fortcom: Error: main.f, line 4: Error in opening the Library module file. [MODDULEPARA]
USE MODDULEPARA
----------^
fortcom: Error: main.f, line 9: An allocate/deallocate object must have the ALLOCATABLE or POINTER attribute. [NAMEP]
+ NAMEP(NPM)
---------^
fortcom: Error: main.f, line 9: The rank of the allocate-shape-spec-list differs from the rank of the allocate-object. [NAMEP]
+ NAMEP(NPM)
---------^
fortcom: Error: main.f, line 10: An allocate/deallocate object must have the ALLOCATABLE or POINTER attribute. [NPHASE]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
---------^
fortcom: Error: main.f, line 10: The rank of the allocate-shape-spec-list differs from the rank of the allocate-object. [NPHASE]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
---------^
fortcom: Error: main.f, line 10: An allocate/deallocate object must have the ALLOCATABLE or POINTER attribute. [INDPH]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
---------------------^
fortcom: Error: main.f, line 10: The rank of the allocate-shape-spec-list differs from the rank of the allocate-object. [INDPH]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
---------------------^
fortcom: Error: main.f, line 10: An allocate/deallocate object must have the ALLOCATABLE or POINTER attribute. [IFLASH]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
--------------------------------^
fortcom: Error: main.f, line 10: The rank of the allocate-shape-spec-list differs from the rank of the allocate-object. [IFLASH]
+ ,NPHASE(NBM),INDPH(NBM),IFLASH(NBM)
--------------------------------^
compilation aborted for main.f (code 1)
make: *** [main.o] Error 1


Please help me, thanks in advance.

James_UTA

0 Kudos
1 Solution
amit-amritkar
New Contributor I
2,508 Views
Quoting - tim18
I tried to respond earlier. Admittedly, examples of Makefiles for .mod files are few and difficult to find by web search.
http://www.fesb.hr/~psarajce/Makefiles.html
You need at least a rule for making the .mod files and to show them in the dependencies list.
There are Makefiles in the ifort installation for building .mod files, e.g. for lapack95.
I don't know if you have figured this out yet or not but you have typos in your USE statement.
MODDULECOM -- MODULECOM etc.
I think if you fix this your code should compile.

View solution in original post

0 Kudos
5 Replies
TimP
Honored Contributor III
2,508 Views
I tried to respond earlier. Admittedly, examples of Makefiles for .mod files are few and difficult to find by web search.
http://www.fesb.hr/~psarajce/Makefiles.html
You need at least a rule for making the .mod files and to show them in the dependencies list.
There are Makefiles in the ifort installation for building .mod files, e.g. for lapack95.
0 Kudos
amit-amritkar
New Contributor I
2,509 Views
Quoting - tim18
I tried to respond earlier. Admittedly, examples of Makefiles for .mod files are few and difficult to find by web search.
http://www.fesb.hr/~psarajce/Makefiles.html
You need at least a rule for making the .mod files and to show them in the dependencies list.
There are Makefiles in the ifort installation for building .mod files, e.g. for lapack95.
I don't know if you have figured this out yet or not but you have typos in your USE statement.
MODDULECOM -- MODULECOM etc.
I think if you fix this your code should compile.
0 Kudos
james_uta
Beginner
2,508 Views
Quoting - Amit
I don't know if you have figured this out yet or not but you have typos in your USE statement.
MODDULECOM -- MODULECOM etc.
I think if you fix this your code should compile.

It works now with the correction of theerror, appreciate your great help.
0 Kudos
james_uta
Beginner
2,508 Views
Quoting - tim18
I tried to respond earlier. Admittedly, examples of Makefiles for .mod files are few and difficult to find by web search.
http://www.fesb.hr/~psarajce/Makefiles.html
You need at least a rule for making the .mod files and to show them in the dependencies list.
There are Makefiles in the ifort installation for building .mod files, e.g. for lapack95.

Thanks Tim18 for your suggestion.
0 Kudos
james_uta
Beginner
2,508 Views
Quoting - Amit
I don't know if you have figured this out yet or not but you have typos in your USE statement.
MODDULECOM -- MODULECOM etc.
I think if you fix this your code should compile.
Hi Amit, could you please take a look at my another posted question as follows?

Home Forums Intel Fortran Compiler for Linux and Mac OS* X Help on mixed programming Fortran and C with intel fortran

I still can not figure it out, thanks in advance.

James

0 Kudos
Reply