how to open *.vtk file in fortran
Can we open *vtk files in fortran?
If yes,How? I have written my code as below: I keep getting error: bad real number in item 1 of list input Please let me know my mistake thanks program work_file implicit none integer:: open_status,ln real::x open(UNIT=8,FILE="NSSAVE0001.vtk", IOSTAT=open_status, STATUS="old") if(open_status >0) stop "problem opening the file" do ln=10,100 read(8,*)x enddo close(8) end program work_file |
VTK files have a standard format. The first lines are usually something like
Code:
# vtk DataFile Version 1.0 Code:
od -c NSSAVE0001.vtk | head -20 Code:
file NSSAVE0001.vtk |
Quote:
I am interested in getting the numerical values as shown below But as you said fortran reads the first line as string. How do I go about it? What modification are required in code? NSSAVE0001.vtk: ASCII C program text First Part of NSSAVE0001.vtk would be # vtk DataFile Version 2.0 TEMPS = 0.2000000E+00 Corps RE=5000 (G8) ASCII DATASET STRUCTURED_POINTS DIMENSIONS 960 320 1 ORIGIN 0.78125E-02 0.78125E-02 0 SPACING 0.15625E-01 0.15625E-01 1 POINT_DATA 307200 SCALARS pression float LOOKUP_TABLE default 0.28744E-01 0.28713E-01 0.28756E-01 0.28849E-01 0.28926E-01 0.28983E-01 0.29029E-01 0.29066E-01 0.29099E-01 0.29127E-01 0.29152E-01 0.29175E-01 0.29196E-01 0.29215E-01 0.29232E-01 0.29249E-01 0.29264E-01 0.29279E-01 0.29292E-01 0.29305E-01 0.29318E-01 0.29329E-01 0.29341E-01 0.29351E-01 0.29362E-01 0.29371E-01 0.29381E-01 0.29390E-01 0.29399E-01 0.29408E-01 0.29416E-01 0.29424E-01 0.29432E-01 0.29439E-01 0.29447E-01 0.29454E-01 0.29461E-01 0.29468E-01 0.29475E-01 0.29481E-01 0.29488E-01 0.29494E-01 0.29500E-01 0.29506E-01 0.29512E-01 0.29518E-01 0.29524E-01 0.29529E-01 0.29535E-01 0.29540E-01 0.29545E-01 0.29551E-01 0.29556E-01 0.29561E-01 0.29566E-01 0.29571E-01 0.29576E-01 0.29581E-01 0.29586E-01 0.29591E-01 0.29595E-01 0.29600E-01 0.29605E-01 0.29609E-01 0.29614E-01 |
Well, you have to read the header lines one after one. When you get the DATA POINTS line, read in the number of data points to find out the number of subsequent lines to read. Here is a dummy example:
Code:
PROGRAM work_file Code:
DO k = 1, 7 |
All times are GMT -5. The time now is 10:21 AM. |