Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: How to read *.res file using fortran

How to read *.res file using fortran 12 years 3 months ago #5279

  • hong
  • hong's Avatar
Hi, there~

I need to use fortran to read the result file to make some analyses.

According to the Appendix 3 in the manual, I can read the data before IPARAM at present.

But the work couldn't carry on because I don't know how many bytes of integers every IPARAM is.

So is anyone good enough to tell me how I can move on?

Besides, it is said in the manual that IPARAM(3) and IPARAM(4) correspond to x and y coordinates of the origin of the mesh if they don't equal to zero. In my opinion, the coordinates are usually reals. So my problem is why the two IPARAMs are defined integers?

Thanks in advance.

Best regards
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5282

  • jmhervouet
  • jmhervouet's Avatar
Hello,

IPARAM(3) and (4) are really integers (origin in metres, when the coordinate system gives very big numbers that may cause problems, an integer number of metres is removed in the computation, in other words the origin is changed).

If you define :

INTEGER IPARAM(10)

you can read it in the following form :

READ(the logical unit,END=..., ERR=...) (IPARAM(K), K=1,10)

Note that :

READ(the logical unit)

would just jump the record and go to the next record.

With best regards,

Jean-Michel Hervouet
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5283

  • hong
  • hong's Avatar
Thank you, Jmhervouet.

But I still can't figure it out.

As you know, the res file is an ASCII file.

So I use direct access to read the infomation.

That's why I need to know the length of IPARAMs.

The method you told me belong to serial access, I think. So they conflict.

This is my first time to read ASCII file,so would you please explain more?

Appreciate it a lot.

Best wishes
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5284

  • jmhervouet
  • jmhervouet's Avatar
Hello,

