Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
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 Discussões

declare a type with file scope but not a module

MWind2
Novo colaborador III
1.184 Visualizações

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 Solução
Steve_Lionel
Colaborador honorário III
1.180 Visualizações

No - Fortran does not have file scope.

Ver solução na publicação original

7 Respostas
Steve_Lionel
Colaborador honorário III
1.181 Visualizações

No - Fortran does not have file scope.

jimdempseyatthecove
Colaborador honorário III
1.142 Visualizações

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

MWind2
Novo colaborador III
1.126 Visualizações

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.

Steve_Lionel
Colaborador honorário III
1.121 Visualizações

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.

Steve_Lionel
Colaborador honorário III
1.105 Visualizações

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".

MWind2
Novo colaborador III
1.099 Visualizações

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

Responder