AzizAbidin / github-slideshow

A robot powered training repository :robot:
https://lab.github.com/githubtraining/introduction-to-github
MIT License
0 stars 0 forks source link

Fortran Best Practices Arrays: https://youtu.be/UNSEm4A44dM #10

Open AzizAbidin opened 2 years ago

AzizAbidin commented 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”

  1. Named constant = assumed size, prime(*)
  2. Variable = Allocatable, deferred length to be determined later, array(:)

INTENT Almost never use intent(inout) prob not allocatable

intent(in) → assumed shape, array(:)

If corresponding sizes, have a runtime check

AzizAbidin commented 2 years ago

RECURSIVE DATA STRUCTURES IN FORTRAN

https://youtu.be/XzgEFGqbXnk

Driver program, ask for fibbonachi number

AzizAbidin commented 2 years ago

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/