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

Download FoX (Fortran XML library)

Luis_Solis
Beginner
922 Views
Hi

I can not compile the library FoX.lib. I have read in a previous thread that this is not possible with current intel fortran compiler version, but this compilation is possible with the GNU compiler. I do not use the gnu compiler and I think it is a difficult task to begin with this problem.

Does anyone know an address where I can download a compiled version of the library?
0 Kudos
10 Replies
Steven_L_Intel1
Employee
922 Views

Please provide a link to where this library is described and the sources provided. I can't readily find it based on your description.
0 Kudos
ArturGuzik
Valued Contributor I
922 Views

Please provide a link to where this library is described and the sources provided. I can't readily find it based on your description.
Luis,

is this library you have in mind? The compatibility matrix there lists IVF 10.1 and claims it needs F95, so it should be possible to make it working.

A.
0 Kudos
Steven_L_Intel1
Employee
922 Views
Actually, it lists "Intel 10.1". Examination of the sources tells me that only a Linux/UNIX build is considered - the configuration and build scripts will not run on Windows (except perhaps under Cygwin, etc.) The sources themselves are probably ok, but there's work to do in order to build on Windows with any compiler.
0 Kudos
Luis_Solis
Beginner
922 Views
Thanks for answerings

Some modules have several compilation directives like these

#if def NAME
#if ndef NAME
#else
#endif

I have translated into

!DEC$ IF DEFINED(NAME)

!DEC$ IF DEFINED(NAME)
!DEC$ ELSE

!DEC$ ELSE
!DEC$ ENDIF

I've incorporated all the modules to a project and tried to build a static library. The compiler returns me multiple errors concerning multiple dependencies between modules.

I do not have enough knowledge to solve this problem otherwise. Any suggestions for learning about this topic?. Maybe I could uninstall my current if 11.1 and test with 10.1. or maybe in the future someone can solve building FoX with intel 11...

Meanwhile, I can work with the library xmlf90-1.2, that I compiled with if 10.1 (my first version of the intel compiler!).

0 Kudos
Kevin_D_Intel
Employee
922 Views
Those translations aren't necessary. I'm looking at this FoX library in relation to a thread (here) from the Linux/Mac OS Fortran forum. I'll poke around into building for Windows too. Stay tuned.....
0 Kudos
thomas_boehme
New Contributor II
922 Views
Those translations aren't necessary. I'm looking at this FoX library in relation to a thread (here) from the Linux/Mac OS Fortran forum. I'll poke around into building for Windows too. Stay tuned.....

I did evaluate the FOX libraries once on Windows. I believe it was back in v10.1 days.

It did compile successfully back then (for the preprocessor directive, you need to enable the C-style pre-processor by setting the option Fortran->Preprocessor->Preprocess Source File to Yes).

However, I remember that it was necessary to increase the stack size when reading anything but really small xml-files. It's possible that using heap arrays would have helped as well.

In the end, it turned out that the FoX libraries DOM-parser gets extremely slow even for moderately sized xml files (e.g. a order of MB).

In the end, we decided touse Microsoft'smsxml6.dll through the COM interface viathe Intel Module Wizard. There are some issues with the module wizard, though. If you are interested, I can give you some workarounds for the issues I observed. Performance is orders of magnitude better than FoX and feature support is very complete.

regards,
Thomas





0 Kudos
Kevin_D_Intel
Employee
922 Views
Quoting - thomas_boehme

In the end, we decided touse Microsoft'smsxml6.dll through the COM interface viathe Intel Module Wizard. There are some issues with the module wizard, though. If you are interested, I can give you some workarounds for the issues I observed. Performance is orders of magnitude better than FoX and feature support is very complete.

regards,
Thomas

Thank youfor sharing Thomas! I believe it would be helpful to offer your workarounds here for others who might consider a similar path.
0 Kudos
thomas_boehme
New Contributor II
922 Views

Thank youfor sharing Thomas! I believe it would be helpful to offer your workarounds here for others who might consider a similar path.

Hi Kevin,

I'll try to outline the process I used to use msxml6.dll via COM interface from my FORTRAN code below. As I did all this a while ago, it will most likely be not 100% complete, but I hope that it will help people get on the "right track"

First of use the Intel Module Wizard to generate the wrapper routines for msxml6.dll. Do this by selecting Tools->Intel Fortran Module Wizard.

Here, select Microsoft XML, v6.0 (should work for older version as well) on the COM tab. If you don't see it, you probably don't have the msxml6.0 runtime installed. You should be able to get it from Microsoft for free.

Click next and select the interfaces that you want to use (or simply all of them) and chose a module name. Selecting finish will create the COM wrapper module.

Unfortunately, this module does not compile out of the box. You need to manually change a few things here:

- remove all the NODE_* definitions in the section ! tagDOMNodeType. These seem to be already defined in IFCOM.
- replace ALL occurences of INTEGER(2), INTENT(OUT) by INTEGER(4), INTENT(OUT). Otherwise you will get errors about differing actual arguments from dummy arguments.

So far, these are fairly straightforward fixes. However, in addition, some function interfaces seem to be generated incorrectly.

