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.
29285 Discussions

declare a type with file scope but not a module

MWind2
New Contributor III
1,179 Views

Can I define a type for file scope without a module as in

type bounds_type
integer lb ! Lower Bound
integer ub ! Upper Bound
end type bounds_type

 

subroutine a()

!uses bounds type

end subroutine 

subroutine a()

!uses bounds type

end subroutine 

 

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,175 Views

No - Fortran does not have file scope.

View solution in original post

0 Kudos
7 Replies
Steve_Lionel
Honored Contributor III
1,176 Views

No - Fortran does not have file scope.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,137 Views

You could use the preprocessor or an INCLUDE file.

! must be compiled with fpp
#define  bounds type bounds_type ; integer :: lb ; integer :: ub ; end type bounds_type

program Console2
    implicit none
    print *, 'Hello World'
end program Console2

subroutine a()
    bounds
    type(bounds_type) :: bt
    bt%lb = 1
end subroutine a

subroutine b()
    bounds
    type(bounds_type) :: bt
    bt%lb = 2
end subroutine b

Note, I tried using the end of line continuation character, but that did not work. ; does work.

 

Use of the Fortran INCLUDE file would be a better approach IMHO

Jim Dempsey

0 Kudos
MWind2
New Contributor III
1,121 Views

I was trying to get the SAFEARRAY dll "cleaner" and pass bounds, but the first iteration uses a module. I must have made a typo as I know now that the dll imports the use <module> routines. Latest version attached, attempt to make one sub and user gets dim and bounds to process. Later will try to get vartype from SAFEARRAY, but it does not seem in ifcon.

0 Kudos
Steve_Lionel
Honored Contributor III
1,116 Views

There isn't a type declared for a SAFEARRAY - the interfaces all reference it as a pointer-sized integer (in other words, an address). Because the structure is variable size, and is also "opaque", it makes more sense to treat it as an opaque pointer.

0 Kudos
Steve_Lionel
Honored Contributor III
1,100 Views

What do you want to do with such a type? There are functions to get and store all the values you need.

I don't understand your reference to "ifcon".

0 Kudos
MWind2
New Contributor III
1,094 Views

ifcom.  I think I've found material that indicates Intel has done such already with VARIANT typing. Sorry.

0 Kudos
Reply