Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
kaffee46
Total Points:
140
Status Points:
90
Green Belt
June 27, 2009 5:49 AM PDT
Read ASCII File with QuickWIN (CVF) and write it
Hi to everybody,

i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:

Tiefe   cC      Härte     RA
0.000  0.706  63.445  5.125
0.016  0.707  63.417  5.189
0.032  0.709  63.388  5.254
0.048  0.711  63.360  5.319
0.064  0.713  63.331  5.385
0.080  0.714  63.302  5.450
0.096  0.716  63.274  5.516
0.112  0.717  63.245  5.582
0.128  0.719  63.216  5.648
0.144  0.721  63.187  5.713
0.160  0.722  63.159  5.779

For me interesting is only column one and two (Tiefe and Cc).

I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...

Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.

SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE

LOGICAL checked
INTEGER ind

CALL ImportAsciiOpenFileNameStruktur('Wähle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*)          ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF

RETURN
END

FIND HERE THE SUBROUTINE "ZeigeErgebnisse"

SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind

6000 FORMAT(F20.3,3X,F20.3)

DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO

RETURN
END

I hope somebody is able give me an advice or correct my code...

Thanks
Marco
anthonyrichards
Total Points:
4,282
Status Points:
3,782
Brown Belt
June 27, 2009 3:50 PM PDT
Rate
 
#1
Quoting - kaffee46
Hi to everybody,

i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:

Tiefe   cC      Härte     RA
0.000  0.706  63.445  5.125
0.016  0.707  63.417  5.189
0.032  0.709  63.388  5.254
0.048  0.711  63.360  5.319
0.064  0.713  63.331  5.385
0.080  0.714  63.302  5.450
0.096  0.716  63.274  5.516
0.112  0.717  63.245  5.582
0.128  0.719  63.216  5.648
0.144  0.721  63.187  5.713
0.160  0.722  63.159  5.779

For me interesting is only column one and two (Tiefe and Cc).

I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...

Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.

SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE

LOGICAL checked
INTEGER ind

CALL ImportAsciiOpenFileNameStruktur('Wähle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*)          ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF

RETURN
END

FIND HERE THE SUBROUTINE "ZeigeErgebnisse"

SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind

6000 FORMAT(F20.3,3X,F20.3)

DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO

RETURN
END

I hope somebody is able give me an advice or correct my code...

Thanks
Marco

Remove the ! from READ(FUNIT,*)    !XV(IND), YV(Ind)
as you have made your variables into a comment!

kaffee46
Total Points:
140
Status Points:
90
Green Belt
June 28, 2009 5:38 AM PDT
Rate
 
#2 Reply to #1
Quoting - anthonyrichards

Remove the ! from READ(FUNIT,*)    !XV(IND), YV(Ind)
as you have made your variables into a comment!

Hi,

thanks, but if i do this, the is "Error Window" if i try to open the ASCII File and the program crashes.
If i only use

READ(FUNIT,*)

the following is shown in the screen:

0.000   0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000

The values of my ASCII FIle are not shown...


Thanks



anthonyrichards
Total Points:
4,282
Status Points:
3,782
Brown Belt
June 28, 2009 12:51 PM PDT
Rate
 
#3 Reply to #2
I think we need to see what is in the module IMPORTASCIIGENERAL as it appearsthat all your variables are declared there.



mavlik
Total Points:
440
Status Points:
390
Green Belt
June 28, 2009 2:12 PM PDT
Rate
 
#4 Reply to #2
Try this
program testread

implicit none
INTEGER*4 I,J,TT
INTEGER*4 NDIS,NLEC,NCON
REAL*4 TIEFE(1000)
REAL*4 cC(1000)
REAL*4 Harte(1000)
REAL*4 RA(1000)
J = 0
NDIS = 1
OPEN (NDIS, FILE = 'ASCIIDATA.TXT')
DO WHILE (.NOT. EOF(1))
J = J + 1
READ (1, *) TIEFE(j), cC(J), Harte(j), RA(j)
WRITE(NCON,*) cC(j)
END DO
CLOSE(NDIS)

end program testread

ASCIIDATA.txt:
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779


Luis Solis
Total Points:
55
Status Points:
5
Green Belt
June 28, 2009 2:32 PM PDT
Rate
 
#5
if you have the names of the columns in the first row...

program main
real, dimension(25):: x,y
integer:: i
open(unit=33,file='foo.txt',action='read') !...
i=-1
do while (.not.eof(33))
i=i+1
if (i==0) then
read(33,*)
else
read(33,*) x(i),y(i) !...iostat
endif
enddo
end program

--------
Luis Solis


kaffee46
Total Points:
140
Status Points:
90
Green Belt
June 30, 2009 9:54 AM PDT
Rate
 
#6 Reply to #4
.
Quoting - mavlik
Try this
program testread

implicit none
INTEGER*4 I,J,TT
INTEGER*4 NDIS,NLEC,NCON
REAL*4 TIEFE(1000)
REAL*4 cC(1000)
REAL*4 Harte(1000)
REAL*4 RA(1000)
J = 0
NDIS = 1
OPEN (NDIS, FILE = 'ASCIIDATA.TXT')
DO WHILE (.NOT. EOF(1))
J = J + 1
READ (1, *) TIEFE(j), cC(J), Harte(j), RA(j)
WRITE(NCON,*) cC(j)
END DO
CLOSE(NDIS)

end program testread

ASCIIDATA.txt:
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779

Hi and thanks for your replies,

i tried to built the program similar to mavlik´s "testread", unfortunately it did not work. I think i made some mistakes because i tried to use my subroutine "ZeigeErgebnisse". Mavlik only used "write". Can somebody help me to integrate the "call ZeigeErgebnisse" SUBROUTINE Mavliks code?

Furthermore more i need some help with the subroutine "ZeigeErgebnisse". I think i have to costumize this code... "ZeigeErgebnisse" will not work, if it stays like this...i have to adjust it to Mavliks code!?!

SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind

6000 FORMAT(F20.3,3X,F20.3)

DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO

RETURN
END


Thanks a lot to everybody of you!

Marco



anthonyrichards
Total Points:
4,282
Status Points:
3,782
Brown Belt
June 30, 2009 10:58 AM PDT
Rate
 
#7 Reply to #6
please attach the module Importasciigeneral, then we might be able to see what's wrong.



kaffee46
Total Points:
140
Status Points:
90
Green Belt
July 1, 2009 10:58 AM PDT
Rate
 
#8 Reply to #7
Quoting - anthonyrichards
please attach the module Importasciigeneral, then we might be able to see what's wrong.



Hi, find attached to more Modules, which are required:

MODULE ImportAsciiGeneral

USE DFWIN
USE DFLIB
USE DFWINTY
USE ModuleImportAscii
USE DFLOGM

INCLUDE 'RESOURCE.FD'

LOGICAL :: lRet
INTEGER :: iRet, TextLen
INTEGER, PARAMETER :: qwUErg = 77
CHARACTER (LEN=80) :: Text

TYPE (T_OPENFILENAME) :: OF

END MODULE


MODULE ModuleImportAscii


INTEGER, PARAMETER :: dimV = 50, FUNIT = 7
Real*4 xV(dimV), yV(dimV)

CHARACTER (LEN=256) :: TxtFile = ''C
INTEGER, PARAMETER :: nFilter = 2

CHARACTER (LEN=*), PARAMETER :: FileFilter = 'Kohlenstofftiefenverlauf *.txt'C // '*.txt'C
CHARACTER (LEN=*), PARAMETER :: FileDefExt = 'Txt'C

END MODULE






Intel Software Network Forums Statistics

8442 users have contributed to 31547 threads and 100375 posts to date.
In the past 24 hours, we have 10 new thread(s) 34 new posts(s), and 45 new user(s).

In the past 3 days, the most popular thread for everyone has been /fpp interferes with breakpoints/stepping through code - again The most posts were made to Help with hitting maximum record length in the compiler with debug info? The post with the most views is You could save the pre-proce

Please welcome our newest member mrnm