1 read_write_print
program main
implicit none
read(*,*) fa,fb
write(*,*) "hello world!"
print * , "hello world! "
stop (可省略)
end
2 数据类型
program ex0404
integer a
real a
real :: a
a = 3.14159/2.0
real :: a,b,c
c =sin(a)**2 +cos(b)**2
character a
character first
character second
character add
first = "happy"
second = "birthday"
add = firs
write(*,*) "a=",a
stop
end
3 格式控制符
program ex0421
integer a
real b
complex c
logical d
character(len=20) e
a =10
b =12.34
c = (1,2)
d = .true.
e = "fortran "
write(*,"(1X,I5)") a
write(*,"(1X,F5.2)") b
write(*,"(1X,F4.1,F4.1)") c
write(*,"(1X,L3)") d
write(*,"(1X,A10)") e
4 自定义数
program ex0434
implicit none
type :: person
character :: name
integer :: age
real :: height
real :: wight
character :: address
end type person
type(person) :: a
write(*,*) "name"
read(*,*) a%name
write(*,*) "AGE"
read(*,*) a%age
write(*,*) "height"
read(*,*) a%height
write(*,*) "weight"
read(*,*) a%weight
write(*,*) "address"
read(*,*) a%adress
write(*,100) a%name, a%age, a%height, a%weight
100 format(/, "name:", A10/, "age:", I3/, "height:" , I3&
&"address:" , A50)
stop
end