- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No - Fortran does not have file scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifcom. I think I've found material that indicates Intel has done such already with VARIANT typing. Sorry.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page