- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I am pretty new to Fortran and fail since a few days to a initial problem.
I am not able to bring data given by a xml file to my Fortran program.(Matrices)
I have data provided in an XML file.
It is structured something like:
<FIELDNAME>
<ROWS>?</ROWS>
<COLS>?</COLS>
<DATA>?</DATA>
</FIELDNAME>
...then comes the next <FIELDNAME> ... ... ... ? represents a double(kind=8)
I have written a parser in vb.net and now i am able to create a *.dat file in every way i like it.
My newest attempt is simply structured like:
FIELDNAME as character(10)
NUMBER OF ROWS as character(10)
NUMBER OF COLUMNS as character(10)
?(1,1)
?(2,1)
... ... ... till the next FIELDNAME ... ... ... ? represents a double(kind=8)
In the file it looks like:
MATRIX1
3.0
3.0
1.0E-18
2.0
3
4.0E+5
5.0
6.0
7.0
8.0
9.0
MATRIX2
...
...
...
The FIELDNAMEs are always the same ~30 Fieldnames in the same order containing Martices.
I thought it would be easy to bring the data into my program cause i can format it as i wish in vb.net but i fail. I also fail when i try to do it with vb.net and try to pass the arrays to fortran as such(I don't want to do it this way anymore cause all description i found in the internet are done like kidding me.) Using FoX compiled under VisualStudio to read from the input.xml itself also was not possible. I've wastet several days to this.
Has someone an Code example or something similar for me how this, in this case "initial step" can be done?
I would be very glad if someone could help me!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will not bother to comment on XML data files or the use of VB programs to convert XML to simpler text files, but you may want to consult available XML libraries if you want to do this.
Assuming that you have the data in the format that you showed, we can do the following. First, show the matrix size using integers rather than real numbers. That is, your second and third lines should contain "3", not "3.0". Flesh out and run the Fortran program below, and make it read your formatted data file as standard input.
program readmat implicit none integer :: nrows,ncols real, dimension(:,:), allocatable :: M1, M2 character(10) :: matname ! read(*,'(A)')matname read(*,*)nrows read(*,*)ncols ! allocate(M1(nrows,ncols)) read(*,*)M1 !
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will not bother to comment on XML data files or the use of VB programs to convert XML to simpler text files, but you may want to consult available XML libraries if you want to do this.
Assuming that you have the data in the format that you showed, we can do the following. First, show the matrix size using integers rather than real numbers. That is, your second and third lines should contain "3", not "3.0". Flesh out and run the Fortran program below, and make it read your formatted data file as standard input.
program readmat implicit none integer :: nrows,ncols real, dimension(:,:), allocatable :: M1, M2 character(10) :: matname ! read(*,'(A)')matname read(*,*)nrows read(*,*)ncols ! allocate(M1(nrows,ncols)) read(*,*)M1 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many Thanks! Now everything works. This looks so easy when you know how!
![](/skins/images/872293744008A34B36F8ABF94A46CC66/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page