1.单双精度Programex01implicitnonereal(kind=4)::areal(kind=8)::ba=3.66666666666666666666666_4!确定这个数字是使用单精度b=3.66666666666666666666666_8!确定这个数字是使用双精度write(*,*)a,bEndprogramex012.判断kind值programex02Implicitnone!判断可以记录9个位数的整数kind值integer,parameter::long_int=selected_int_kind(9)!判断可以记录3个位数的整数kind值integer,parameter::short_int=selected_int_kind(3)!判断可以有3个有效位数,指数可以记录到3的浮点数kind值integer,parameter::long_real=selected_real_kind(10,50)!判断可以有10个有效位数,指数可以记录到50的浮点数kind值integer,parameter::short_real=selected_real_kind(3,3)integer(kind=long_int)::a=123456integer(kind=short_int)::b=123real(kind=long_real)::c=+1.23456789D45real(kind=short_real)::d=+1230write(*,"(I3,1X,I10)")long_int,awrite(*,"(I3,1X,I10)")short_int,bwrite(*,"(I3,1X,E10.5)")long_real,cwrite(*,"(I3,1X,E10.5)")short_real,dEND3.TYPEprogramex0434implicitnoneType::person!开始建立person这个类型character(len=30)::name!人名integer::age!年龄integer::height!身高INTEGER::weight!体重character(len=80)::address!地址Endtypepersontype(person)::a!声明一个person类型的变量write(*,*)"NAME:"read(*,*)a%namewrite(*,*)"AGE:"read(*,*)a%agewrite(*,*)"HEIGHT:"read(*,*)a%heightwrite(*,*)"WEIGHT:"read(*,*)a%weightwrite(*,*)"ADDRESS:"read(*,*)a%addresswrite(*,100)a%name,a%age,a%height,a%weight100format("Name:",A10/,"Age:",I3/,"Height:",I3/,"Weight:",I3/,&"Addres:",A80)End4.REAL与INTEGERProgramex0431implicitnoneinteger::a=1integer::b=2real::cc=a/b!c=1/2=0,虽然c是浮点数,但因为a,b是整数,计算a/b时会用整数去计算.write(*,"(F5.2)")cEnd5.DATA变量表/初值表/,变量表/初值表/,…PROGRAMex0430IMPLICITNONEINTEGERAREALBCOMPLEXCCHARACTER(20)STRDATAA,B,C,STR/1,2.0,(1.0,2.0),'FORTRAN77'/WRITE(*,*)A,B,,C,STREND6.复数实虚部Programex0430complex::c=(1,2)write(*,100)real(c),'+',aimag(c),'i'100format(f5.1,a1,f5.1,a1)End7.逻辑输出Programex0416logicala,ba=.true.b=.false.write(*,100)a,b100format(L5,L4)End8.Programex0415character(len=20)stringcharacter(len=5)substringstring="Haveaniceday."substring="nice"write(*,*)ichar('A')!输出字符A的ASCII码write(*,*)char(65)!输出ASCII码65所代表的字符,也就是Awrite(*,*)len(string)!输出字符串string声明时的长度write(*,*)len_trim(string)!输出字符串string内容的长度write(*,*)index(string,substring)!nice在Haveaniceday的第8个位置End9.Programex0414character(len=6)firstcharacter(len=10)secondcharacter(len=20)addfirst="Happy"second="Birthday"add=first//second!经由两个连续的除号可以连接两个字符串write(*,100)add100FORMAT('生日快乐',/,A)End10.带精度计算Programex0408real(kind=8)::a,ba=1b=0.1write(*,*)a,"+",b,"=",a+bEnd11.逻辑if语句Programex0504implicitnoneintegerrain,windspeedlogicalr,wwrite(*,*)"Rain:"read(*,*)rainwrite(*,*)"Wind:"read(*,*)windspeedr=(rain>=500)!如果rain>=150,r=.true,不然r=.false.w=(windspeed>=10)!如果windspeed>=10,w=.true,不然w=.false.if(r.or.w)then!只要r或w有一个值是true就成立write(*,*)"停止上班上课"elsewrite(*,*)"照常上班上课"EndifEnd12.SelectCase用法Programex0512implicitnoneinteger::scorecharactergradewrite(*,*)"Score:"read(*,*)scoreselectcase(score)case(90:100)grade='A'case(80:89)grade='B'casedefaultgrade='?'Endselectwrite(*,"('Grade:',A1)")gradeEnd13.IFGOTO语句PROGRAMex0514IMPLICITNONEREALheightREALweightWRITE(*,*)"height:"READ(*,*)heightWRITE(*,*)"weight:"READ(*,*)weightIF(weight>height-100)GOTO200100WRITE(*,*)"Undercontrol."GOTO300200WRITE(...