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

Error: This USE statement is not positioned correctly within the scoping unit.

arthur_amarra
Beginner
4,290 Views
I keep getting this error, and I have no idea why. The program is in a very standard structure:


      PROGRAM SIMILAR

include 'mkl.fi'
include 'mkl_lapack.fi'
include 'mkl_blas.fi'
use inoutch_module
use filePathModule
use globalDataModule
use solution_control
use glb_mesh
use subdomains
use NumericalIntgTableModule
c
implicit none
.....rest of code
END PROGRAM SIMILAR

and here's an example of the module:

module inoutch_module
save
c integer ichinp,ichout,ichmtx,ichstr,ichsta,ichwrl,ichplt,ichbdf
integer :: ich
integer, parameter :: iin=5
integer, parameter :: iout=6
integer, parameter :: ichinp=7
integer, parameter :: ichout=8
integer, parameter :: ichmtx=12
c integer, parameter :: ichstr=16
integer, parameter :: ichplt=18
integer, parameter :: ichsta=20
c integer, parameter :: ichwrl=22
integer, parameter :: ichbdf=26
integer, parameter :: ichtfd=27
integer, parameter :: ichmatlab=28
end module inoutch_module

So what's going on?? the error i get is this:

fortcom: Error: Main.f, line 20: This USE statement is not positioned correctly within the scoping unit.
use inoutch_module
------^


0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
4,290 Views

"USE YourModule" must preceed local variable declarations. Your include file (at least one of your include files) is declaring at least one variable.

Place your USE to preceed the include statements.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
4,290 Views
USE also must precede any IMPLICIT statements. Best is to have them come directly after the SUBROUTINE or FUNCTION statement.
0 Kudos
arthur_amarra
Beginner
4,290 Views
Thanks!
0 Kudos
Reply