已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
土木建筑学院 随机波浪课程作业用fortran写tecplot的二进制文件2008-06-19 21:55tecplot的文件分为ASCII码和二进制两种,二进制文件的大小要远小于前者,对于节约空间较为有利;另外tecplot 在打开ASCII码文件是要先把它转化为二进制文件,当文件较大时速度奇慢。然而二进制文件的生成方法较为复杂,一位浙大的同学帖子中有介绍,并且给出了用C语言直接写二进制文件的程序。具有很好的参考价值。/hepei63/blog/item/32f9dd0f73c018e9ab6457f2.html不过该程序只能写单区的文件,如何写多区文件呢?进过两天的实验,我用FORTRAN语言写了一个,然后又弄了多区的文件。现在贡献给大家,希望有用。tecplot安装目录里的utilpreplotpreplot.c的最后部分详细介绍了二进制文件的格式,各个版本的格式不完全一样,本程序是参照TECPLOT10.0格式写的。先来一个简单的单区的:program tecbinimplicit real*4 (a-h,o-z)integer, parameter: imax=50integer, parameter: jmax=25integer, parameter: kmax=50Integer*4 I,J,K,GTYPEcharacter*40 Title,varcharacter*40 Varname1,Varname2,Varname3,Varname4character*40 Zonename1real(kind=8): x(imax,jmax,kmax) !x coordinatereal(kind=8): y(imax,jmax,kmax) !y coordinatereal(kind=8): z(imax,jmax,kmax) !z coordinatereal(kind=8): den(imax,jmax,kmax) !densityREAL*4 ZONEMARKER, EOHMARKERZONEMARKER= 299.0EOHMARKER = 357.0 open(unit=99,file=tecbin.plt,form=BINARY)c I. The header section.c-1.1 Magic number, Version numberwrite(99) #!TDV101c-1.2. Integer value of 1.- write(99) 1c-1.3. Title and variable names.-c-1.3.1. The TITLE.Title=This is my first bin file.call dumpstring(Title)c -1.3.2 Number of variables (NumVar) in the datafile.write(99) 4c-1.3.3 Variable names. N = L1 + L2 + . LNumVarVarname1=Xcall dumpstring(Varname1)Varname2=Ycall dumpstring(Varname2)Varname3=Zcall dumpstring(Varname3)Varname4=density call dumpstring(Varname4)c-1.4. Zones-c-Zone marker. Value = 299.0write(99) ZONEMARKERc-Zone name.Zonename1=ZONE 001call dumpstring(Zonename1)c-Zone Color write(99) -1c-ZoneType write(99) 0c-DataPacking 0=Block, 1=Point write(99) 1c-Specify Var Location. 0 = Dont specify, all data is located at the nodes. 1 = Specify write(99) 0c-Number of user defined face neighbor connections (value = 0) write(99) 0c-IMax,JMax,KMax write(99) IMax write(99) JMax write(99) KMaxc-1=Auxiliary name/value pair to follow 0=No more Auxiliar name/value pairs. write(99) 0c-I HEADER OVER-C EOHMARKER, value=357.0 write(99) EOHMARKERc+II. Data section+c-2.1 zone -write(99) ZonemarkerC-variable data format, 1=Float, 2=Double, 3=LongInt, 4=ShortInt, 5=Byte, 6=Bit write(99) 3 write(99) 3 write(99) 3 write(99) 3C-Has variable sharing 0 = no, 1 = yes. write(99) 0 C-Zone number to share connectivity list with (-1 = no sharing). write(99) -1C-Zone Data. Each variable is in data format asspecified above.do k=1,kmax do j=1,jmax do i=1,imax write(99) i write(99) j write(99) k write(99) i+j+k+100 !data end do end do end doendsubroutine dumpstring(instring) character(40) instring integer len len=LEN_TRIM(instring) do ii=1,len I=ICHAR(instring(ii:ii) write(99) I end do write(99) 0returnend+OVER+太长了,多区的写在下一篇文章里吧上一篇介绍了用fortran写单区的tecplot的二进制文件,本篇将给出一个2区的程序,再多的类似。其实从单区改为多区很简单,只要在每个区的HEADER SECTION和ZONE SECTION后面在加一个区就可以了,废话不说,看程序吧program tecbinc implicit double precision (a-h,o-z)implicit real*4 (a-h,o-z)integer, parameter: imax=50integer, parameter: jmax=25integer, parameter: kmax=50Integer*4 I,J,K,GTYPEcharacter*40 Title,varcharacter*40 Varname1,Varname2,Varname3,Varname4character*40 Zonename1,Zonename2real(kind=8): x(imax,jmax,kmax) !x coordinatereal(kind=8): y(imax,jmax,kmax) !y coordinatereal(kind=8): z(imax,jmax,kmax) !z coordinatereal(kind=8): den(imax,jmax,kmax) !densityREAL*4 ZONEMARKER,GEOMMARKER,TEXTMARKER,CUSTOMLABELMARKER, 1 USERRECMARKER ,DATASETAUXDATAMARKER,VARAUXDATAMARKER, 2 EOHMARKER ZONEMARKER= 299.0GEOMMARKER= 399.0TEXTMARKER = 499.0CUSTOMLABELMARKER= 599.0USERRECMARKER = 699.0DATASETAUXDATAMARKER= 799.0VARAUXDATAMARKER= 899.0EOHMARKER = 357.0 open(unit=99,file=tecbin.plt,form=BINARY)c I. The header section.c The header section contains The version number of the file, a titlec of the file, the names of the varialles to be plotted, thec descriptions of all zones to be read in and all text and geometryc definitions.c-1.1 Magic number, Version numberwrite(99) #!TDV101c-1.2. Integer value of 1.-c +-+c | INT32 | This is used to determine the byte orderc +-+ of the reader relative to the writer. write(99) 1c-1.3. Title and variable names.-c-1.3.1. The TITLE. (See note 1.)Title=This is my first bin file.call dumpstring(Title)c -1.3.2 Number of variables (NumVar) in the datafile.write(99) 4c-1.3.3 Variable names. N = L1 + L2 + . LNumVarVarname1=Xcall dumpstring(Varname1)Varname2=Ycall dumpstring(Varname2)Varname3=Zcall dumpstring(Varname3)Varname4=Pressure call dumpstring(Varname4)c-1.4. Zones-c-1.4.1 Zone 1+c-Zone marker. Value = 299.0write(99) ZONEMARKERc-Zone name. (See note 1.) N = length of zone name + 1. Zonename1=ZONE 001call dumpstring(Zonename1)c-Zone Color (set to -1 if you want tecplot todetermine). write(99) -1c-ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK write(99) 0c-DataPacking 0=Block, 1=Point write(99) 1c-Specify Var Location. 0 = Dont specify, all data is located at the nodes. 1 = Specify write(99) 0c-Number of user defined face neighbor connections (value = 0) write(99) 0c-IMax,JMax,KMax write(99) IMax write(99) JMax write(99) KMaxc-1=Auxiliary name/value pair to follow 0=No more Auxiliar name/value pairs. write(99) 0c-1.4.2-Zone 2+write(99) ZONEMARKERc-Zone name. (See note 1.) N = length of zone name + 1.Zonename2=ZONE 002call dumpstring(Zonename2)c-Zone Color (set to -1 if you want tecplot todetermine). write(99) -1c-ZoneType 0=ORDERED,1=FELINESEG,2=FETRIANGLE,3=FEQUADRILATERAL,4=FETETRAHEDRON,5=FEBRICK write(99) 0c-DataPacking 0=Block, 1=Point write(99) 1c-Specify Var Location. 0 = Dont specify, all data is located at the nodes. 1 = Specify write(99) 0c-Number of user defined face neighbor connections (value = 0) write(99) 0c-IMax,JMax,KMax write(99) IMax write(99) JMax write(99) KMaxc For all zone types (repeat for each Auxiliary data name/value pair): write(99) 0c-I HEADER OVER-C EOHMARKER, value=357.0 write(99) EOHMARKERc+II. Data section+c-2.1 zone 1-C-Zone marker Value = 299.0write(99) ZonemarkerC-variable data format, 1=Float, 2=Double, 3=LongInt, 4=ShortInt, 5=Byte, 6=Bit write(99) 3 ! very important! write(99) 3 write(99) 3 write(99) 3C-Has variable sharing 0 = no, 1 = yes. write(99) 0 C-Zone number to share connectivity list with (-1 = no sharing). write(99) -1C-Zone Data. Each variable is in data format asspecified above.do k=1,kmax do j=1,jmax do i=1,imax write(99) i write(99) j write(99) k write(99) i+j+k+100 !data end do end do end doc-2.2 zone 2-C-Zone marker Value = 299.0write(99) ZonemarkerC-variable data format, 1=Float, 2=Double, 3=LongInt, 4=ShortInt, 5=Byte, 6=Bit write(99) 3 ! very important! write(99) 3 write(99) 3 write(99) 3C-Has variable sharing 0 = no, 1 = yes. write(99) 0 C-Zone number to share connectivity list with (-1 = no sharing). write(99) -1C-Zone Data. Each variable is in data format asspecified above.do k=1,kmax do j=1,jmax do i=1,imax write(99) i+50 write(99) j write(99) k write(99) i+j+k !data end do end do end doclose(99)stop endsubroutine dumpstring(instring) character(40) instring integer len len=LEN_TRIM(instring) do ii=1,len I=ICHAR(instring(ii:ii) write(99) I end do write(99) 0returnend输出tecplot格式的fortran程序软件学习 2010-07-08 01:13:35 阅读45 评论0 字号:大中小 今天找到一个好网站,有一个比较通用的fortran程序可以输出tecplot格式文件,留下来参考。subroutine tecplot_write_open ( file_name, iunit )!*! TECPLOT_WRITE_OPEN opens a TECPLOT output file.! Modified:! 19 April 2001! Author:! John Burkardt! Parameters:! Input, character ( len = * ) FILE_NAME, the output file to create.! Output, integer IUNIT, the FORTRAN unit number to be used with the file.! implicit none! character ( len = * ) file_name integer ios integer iunit! Get a free FORTRAN unit and open the output file.! call get_unit ( iunit ) open ( unit = iunit, file = file_name, form = formatted, & access = sequential, status = replace, iostat = ios ) if ( ios /= 0 ) then write ( *, (a) ) write ( *, (a) ) TECPLOT_WRITE_OPEN - Fatal error! write ( *, (a) ) Could not open the output file. stop end if returnendsubroutine tecplot_write_close ( iunit )!*! TECPLOT_WRITE_CLOSE closes a TECPLOT output file.! Modified:! 19 April 2001! Author:! John Burkardt! Parameters:! Input, integer IUNIT, the FORTRAN unit number that was used with the file.! implicit none! integer iunit! close ( unit = iunit ) returnendsubroutine tecplot_write_header ( iunit, title, variables )!*! TECPLOT_WRITE_HEADER writes the two line TECPLOT header.! Discussion:! You are free to specify any title you want. The routine will add a! Title keyword, and delimit the title with double quotes. For! example, if the input value of TITLE is FLOW6 data, then what will! appear as the title line in the TECPLOT file is:! Title=FLOW6 data! The variables list is significant, since TECPLOT will count! the number of names, and assume that a corresponding set of values! will follow. VARIABLES should contain a list of variable names,! each in double quotes, separated by commas. The first two or three! variables are usually the spatial coordinates. A typical value! of VARIABLES might be X,Y,P,U,V, in which case this! routine will write the line:! Variables=X,Y,P,U,V! Modified:! 18 July 2001! Author:! John Burkardt! Parameters:! Input, integer IUNIT, the FORTRAN unit associated with the file.! Input, character ( len = * ) TITLE, the title.! Input, character ( len = * ) VARIABLES, the variable name line.! implicit none! integer iunit character ( len = * ) title character ( len = * ) variables! write ( iunit, (a) ) Title= / trim ( title ) / write ( iunit, (a) ) Variables= / trim ( variables ) returnendsubroutine tecplot_write_xy_line ( iunit, np, x, y )!*! TECPLOT_WRITE_XY_LINE writes out line data in XY geometry for use by TECPLOT.! Discussion:! The data is written as a GEOMETRY record.! The GEOMETRY record arguments, which you might want to adjust, include:! X = 0.0,! Y = 0.0, a fixed offset to be added to the (X,Y) data;! T = LINE, specifies that a line is being drawn;! CS = GRID, specifies that X and Y are measured in physical units;! L = SOLID, chooses a solid line type;! LT = 0.005, sets the line thickness, in frame units;! C = BLACK, chooses the line color to be black;! FC = BLACK, chooses the fill color, to be used if the line forms an area;! F = POINT, specifies that data will be (X1,Y1), (X2,Y2), .(XN,YN);! S = GLOBAL, says that this line should appear in all like frames;! I am not completely clear on the filled areas. In particular, I dont! understand whether:! A) the points are drawn, and if they enclose an area, the area is filled! with color FC;! B) the points are drawn, and the last point connected to the first,! and then, if FC is specified, that area is filled.! C) the points are drawn, and if FC is specified, the last point is! connected to the first and the area is filled.! The ZN parameter can be used to attact the line to a specific zone! or XY mapping.! Modified:! 18 July 2001! Reference:! Section 3.5.2, Geometry Record,! TECPLOT Users Manual, Version 7,! AMTEC Engineering, August 1996.! Author:! John Burkardt! Parameters:! Input, integer IUNIT, the FORTRAN unit number associated with the file.! Input, integer NP, the number of nodes.! Input, real X(NP), the X coordinates of the nodes.! Input, real Y(NP), the Y coordinates of the nodes.! implicit none! integer np! integer i integer iunit real x(np) real y(np)! write ( iunit, (a) ) write ( iunit, (a) ) GEOMETRY X = 0.0, Y = 0.0, T = LINE, CS = GRID, write ( iunit, (a) ) L = SOLID, LT = 0.005, C = BLACK, FC = BLACK, write ( iunit, (a) ) F = POINT, S = GLOBAL write ( iunit, (a) ) 1 write ( iunit, (i6) ) np do i = 1, np write ( iunit, (2g15.6) ) x(i), y(i) end do returnendsubroutine tecplot_write_xy_puv ( iunit, nelem, np, x, y, p, u, v )!*! TECPLOT_WRITE_XY_PUV writes out PUV data in XY geometry for use by TECPLOT.! Discussion:! The data format used is FEDATA, or finite element data.! PUV is intended to indicate pressure and X, Y velocity components.! Before this routine, you should have called! TECPLOT_WRITE_HEADER! to write the title and variable names.! After this routine writes the node data, you should call! TECPLOT_WRITE_T3 ! or ! TECPLOT_WRITE_T6! to record the element data.! Modified:! 18 July 2001! Author:! John Burkardt! Parameters:! Input, integer IUNIT, the FORTRAN unit number associated with the file.! Input, integer NELEM, the number of elements. If you are using 3 node! triangles, then NELEM should be this number. If you are using 6 node! triangles, then NELEM should be 4 times that number, since each 6 node! triangle you were using will be reported to TECPLOT as 4 triangles ! of 3 nodes.! Input, integer NP, the number of nodes.! Input, real X(NP), Y(NP), the X and Y coordinates of the nodes.! Input, real P(NP), the pressure.! Input, real U(NP), V(NP), the X and Y components of velocity.! implicit none! integer np! integer i integer iunit integer nelem real p(np) real u(np) real v(np) real x(np) real y(np)! write ( iunit, (a) ) write ( iunit, (a,i6,a,i6,a) ) Zone N=, np, , E=, nelem, & , F=FEPOINT, ET=TRIANGLE! Write out the data at each node.! do i = 1, np write ( iunit, (5g15.6) ) x(i),
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025至2030中国抗结核药物市场供需状况及未来趋势预测报告
- 2026中国汽车热交换器行业运营态势与应用前景预测报告
- 2025至2030教育云计算服务模式创新与行业应用深度研究报告
- 吉安市高级实验中学2026年1月面向高校招聘教师备考题库及1套完整答案详解
- 中国人民银行所属企业网联清算有限公司2026年度校园招聘26人备考题库及答案详解参考
- 2026年石狮市华侨实验小学招聘编外合同教师备考题库及完整答案详解1套
- 宿主星系相互作用
- 同德县县直机关事务管理局2026年面向全县公开招聘政府聘用工作人员的备考题库及完整答案详解一套
- 2025至2030中国中医药大健康行业市场现状文化传承及创新发展路径研究报告
- 兴国县鼎龙乡中心幼儿园2026年春季教师招聘备考题库及答案详解参考
- 耳鼻喉科2025年工作总结及2026年工作规划
- 2026年酒店服务员考试题及答案
- 普速铁路行车技术管理课件 项目二 行车组织基础
- 《(2025年)中国类风湿关节炎诊疗指南》解读课件
- 炎德·英才·名校联考联合体2026届高三年级1月联考语文试卷(含答及解析)
- 麦当劳行业背景分析报告
- 中国心理行业分析报告
- 2025至2030中国生物芯片(微阵列和和微流控)行业运营态势与投资前景调查研究报告
- 结核性支气管狭窄的诊治及护理
- 2025年铁岭卫生职业学院单招职业适应性考试模拟测试卷附答案
- 急腹症的识别与护理
评论
0/150
提交评论