-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfortran_notes.txt
18 lines (13 loc) · 1.03 KB
/
fortran_notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Allocatable character array:
subroutine hello (n,string)
character(:),allocatable,intent(out)::string
integer,intent(in)::n
character(10)::helloworld="hello world"
! string=helloworld(:n) ! Does not work.
! string=(helloworld(:n)) ! Works.
! allocate(string, source=helloworld(:n)) ! Does not work.
allocate(string, source=(helloworld(:n))) ! Works.
end subroutine hello
Allocatable arrays are automatically deallocated on exit (if not returned). Pointer arrays are not and must be manually deallocated.
https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/326100
Note that 'continue' is basically a no-op. To get the desired effect of skipping to the next iteration of a loop, use 'cycle'. 'exit' is the equivalent of 'break' in C. It is also a common extension to end a program, similar to 'stop'. A name can be provided to 'cycle' or 'exit' to indicate which named construct (e.g., loop or block) should be affected.