Open AzizAbidin opened 2 years ago
DONT hard code the array size into the variable.
i.e. primes(2)
Leave the array size open i.e. primes(*)→ ASSUMED SIZE primes(:) → ASSUMED SHAPE
Error command example: error stop “Don’t know that many primes”
MAKE ALL VARIABLES ALLOCATABLE
ELEMENT WISE ASSOCIATION Give 1st or 2nd element of array, gives 5 elementa from 2nd element
DONT USE EXPLICIT ARRAY ELEMENT ARGUMENTS
YOU CANT HAVE THE COMPILER CHECK YOU ARE PASSING THE ARRAYS OF RIGHT SIZE
MUST CHECK AT RUN TIME
if size(x) \= size(y) error stop “ARRAYS DIFFERENT SIZES”
INTENT Almost never use intent(inout) prob not allocatable
intent(in) → assumed shape, array(:)
If corresponding sizes, have a runtime check
RECURSIVE DATA STRUCTURES IN FORTRAN
https://youtu.be/XzgEFGqbXnk
Driver program, ask for fibbonachi number
KIND TYPES IN FORTRAN BEST PRACTICES
https://fortran-lang.org/learn/best_practices/modules_programs
https://web.archive.org/web/20200930090137/https://stevelionel.com/drfortran/2017/03/27/doctor-fortran-in-it-takes-all-kinds/
DONT hard code the array size into the variable.
i.e. primes(2)
Leave the array size open i.e. primes(*)→ ASSUMED SIZE primes(:) → ASSUMED SHAPE
Error command example: error stop “Don’t know that many primes”
MAKE ALL VARIABLES ALLOCATABLE
ELEMENT WISE ASSOCIATION Give 1st or 2nd element of array, gives 5 elementa from 2nd element
DONT USE EXPLICIT ARRAY ELEMENT ARGUMENTS
YOU CANT HAVE THE COMPILER CHECK YOU ARE PASSING THE ARRAYS OF RIGHT SIZE
MUST CHECK AT RUN TIME
if size(x) \= size(y) error stop “ARRAYS DIFFERENT SIZES”
INTENT Almost never use intent(inout) prob not allocatable
intent(in) → assumed shape, array(:)
If corresponding sizes, have a runtime check