"## Introduction to structured programming with Fortran\n",
"\n",
"### Why to learn Fortran ?\n",
"\n",
"* Because of the execution speed of a program\n",
"* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran\n",
"\n",
"## Getting started\n",
"\n",
"### Hello World"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "00ec1776",
"metadata": {},
"outputs": [],
"source": [
"program hello_world\n",
"\n",
" implicit none ! important\n",
"\n",
" print *, \"Hello World!\"\n",
"\n",
"end program hello_world"
]
},
{
"cell_type": "markdown",
"id": "c4b788f0",
"metadata": {},
"source": [
"### Data Type Declarations and Assignments"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ffd3f0c3",
"metadata": {},
"outputs": [],
"source": [
"program data_type\n",
"\n",
" implicit none\n",
" \n",
" real x, y\n",
" integer i, j\n",
" logical flag\n",
" \n",
" integer matrix(2,2) \n",
" character(80) month\n",
" character(len=80) months(12)\n",
" \n",
" character family*16\n",
" \n",
" real, dimension(12) :: small_array\n",
" character(len=80), dimension(24) :: screen\n",
" \n",
" integer, parameter :: it = 100\n",
" \n",
" i = 1\n",
" j = i+2\n",
" x = 85.8\n",
" y = 3.5*cos(x)\n",
"\n",
" month=\"december\"\n",
" \n",
" months(:)=\"empty\"\n",
" \n",
" months(12)=month\n",
" \n",
" flag = .TRUE.\n",
" \n",
" family = \"GEORGE P. BURDELL\"\n",
" print*,family(:6)\n",
" print*,family(8:9)\n",
" print*,family(11:)\n",
" print*,family(:6)//FAMILY(10:)\n",
" \n",
"end"
]
},
{
"cell_type": "markdown",
"id": "133046ed",
"metadata": {},
"source": [
"### Arithmetic Assignments\n",
"\n",
"The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results."
"Although Fortran normally works from left to right at a given level of precedence (does all multiply and divide from left to right before moving on to adds and subtracts). It works exponentiation from right to left when it hits 2 or more sequential exponentiation operations"
"When in doubt use parentheses to get the answer that you really want.\n",
"\n",
"### Assignments exercise"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14f6e7e2",
"metadata": {},
"outputs": [],
"source": [
"program sphere \n",
"\n",
" implicit none\n",
" \n",
" real pi,radius,volume,area \n",
" \n",
" radius = 1.0\n",
" pi = 0.0\n",
" \n",
" write(*,*) 'The value of pi is ', pi\n",
" write(*,*) \n",
"\n",
" area = 0.0\n",
" volume = 0.0\n",
" \n",
" write(*,*) 'For a radius ', radius \n",
" write(*,*) 'the area of a sphere is ', area\n",
" write(*,*) 'and the volume is ', volume\n",
" \n",
"end "
]
},
{
"cell_type": "markdown",
"id": "9a1702f7",
"metadata": {},
"source": [
"### Execution Control"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "41f9a8f0",
"metadata": {},
"outputs": [],
"source": [
"PROGRAM gcd\n",
" ! Computes the greatest common divisor, Euclidean algorithm\n",
" IMPLICIT NONE\n",
" INTEGER :: m, n, t\n",
" WRITE(*,*) \"Give positive integers m and n :\"\n",
" m=5464\n",
" n=484682\n",
" WRITE(*,*) 'm:', m,' n:', n\n",
" positive_check: IF (m > 0 .AND. n > 0) THEN\n",
" main_algorithm: DO WHILE (n /= 0)\n",
" t = MOD(m,n)\n",
" m = n\n",
" n = t\n",
" END DO main_algorithm\n",
" WRITE(*,*) \"Greatest common divisor: \",m\n",
" ELSE\n",
" WRITE(*,*) 'Negative value entered'\n",
" END IF positive_check\n",
"END PROGRAM gcd"
]
},
{
"cell_type": "markdown",
"id": "cef2ad42",
"metadata": {},
"source": [
"### File-Directed Input and Output"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8fd042c4",
"metadata": {},
"outputs": [],
"source": [
"program plot\n",
"\n",
" ! Program to provide plots of Sin(x)\n",
"\n",
" implicit none\n",
" character label*150\n",
" real x\n",
" integer i\n",
" character xlabel*32,ylabel*32,title*32\n",
" real fx\n",
" !\n",
" ! label - Character string \n",
" ! xlabel - Contains a label for the x-axis\n",
" ! ylabel - Contains a label for the y-axis\n",
" ! title - Contains a title for the plot\n",
" !\n",
" ! Drive a separate true graphics program (gnuplot)\n",
" !\n",
" ! First set up the command file for gnuplot\n",
" !\n",
" xlabel=\"'x'\"\n",
" ylabel=\"'y'\"\n",
" title=\"'sin(x)'\"\n",
" open (112,file='03_gnuxy')\n",
" !\n",
" label='set xlabel '//xlabel\n",
" write(112,*)label\n",
" write(112,*)'set xrange [0:6]'\n",
" label='set ylabel '//ylabel\n",
" write(112,*)label\n",
" write(112,*)'set yrange [-1.2:1.2]'\n",
" label='plot \"03_dataxy\" using 1:2 title '//title\n",
" label=trim(label)//' with lines lt rgb \"red\"'\n",
" write(112,*) label\n",
" write (112,*) 'pause -1'\n",
" close(112)\n",
" !\n",
" ! Generate x-y pairs for the graph\n",
" !\n",
" open (112,file='03_dataxy')\n",
" do i=0,60\n",
" x=.1*i\n",
" fx=sin(x)\n",
" write(112,*) x,fx\n",
" enddo\n",
" close(112)\n",
" !\n",
"end program"
]
},
{
"cell_type": "markdown",
"id": "059d5e2a",
"metadata": {},
"source": [
"This code is going to create 2 files: \"03_dataxy\" and \"03_gnuxy\".\n",
"\n",
"The idea is to use a linux plotting tool called \"GNUplot\" to make a graph: the first file is the data for the graph, the second one is the gnuplot script using these data.\n",
"The aim of this exercise is to work with loops (for or while) in order to draw in a terminal a Christmas tree with its balls.\n",
"\n",
"The program must be carried out in Fortran 90. It will take as argument the height of the tree which is a variable of the problem:\n",
"\n",
"Height=7\n",
"```\n",
" #\n",
" ###\n",
" #o###\n",
" ##o####\n",
" #o#####o#\n",
" ####o#####o\n",
"#####o#####o#\n",
"```\n",
"This parameter must be supplied at the command line when the program (for example './tree 10'). \n",
"\n",
"Balls must be positioned all 6 sharps."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "930eedf9",
"metadata": {},
"outputs": [],
"source": [
"program ChristmasTree\n",
"\n",
" implicit none\n",
"\n",
"\n",
"\n",
"end program"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6362d74e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Fortran",
"language": "Fortran",
"name": "fortran_spec"
},
"language_info": {
"file_extension": "f90",
"mimetype": "text/plain",
"name": "fortran"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:10d0e3c5 tags:
## Introduction to structured programming with Fortran
### Why to learn Fortran ?
* Because of the execution speed of a program
* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran
## Getting started
### Hello World
%% Cell type:code id:00ec1776 tags:
``` Fortran
program hello_world
implicit none ! important
print *, "Hello World!"
end program hello_world
```
%% Cell type:markdown id:c4b788f0 tags:
### Data Type Declarations and Assignments
%% Cell type:code id:ffd3f0c3 tags:
``` Fortran
program data_type
implicit none
real x, y
integer i, j
logical flag
integer matrix(2,2)
character(80) month
character(len=80) months(12)
character family*16
real, dimension(12) :: small_array
character(len=80), dimension(24) :: screen
integer, parameter :: it = 100
i = 1
j = i+2
x = 85.8
y = 3.5*cos(x)
month="december"
months(:)="empty"
months(12)=month
flag = .TRUE.
family = "GEORGE P. BURDELL"
print*,family(:6)
print*,family(8:9)
print*,family(11:)
print*,family(:6)//FAMILY(10:)
end
```
%% Cell type:markdown id:133046ed tags:
### Arithmetic Assignments
The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results.
Although Fortran normally works from left to right at a given level of precedence (does all multiply and divide from left to right before moving on to adds and subtracts). It works exponentiation from right to left when it hits 2 or more sequential exponentiation operations
When in doubt use parentheses to get the answer that you really want.
### Assignments exercise
%% Cell type:code id:14f6e7e2 tags:
``` Fortran
program sphere
implicit none
real pi,radius,volume,area
radius = 1.0
pi = 0.0
write(*,*) 'The value of pi is ', pi
write(*,*)
area = 0.0
volume = 0.0
write(*,*) 'For a radius ', radius
write(*,*) 'the area of a sphere is ', area
write(*,*) 'and the volume is ', volume
end
```
%% Cell type:markdown id:9a1702f7 tags:
### Execution Control
%% Cell type:code id:41f9a8f0 tags:
``` Fortran
PROGRAM gcd
! Computes the greatest common divisor, Euclidean algorithm
IMPLICIT NONE
INTEGER :: m, n, t
WRITE(*,*) "Give positive integers m and n :"
m=5464
n=484682
WRITE(*,*) 'm:', m,' n:', n
positive_check: IF (m > 0 .AND. n > 0) THEN
main_algorithm: DO WHILE (n /= 0)
t = MOD(m,n)
m = n
n = t
END DO main_algorithm
WRITE(*,*) "Greatest common divisor: ",m
ELSE
WRITE(*,*) 'Negative value entered'
END IF positive_check
END PROGRAM gcd
```
%% Cell type:markdown id:cef2ad42 tags:
### File-Directed Input and Output
%% Cell type:code id:8fd042c4 tags:
``` Fortran
program plot
! Program to provide plots of Sin(x)
implicit none
character label*150
real x
integer i
character xlabel*32,ylabel*32,title*32
real fx
!
! label - Character string
! xlabel - Contains a label for the x-axis
! ylabel - Contains a label for the y-axis
! title - Contains a title for the plot
!
! Drive a separate true graphics program (gnuplot)
!
! First set up the command file for gnuplot
!
xlabel="'x'"
ylabel="'y'"
title="'sin(x)'"
open (112,file='03_gnuxy')
!
label='set xlabel '//xlabel
write(112,*)label
write(112,*)'set xrange [0:6]'
label='set ylabel '//ylabel
write(112,*)label
write(112,*)'set yrange [-1.2:1.2]'
label='plot "03_dataxy" using 1:2 title '//title
label=trim(label)//' with lines lt rgb "red"'
write(112,*) label
write (112,*) 'pause -1'
close(112)
!
! Generate x-y pairs for the graph
!
open (112,file='03_dataxy')
do i=0,60
x=.1*i
fx=sin(x)
write(112,*) x,fx
enddo
close(112)
!
end program
```
%% Cell type:markdown id:059d5e2a tags:
This code is going to create 2 files: "03_dataxy" and "03_gnuxy".
The idea is to use a linux plotting tool called "GNUplot" to make a graph: the first file is the data for the graph, the second one is the gnuplot script using these data.
"* Because of the execution speed of a program\n",
"* Because of the execution speed of a program\n",
"* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran\n",
"* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran\n",
"\n",
"\n",
"### Getting started\n",
"## Getting started\n",
"\n",
"\n",
"#### Hello World"
"### Hello World"
]
]
},
},
{
{
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
"id": "c4b788f0",
"id": "c4b788f0",
"metadata": {},
"metadata": {},
"source": [
"source": [
"#### Data Type Declarations and Assignments"
"### Data Type Declarations and Assignments"
]
]
},
},
{
{
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
"id": "133046ed",
"id": "133046ed",
"metadata": {},
"metadata": {},
"source": [
"source": [
"#### Arithmetic Assignments\n",
"### Arithmetic Assignments\n",
"\n",
"\n",
"The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results."
"The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results."
]
]
...
@@ -296,7 +296,7 @@
...
@@ -296,7 +296,7 @@
"source": [
"source": [
"When in doubt use parentheses to get the answer that you really want.\n",
"When in doubt use parentheses to get the answer that you really want.\n",
"\n",
"\n",
"#### Assignments exercise"
"### Assignments exercise"
]
]
},
},
{
{
...
@@ -310,20 +310,20 @@
...
@@ -310,20 +310,20 @@
"\n",
"\n",
" implicit none\n",
" implicit none\n",
" \n",
" \n",
" real pi,radius,volume,area \n",
" real pi,radius,volume,area \n",
" \n",
" \n",
" radius = 1.0\n",
" radius = 1.0\n",
" pi = 0.0\n",
" pi = 0.0\n",
" \n",
" \n",
" write(*,*) 'The value of pi is ', pi\n",
" write(*,*) 'The value of pi is ', pi\n",
" write(*,*) \n",
" write(*,*) \n",
"\n",
"\n",
" area = 0.0\n",
" area = 0.0\n",
" volume = 0.0\n",
" volume = 0.0\n",
" \n",
" \n",
" write(*,*) 'For a radius ', radius \n",
" write(*,*) 'For a radius ', radius \n",
" write(*,*) 'the area of a sphere is ', area\n",
" write(*,*) 'the area of a sphere is ', area\n",
" write(*,*) 'and the volume is ', volume\n",
" write(*,*) 'and the volume is ', volume\n",
" \n",
" \n",
"end "
"end "
]
]
...
@@ -333,7 +333,7 @@
...
@@ -333,7 +333,7 @@
"id": "9a1702f7",
"id": "9a1702f7",
"metadata": {},
"metadata": {},
"source": [
"source": [
"#### Execution Control"
"### Execution Control"
]
]
},
},
{
{
...
@@ -369,7 +369,7 @@
...
@@ -369,7 +369,7 @@
"id": "cef2ad42",
"id": "cef2ad42",
"metadata": {},
"metadata": {},
"source": [
"source": [
"#### File-Directed Input and Output"
"### File-Directed Input and Output"
]
]
},
},
{
{
...
@@ -431,7 +431,7 @@
...
@@ -431,7 +431,7 @@
},
},
{
{
"cell_type": "markdown",
"cell_type": "markdown",
"id": "31f27416",
"id": "059d5e2a",
"metadata": {},
"metadata": {},
"source": [
"source": [
"This code is going to create 2 files: \"03_dataxy\" and \"03_gnuxy\".\n",
"This code is going to create 2 files: \"03_dataxy\" and \"03_gnuxy\".\n",
"The aim of this exercise is to work with loops (for or while) in order to draw in a terminal a Christmas tree with its balls.\n",
"\n",
"The program must be carried out in Fortran 90. It will take as argument the height of the tree which is a variable of the problem:\n",
"\n",
"Height=7\n",
"```\n",
" #\n",
" ###\n",
" #o###\n",
" ##o####\n",
" #o#####o#\n",
" ####o#####o\n",
"#####o#####o#\n",
"```\n",
"This parameter must be supplied at the command line when the program (for example './tree 10'). \n",
"\n",
"Balls must be positioned all 6 sharps."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "930eedf9",
"metadata": {},
"outputs": [],
"source": [
"program ChristmasTree\n",
"\n",
" implicit none\n",
"\n",
"\n",
"\n",
"end program"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "27748335",
"id": "6362d74e",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": []
"source": []
...
...
%% Cell type:markdown id:10d0e3c5 tags:
%% Cell type:markdown id:10d0e3c5 tags:
## Introduction to structured programming with Fortran
## Introduction to structured programming with Fortran
### Why to learn Fortran ?
### Why to learn Fortran ?
* Because of the execution speed of a program
* Because of the execution speed of a program
* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran
* Well suited for numerical computations : more than **45% of scientific applications** are in Fortran
### Getting started
## Getting started
#### Hello World
### Hello World
%% Cell type:code id:00ec1776 tags:
%% Cell type:code id:00ec1776 tags:
``` Fortran
``` Fortran
program hello_world
program hello_world
implicit none ! important
implicit none ! important
print *, "Hello World!"
print *, "Hello World!"
end program hello_world
end program hello_world
```
```
%% Cell type:markdown id:c4b788f0 tags:
%% Cell type:markdown id:c4b788f0 tags:
#### Data Type Declarations and Assignments
### Data Type Declarations and Assignments
%% Cell type:code id:ffd3f0c3 tags:
%% Cell type:code id:ffd3f0c3 tags:
``` Fortran
``` Fortran
program data_type
program data_type
implicit none
implicit none
real x, y
real x, y
integer i, j
integer i, j
logical flag
logical flag
integer matrix(2,2)
integer matrix(2,2)
character(80) month
character(80) month
character(len=80) months(12)
character(len=80) months(12)
character family*16
character family*16
real, dimension(12) :: small_array
real, dimension(12) :: small_array
character(len=80), dimension(24) :: screen
character(len=80), dimension(24) :: screen
integer, parameter :: it = 100
integer, parameter :: it = 100
i = 1
i = 1
j = i+2
j = i+2
x = 85.8
x = 85.8
y = 3.5*cos(x)
y = 3.5*cos(x)
month="december"
month="december"
months(:)="empty"
months(:)="empty"
months(12)=month
months(12)=month
flag = .TRUE.
flag = .TRUE.
family = "GEORGE P. BURDELL"
family = "GEORGE P. BURDELL"
print*,family(:6)
print*,family(:6)
print*,family(8:9)
print*,family(8:9)
print*,family(11:)
print*,family(11:)
print*,family(:6)//FAMILY(10:)
print*,family(:6)//FAMILY(10:)
end
end
```
```
%% Cell type:markdown id:133046ed tags:
%% Cell type:markdown id:133046ed tags:
#### Arithmetic Assignments
### Arithmetic Assignments
The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results.
The result of any integer divide is truncated to the integer value less than the correct decimal answer for the division. The result of this is that changing the order of operations can make a big difference in the answers. Notice how parentheses force more expected results.
Although Fortran normally works from left to right at a given level of precedence (does all multiply and divide from left to right before moving on to adds and subtracts). It works exponentiation from right to left when it hits 2 or more sequential exponentiation operations
Although Fortran normally works from left to right at a given level of precedence (does all multiply and divide from left to right before moving on to adds and subtracts). It works exponentiation from right to left when it hits 2 or more sequential exponentiation operations
When in doubt use parentheses to get the answer that you really want.
When in doubt use parentheses to get the answer that you really want.
#### Assignments exercise
### Assignments exercise
%% Cell type:code id:14f6e7e2 tags:
%% Cell type:code id:14f6e7e2 tags:
``` Fortran
``` Fortran
program sphere
program sphere
implicit none
implicit none
real pi,radius,volume,area
real pi,radius,volume,area
radius = 1.0
radius = 1.0
pi = 0.0
pi = 0.0
write(*,*) 'The value of pi is ', pi
write(*,*) 'The value of pi is ', pi
write(*,*)
write(*,*)
area = 0.0
area = 0.0
volume = 0.0
volume = 0.0
write(*,*) 'For a radius ', radius
write(*,*) 'For a radius ', radius
write(*,*) 'the area of a sphere is ', area
write(*,*) 'the area of a sphere is ', area
write(*,*) 'and the volume is ', volume
write(*,*) 'and the volume is ', volume
end
end
```
```
%% Cell type:markdown id:9a1702f7 tags:
%% Cell type:markdown id:9a1702f7 tags:
#### Execution Control
### Execution Control
%% Cell type:code id:41f9a8f0 tags:
%% Cell type:code id:41f9a8f0 tags:
``` Fortran
``` Fortran
PROGRAM gcd
PROGRAM gcd
! Computes the greatest common divisor, Euclidean algorithm
! Computes the greatest common divisor, Euclidean algorithm
IMPLICIT NONE
IMPLICIT NONE
INTEGER :: m, n, t
INTEGER :: m, n, t
WRITE(*,*) "Give positive integers m and n :"
WRITE(*,*) "Give positive integers m and n :"
m=5464
m=5464
n=484682
n=484682
WRITE(*,*) 'm:', m,' n:', n
WRITE(*,*) 'm:', m,' n:', n
positive_check: IF (m > 0 .AND. n > 0) THEN
positive_check: IF (m > 0 .AND. n > 0) THEN
main_algorithm: DO WHILE (n /= 0)
main_algorithm: DO WHILE (n /= 0)
t = MOD(m,n)
t = MOD(m,n)
m = n
m = n
n = t
n = t
END DO main_algorithm
END DO main_algorithm
WRITE(*,*) "Greatest common divisor: ",m
WRITE(*,*) "Greatest common divisor: ",m
ELSE
ELSE
WRITE(*,*) 'Negative value entered'
WRITE(*,*) 'Negative value entered'
END IF positive_check
END IF positive_check
END PROGRAM gcd
END PROGRAM gcd
```
```
%% Cell type:markdown id:cef2ad42 tags:
%% Cell type:markdown id:cef2ad42 tags:
#### File-Directed Input and Output
### File-Directed Input and Output
%% Cell type:code id:8fd042c4 tags:
%% Cell type:code id:8fd042c4 tags:
``` Fortran
``` Fortran
program plot
program plot
! Program to provide plots of Sin(x)
! Program to provide plots of Sin(x)
implicit none
implicit none
character label*150
character label*150
real x
real x
integer i
integer i
character xlabel*32,ylabel*32,title*32
character xlabel*32,ylabel*32,title*32
real fx
real fx
!
!
! label - Character string
! label - Character string
! xlabel - Contains a label for the x-axis
! xlabel - Contains a label for the x-axis
! ylabel - Contains a label for the y-axis
! ylabel - Contains a label for the y-axis
! title - Contains a title for the plot
! title - Contains a title for the plot
!
!
! Drive a separate true graphics program (gnuplot)
! Drive a separate true graphics program (gnuplot)
!
!
! First set up the command file for gnuplot
! First set up the command file for gnuplot
!
!
xlabel="'x'"
xlabel="'x'"
ylabel="'y'"
ylabel="'y'"
title="'sin(x)'"
title="'sin(x)'"
open (112,file='03_gnuxy')
open (112,file='03_gnuxy')
!
!
label='set xlabel '//xlabel
label='set xlabel '//xlabel
write(112,*)label
write(112,*)label
write(112,*)'set xrange [0:6]'
write(112,*)'set xrange [0:6]'
label='set ylabel '//ylabel
label='set ylabel '//ylabel
write(112,*)label
write(112,*)label
write(112,*)'set yrange [-1.2:1.2]'
write(112,*)'set yrange [-1.2:1.2]'
label='plot "03_dataxy" using 1:2 title '//title
label='plot "03_dataxy" using 1:2 title '//title
label=trim(label)//' with lines lt rgb "red"'
label=trim(label)//' with lines lt rgb "red"'
write(112,*) label
write(112,*) label
write (112,*) 'pause -1'
write (112,*) 'pause -1'
close(112)
close(112)
!
!
! Generate x-y pairs for the graph
! Generate x-y pairs for the graph
!
!
open (112,file='03_dataxy')
open (112,file='03_dataxy')
do i=0,60
do i=0,60
x=.1*i
x=.1*i
fx=sin(x)
fx=sin(x)
write(112,*) x,fx
write(112,*) x,fx
enddo
enddo
close(112)
close(112)
!
!
end program
end program
```
```
%% Cell type:markdown id:31f27416 tags:
%% Cell type:markdown id:059d5e2a tags:
This code is going to create 2 files: "03_dataxy" and "03_gnuxy".
This code is going to create 2 files: "03_dataxy" and "03_gnuxy".
The idea is to use a linux plotting tool called "GNUplot" to make a graph: the first file is the data for the graph, the second one is the gnuplot script using these data.
The idea is to use a linux plotting tool called "GNUplot" to make a graph: the first file is the data for the graph, the second one is the gnuplot script using these data.