No, the results file is a binary file. You can see example of how to read this file in the library bief (subroutines readgeo1, readgeo2 and readgeo3, all calling subroutine lit where the real job with READ statement is.

Regards,

JMH
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5285

  • hong
  • hong's Avatar
Sorry, what I wanted to say is not"ACSII file" but "binary file"

Thanks again for your suggestion~
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5296

  • hong
  • hong's Avatar
Hello,Jmhervouet.

Referring to the readgeo.f files, I tried to read the res file with serial access.

But I couldn't even read the first record including title and format at all.

I defined two character variables TITLE(len=72) and FORMAT(len=8)

and read them with the sentence

READ(the logical unit,END=..., ERR=...)TITLE(1:72).

And a read error occured.

I have no idea what's the reason.

Could you please check it for me?

Thanks a lot.
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5297

  • jmhervouet
  • jmhervouet's Avatar
Hello,

The logical unit in the case of the geometry file is 1, except in coupling, it is also : T2D_FILES(T2DGEO)%LU.

The title in the SERAFIN FORMAT is 80 characters, so you'd better define TITLE with a size of 80, and then do :

FORMAT=TITLE(73:80)

You cannot read TITLE and then FORMAT as 72 and then 8 characters, because it would meant 2 records, whereas TITLE is only one record.

If it does not work we would need to see your Fortran.

With best regards,

JMH
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5298

  • hong
  • hong's Avatar
Thank you, Jmhervouet.
The fortran file is as following(making use of most sentences in the readgeo1.f)


INTEGER :: NPOIN ! NUMBER OF MESH NODES
INTEGER :: NELEM ! NUMBER OF ELEMENTS
INTEGER :: NDP ! NUMBER OF ELEMENT FACES
INTEGER :: IB(10) ! INTEGER ARRAY
INTEGER :: NPTFR ! NUMBER OF BOUNDARY NODES
INTEGER :: NFIC ! FILE TO READ
INTEGER :: NELEBD ! NUMBER OF BOUNDARY ELEMENTS
!
!+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!
DOUBLE PRECISION :: XB(2)
REAL :: RB(2)
INTEGER :: ISTAT
INTEGER :: NVAR
INTEGER :: I,IB6(6)
CHARACTER(LEN=2) :: CB
CHARACTER(LEN=80) :: TITLE
C CHARACTER(LEN=8) :: FORMATT
!
!
!
! GOES TO THE BEGINNING OF THE FILE
rewind(10)
open(10,file='wq3.res',form='unformatted')
WRITE(*,*)'OK1'
!
! 1: TITLE
c CALL LIT(XB,RB,IB,TITRE,72,'CH',NFIC,'STD',ISTAT)
READ(10,END=100,ERR=101) TITLE(1:80)
WRITE(*,*)'OK2'
WRITE(*,*) TITLE(1:80)
!
! 2: NUMBER OF ARRAYS IN THE RESULT FILE
C CALL LIT(XB,RB,IB,CB,2,'I ',NFIC,'STD',ISTAT)
READ(10,END=100,ERR=101)(IB(J),J=1,2)
WRITE(*,*)(IB(J),J=1,2)
NVAR = IB(1) + IB(2)
! 3: NAMES AND UNITS OF VARIABLES
IF(NVAR.GE.1) THEN
DO I=1,NVAR
C CALL LIT(XB,RB,IB,CB,2,'CH',NFIC,'STD',ISTAT)
READ(10,END=100,ERR=101) CB(1:2)
WRITE(*,*)CB(1:2)
ENDDO
ENDIF
!
! 4: LIST OF 10 INTEGER PARAMETERS
C CALL LIT(XB,RB,IB,CB,10,'I ',NFIC,'STD',ISTAT)
READ(10,END=100,ERR=101)(IB(J),J=1,10)
WRITE(*,*)(IB(J),J=1,10)
!
! CASE WHERE DATE AND TIME ARE IN THE FILE
IF(IB(10).EQ.1)READ(10,END=100,ERR=101)(IB6(J),J=1,6)
WRITE(*,*)(IB6(J),J=1,6)
!CALL LIT(XB,RB,IB6,CB,6,'I ',NFIC,'STD',ISTAT)
!
! READS THE NUMBER OF BOUNDARY ELEMENTS FOR 3D MESH
IF(IB(7).NE.0) THEN
NELEBD = IB(7)
END IF
! CASE WHERE KNOLG IS GIVEN INSTEAD OF IPOBO (PARALLEL MODE)
IF(IB(8).NE.0) THEN
NPTFR=IB(8)
! NOTE JMH : NEXT LINE MOVED AFTER ENDIF ON 22/07/02
! SUBDOMAINS MAY HAVE NPTFR=0
! NPTIR=IB(9)
ENDIF
NPTIR=IB(9)
!
! 5: 4 INTEGERS
C CALL LIT(XB,RB,IB6,CB,4,'I ',NFIC,'STD',ISTAT)
READ(10,END=100,ERR=101)(IB6(J),J=1,4)
WRITE(*,*)(IB6(J),J=1,4)
!
NELEM = IB6(1)
NPOIN = IB6(2)
NDP = IB6(3)
100 CONTINUE
WRITE(*,'(1X,A)') 'ABNORMAL END OF FILE'
WRITE(*,'(1X,A)') 'ONE INTENDED TO READ'
STOP
101 CONTINUE
WRITE(*,'(1X,A)') ' READ ERROR'
STOP
WRITE(*,300) TITRE
WRITE(*,500) NELEM,NPOIN
WRITE(*,301) TITRE
WRITE(*,501) NELEM,NPOIN
!
IF(NPOIN.LT.3) THEN
WRITE(*,24) NPOIN
STOP
ENDIF
!
24 FORMAT(1X,' NUMBER OF POINTS IN THE MESH: ',1I9,/,1X,
& ' NUMBER OF BOUNDARY POINTS: ',1I8,/,1X,
& ' WRONG DATA, PROGRAMME STOPPED')
300 FORMAT(1X,//,1X,'TITRE= ',A72,/)
301 FORMAT(1X,//,1X,'TITLE= ',A72,/)
500 FORMAT(1X,'NOMBRE D''ELEMENTS:',1I9,/,
& 1X,'NOMBRE REEL DE POINTS:',1I9)
501 FORMAT(1X,'NUMBER OF ELEMENTS:',1I9,/,
& 1X,'NUMBER OF POINTS:',1I9)
!
!
!
END
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5299

  • jmhervouet
  • jmhervouet's Avatar
Hello,

If you do not put a return after line :

NDP=IB6(3)
RETURN
100 CONTINUE

it will always go to label 100 and stop. Could it be your problem ?

Regards,

JMH
The administrator has disabled public write access.

Re: How to read *.res file using fortran 12 years 3 months ago #5300

  • hong
  • hong's Avatar
No, there isn't a "return" in my file:(
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.