! Program Structure:
PROGRAM ProgramName
! Declarations and statements
CONTAINS
! Subroutines and functions
END PROGRAM ProgramName
! Variable Declaration:
INTEGER :: int_var
REAL :: real_var
DOUBLE PRECISION :: dbl_var
CHARACTER(LEN=20) :: char_var
! Arrays:
REAL, DIMENSION(3) :: real_array
INTEGER, DIMENSION(0:9) :: int_array
! Control Structures:
IF (condition) THEN
! code block
ELSE
! code block
END IF
DO i = start, stop, step
! code block
END DO
SELECT CASE (variable)
CASE (value1)
! code block
CASE (value2)
! code block
CASE DEFAULT
! code block
END SELECT
! Subroutines and Functions:
SUBROUTINE MySubroutine(arg1, arg2)
! code block
END SUBROUTINE
FUNCTION MyFunction(arg1, arg2) RESULT(result_var)
! code block
END FUNCTION
! Modules:
MODULE MyModule
! Declarations
CONTAINS
! Subroutines and functions
END MODULE MyModule
! File I/O:
OPEN(unit=unit_num, file='filename', status='STATUS')
READ(unit_num, *) variable
WRITE(unit_num, *) variable
CLOSE(unit_num)
! Parameter Statements:
PARAMETER (pi = 3.14159)
! Derived Types:
TYPE MyType
INTEGER :: x
REAL :: y
END TYPE MyType
TYPE(MyType) :: obj
! Pointer Variables:
REAL, POINTER :: ptr_var(:)
ALLOCATE(ptr_var(10))
! Intrinsic Functions:
result = SIN(angle)
result = SQRT(value)
result = MAX(val1, val2)
! Array Operations:
real_array = real_array1 + real_array2
real_array = real_array * 2.0
! Format Statements:
WRITE(*, '(A, I3, F5.2)') 'Result:', int_var, real_var