As example, the function $IXMLDOMNode_appendChild has its second argument defined as
[plain]INTEGER(INT_PTR_KIND()), INTENT(IN)	:: newChild	! IDispatch
!DEC$ ATTRIBUTES REFERENCE	:: newChild[/plain]
Here, the use of reference seems to be wrong and leads to a crash when calling the function. You need to change the definition to pass by value by changing above lines to
[cpp]INTEGER(INT_PTR_KIND()), INTENT(IN)	:: newChild	! IDispatch
!DEC$ ATTRIBUTES VALUE	:: newChild[/cpp]
I can't provide a full list of functions where you need to do that, but I am quite sure it affects all functions with an XML object (node, element,list,...)as a second argument.

These changes should allow you to compile the COM interface module successfully and use msxml6.dll from you code. For usage, you can look at the C++ documentation of msxml6.dll as usage is quite similar.

In the following, I will post some very simple routines I used for our initial testing to give you some more help to get started using msxml6.dll from FORTRAN (the use msxml6 is the interface module generated with the IVF Module wizard).

I hope this will be to value to some of you.

regards,
Thomas

Usage example:

[plain]	CALL COMInitialize(status)   
                CALL COMCreateObjectByGUID(CLSID_DOMDocument60, CLSCTX_ALL, IID_IXMLDOMDocument2, $xmlDocument, status)
	CALL LoadXMLFile( $xmlDocument, "f:test.xml")	! Load xml file into DOM structure
	CALL XMLAddNamespace( $xmlDocument, "xmlns:def='defaultNS'") ! add default namespace into selection list
	CALL XMLGetString($xmlDocument, '/def:XMLRoot/def:XMLElement[@id="12"], StrRes)

[/plain]
Note that adding adding the default namespace and giving it a short name (here def) is required when your xml-file are using namespaces. The namespace needs to be used for the XPath queries then as well, otherwise, you won't get any results.



[plain]MODULE MSXmlParserCOM
USE msxml6
USE FortranHelpers
CONTAINS
!-------------------------------------------------------------------------------------
  SUBROUTINE LoadXmlFile( $XMLDocument, filename )  
  IMPLICIT NONE
  INTEGER(INT_PTR_KIND()) :: $XMLDocument
  CHARACTER *(*)	      :: filename
  LOGICAL(2)			  :: isSuccessful			
  INTEGER(INT_PTR_KIND()) :: dummy
  type (VARIANT)	      :: variantString   
  variantString = NewStringVariant( filename )
  dummy = $IXMLDOMDocument_load($XMLDocument, variantString, isSuccessful)
  CALL DeleteStringVariant( variantString )
  END SUBROUTINE LoadXmlFile
!-------------------------------------------------------------------------------------
  SUBROUTINE XMLAddNamespace( $XMLDocument, nsToAdd )
  IMPLICIT NONE
  INTEGER(INT_PTR_KIND()) :: $XMLDocument
  CHARACTER *(*)		  :: nsToAdd
  INTEGER(INT_PTR_KIND()) :: dummy
  type (VARIANT)	      :: variantString  
  variantString = NewStringVariant(nsToAdd)
  dummy = $IXMLDOMDocument2_setProperty( $XMLDocument, "SelectionNamespaces", variantString)
  END SUBROUTINE XMLAddNamespace
!-------------------------------------------------------------------------------------
  SUBROUTINE XMLGetString($XMLDocument, xPath, stringValue)
  IMPLICIT NONE
  INTEGER(INT_PTR_KIND())	  :: $XMLDocument
  CHARACTER *(*)			  :: xPath
  CHARACTER *(*)			  :: stringValue
  integer                     :: Status
  integer                     :: length
  INTEGER(INT_PTR_KIND())     :: $XMLNode
  INTEGER(INT_PTR_KIND())     :: $XMLNodeList
$XMLNode = 0
$XMLNodeList = 0 Status = $IXMLDOMNode_selectNodes( $XMLDocument, xPath, $XMLNodeList ) Status = $IXMLDOMNodeList_Getlength( $XMLNodeList, length) IF (LENGTH .EQ. 1) THEN Status = $IXMLDOMNodeList_GetItem( $XMLNodeList, 0, $XMLNode ) Status = $IXMLDOMNode_Gettext($XMLNode, stringValue) END IF ! Clean up (Important, otherwise you'll get memory leaks in msxml6.dll if ($XMLNodeList/=0) Status = COMReleaseObject( $XMLNodeList) if ($XMLNode/=0) Status = COMReleaseObject( $XMLNode ) END SUBROUTINE XMLGetString !------------------------------------------------------------------------------------- type (variant) function NewStringVariant(string) character *(*) string ! Local variable integer (INT_PTR_KIND()) :: pBSTR CALL VariantInit( NewStringVariant ) NewStringVariant%VT = VT_BSTR pBSTR = ConvertStringToBSTR( string ) NewStringVariant%VU%PTR_VAL = pBSTR end function !------------------------------------------------------------------------------------- subroutine DeleteStringVariant( stringVariant ) type (variant) :: stringVariant logical(2) :: res res = VariantClear( stringVariant ) end subroutine END [/plain]

0 Kudos
Kevin_D_Intel
Employee
922 Views

Thank you Thomas. We really appreciate your contributing those details!

There is no update on my attempts to build the FoX Library on Windows, but please visit the thread (here) in our Linux/Mac OS forum for an update regarding current internal errors.
0 Kudos
CharlieG
Beginner
922 Views
Thomas,

Could you also post your test.xml file? I can't quite get my xPath to work and I'd like to see exactly what you were querying.

Thanks,

Charlie Guthrie
0 Kudos
Reply