WRITE/READ(UNIT=number,FMT=format,NML=namelist,REC=record,IOSTAT=stat,ERR=errlabel,END=ENDLABEL,ADVANCE=advance,SIZE=size) 1. UNIT=number 指定文件代码 FMT=format 指定输入输出格式,若为*号则表示自由格式(为了读写数据的准确,建议使用*号) 1. 2. REWIND的使用 Rewind语句将一个文件的操作位置重新定位...
Read(字符串,*) 整型或实型:字符串->数字 Write(字符串,*) 整型或实型:数字->字符串 字符串允许使用子字符串表示字符串的一部分,是一种特殊的数组。 语法中有很多内容本身也是字符串,如文件名,Open语句的子句和格式Format等。 利用字符串可以实现批量文件处理以及动态Format等功能,后续会讲到。 5.4 浮点数 浮...
write(*, "(2(A4, I3))") "a=", a, "b=",b A4表示character 100 format(I4) ! 定义行代码, 并指定格式(宽度为4个正型) ! 1. print没有括号 ! 2. *表示不限定输出格式,类似write的第二个星号 ! 3. print只针对屏幕输出 print *, a ! 输入命令 read(*, *) a !第1个*表示输入来源,...
programexampleimplicitnonerealcwrite(*,*)"input a number"read (*,*) cif(c)10,20,30!10,20和30为行代码,根据c小于/等于/大于0,执行10/20/30行的程序10write(*,*)"A"goto40!goto可实现跳到任意前面或后面的行代码处,但用多了破坏程序结20write(*,*)"B"goto4030write(*,*)"C"goto4040stopend...
★【重要语法】write / read(unit = number , fmt = Format , NML = namelist(专读某个namelish,无用),rec = record(直读文件终,设置所读写文件模块位置),Iostat = var,ERR = label,END=label(遇到文件结尾的跳转标签),ADVANCE = ‘yes/no是否读写后换行’) ...
write(*,*)中,第一个*表示默认输出位置,第二个*表示默认输出格式,完整表述为以下格式 write(unit=6,fmt=*)"Hello World" unit=6 表述输出至屏幕,等效于unit=*。 输入 programmainintegera,b,cwrite(*,*)"please input 3 number"read(*,*)a,b,cwrite(*,*)a+b+cend ...
program read_write implicit none real :: x write (*, *) "Input your number: " ! 向控制台输出 read (*, *) x ! 从键盘读入 open (unit=1, file='1.dat', status='replace') ! 打开"1.dat"文件 write (1, *) "This is the number you entered: ", x ! 输出字符串与变量 close (...
write(*,*)中,第一个*表示默认输出位置,第二个*表示默认输出格式,完整表述为以下格式 write(unit=6,fmt=*) "Hello World" 1. unit=6 表述输出至屏幕,等效于unit=*。 输入 program main integer a,b,c write(*,*) "please input 3 number" ...
WRITE(2,20) ((B(I,J),J=0,10),I=0,20) CLOSE(2) 10 FORMAT(X,11F14.8) 20 format( 22f14.8 ) END 댓글 수: 2 John D'Errico2017년 10월 12일 It is time to learn MATLAB. Read the getting started tutorials. per isakson2017년 10월 12...
WRITE(*,’(A,2X,A,2X,A)’)A,B,C END 输入:ABC□DBASICFORMAT 结果:ABC□D□□BASIC□□FORMA !!!2X表示□□ X编辑描述符 功能1:在输出时产生空格,它的一般形式为:nX 关系表达式与逻辑表达式 关系运算符: >、>=、<、<=、==(等于)、/=(不等于) (常用) .GT.、.GE.、.LT.、.LE.、.EQ....