对Fortran的亲切问候!
1. 简单问候
program hello
!
! Hello, Fortran
!
implicit none
write(*,*) "Hello, Fortran !"
end program hello
2. 循环问候
progran hello
!
! Hello, Fortran
!
implicit none
integer :: i
do i = 1, huge(i) ! 就不写得太暴力,给个爱的极限吧!
write(*,*) "Hello, Fortran !"
end do
end program hello
3. 并行问候
program hello
!
! Hello, Fortran
!
use omp_lib
implicit none
integer :: nthr, i
nthr = omp_get_max_threads()
call omp_set_num_threads(nthr) ! use all the brain cells
!$omp parallel do
do i = 1, huge(i)
! Crazy but polite
write(*,"('Hello, Fortran ! I''m thread ', I0, /)") omp_get_thread_num()
end do
end program hello