You know, FORTRAN isn't so bad
- Meat Engine
- Ancient One
- Posts: 4451
- Joined: 02 Feb 2010, 02:55
- Contact:
You know, FORTRAN isn't so bad
Sure, there are builds in use that are older than I am, but that's OK. It's pretty easy to learn. Having an IDE makes a big difference, too.
- rhino
- PAWG Hunter
- Posts: 51143
- Joined: 14 Apr 2009, 04:59
Re: You know, FORTRAN isn't so bad
[youtube]CUW0puvocTg[/youtube]
- scarica
- Ancient One
- Posts: 2127
- Joined: 13 Apr 2009, 15:18
- Location: hwy 180 burrito shop
Re: You know, FORTRAN isn't so bad
<a class="bbc_url" href="http://www.youtube.com/watch?v=sKyve_IO ... e_IO0nA</a>
<blockquote class="ipsBlockquote" data-author="ANGEL OF DESEASE">
when a lady lick the nipple, the ding-ding start to smile
</blockquote>
<blockquote class="ipsBlockquote" data-author="ANGEL OF DESEASE">
when a lady lick the nipple, the ding-ding start to smile
</blockquote>
- Lavabug
- Metal God
- Posts: 7817
- Joined: 17 Apr 2009, 16:15
- Location: An ocean of filth.
Re: You know, FORTRAN isn't so bad
I will inevitably have to learn it in the future, but for now I'm picking up some Python on the side at my own pace(still very basic, just for calculating stuff and graphing is from the looks of it simple)
- Meat Engine
- Ancient One
- Posts: 4451
- Joined: 02 Feb 2010, 02:55
- Contact:
Re: You know, FORTRAN isn't so bad
Here's a piece of what I'm working on so far. As you can see, variable declarations are super easy. You can do it globally before any executable instructions, you can do it locally in sub-routines, and you can do it with regular arithmetic expressions, which defaults the new variable to a "real" type.
It's easy to declare multiple variables of one type in the same statement, but I like to have documentation on each.
Code: Select all
Program yarnImpact
character yarnName !Type of yarn
real cE !Sound speed in the yarn
real L !Length of the yarn
real rho !Density of the yarn
integer n !Number of nodes in the yarn
real V0 !Impact velocity
real mP !Mass of the projectile
real alpha !Courant coefficient
real gamma !Damping coefficient
real x(1000) !Array of node positions along x-axis
real y(1000) !Array of node positions along y-axis
real Vx(1000) !Array of node velocities in x-direction
real Vy(1000) !Array of node velocities in y-direction
real sig(1000) !Array of spring stresses
real theta(1000) !Array of spring angles
real ep(1000) !Array of spring strains
implicit integer (i-j)
print *, "This program will allow us to analyze a projectile impact."
print *, "Please enter the requested data when prompted."
print *, "What type of yarn is being used?"
read *, yarnName
print *, "What is the sound speed for the yarn in m/s?"
read *, cE
print *, "What is the length of the yarn in meters? Suggested: 0.2"
read *, L
print *, "What is the density of the yarn in kg/m3?"
read *, rho
print *, "How many nodes will be analyzed? Suggested: 100"
read *, n
print *, "What is the impact velocity of the projectile in m/s?"
read *, V0
print *, "What is the mass of the projectile in kilograms?"
read *, mP
print *, "What Courant factor will be used in the model?"
read *, alpha
print *, "What damping coefficient will be used in the model?"
print *, "Suggested: 3"
read *, gamma
! Calculates the modulus of elasticity
E=(c**2)*rho
! Calculates the distance between two nodes
dx=L/(n-1)
! Calculates the length of the time step
h=alpha*dx/c
! Yarn cross-section
a=7.854d-5
! Mass of a node
mN=L*a*rho/n
! Fix initial position of nodes in x-axis
Do 5 j=1,n
x(j)=(j-1)*dx
5 Continue
! Set boundary condition for fixed node
Vx(n)=0
Vy(n)=0
end
It's easy to declare multiple variables of one type in the same statement, but I like to have documentation on each.
- Mr. P
- Ancient One
- Posts: 4211
- Joined: 16 Apr 2009, 16:25
Re: You know, FORTRAN isn't so bad
[quote name="The Fu Monster"]Here's a piece of what I'm working on so far. As you can see, variable declarations are super easy. You can do it globally before any executable instructions, you can do it locally in sub-routines, and you can do it with regular arithmetic expressions, which defaults the new variable to a "real" type.
It's easy to declare multiple variables of one type in the same statement, but I like to have documentation on each.[/quote]
If this is an school assasment then the better documentation you do the better grade you will get. Also one documentation tip is that add your requirements for the software in the code. IE ! ## Req ID: 1. User needs to insert these values (list). ! ## Req ID: 2. Calculate result. ! ## Req ID: 3. create schematics of the result in graphics. or whatever.
I would also imply a tag to the end of DO, WHILE, LOOP or similar that which loop ends here. When you write loops inside loops it get more easier to debug your code and also for look mistakes.
just saying...
Code: Select all
Program yarnImpact
character yarnName !Type of yarn
real cE !Sound speed in the yarn
real L !Length of the yarn
real rho !Density of the yarn
integer n !Number of nodes in the yarn
real V0 !Impact velocity
real mP !Mass of the projectile
real alpha !Courant coefficient
real gamma !Damping coefficient
real x(1000) !Array of node positions along x-axis
real y(1000) !Array of node positions along y-axis
real Vx(1000) !Array of node velocities in x-direction
real Vy(1000) !Array of node velocities in y-direction
real sig(1000) !Array of spring stresses
real theta(1000) !Array of spring angles
real ep(1000) !Array of spring strains
implicit integer (i-j)
print *, "This program will allow us to analyze a projectile impact."
print *, "Please enter the requested data when prompted."
print *, "What type of yarn is being used?"
read *, yarnName
print *, "What is the sound speed for the yarn in m/s?"
read *, cE
print *, "What is the length of the yarn in meters? Suggested: 0.2"
read *, L
print *, "What is the density of the yarn in kg/m3?"
read *, rho
print *, "How many nodes will be analyzed? Suggested: 100"
read *, n
print *, "What is the impact velocity of the projectile in m/s?"
read *, V0
print *, "What is the mass of the projectile in kilograms?"
read *, mP
print *, "What Courant factor will be used in the model?"
read *, alpha
print *, "What damping coefficient will be used in the model?"
print *, "Suggested: 3"
read *, gamma
! Calculates the modulus of elasticity
E=(c**2)*rho
! Calculates the distance between two nodes
dx=L/(n-1)
! Calculates the length of the time step
h=alpha*dx/c
! Yarn cross-section
a=7.854d-5
! Mass of a node
mN=L*a*rho/n
! Fix initial position of nodes in x-axis
Do 5 j=1,n
x(j)=(j-1)*dx
5 Continue
! Set boundary condition for fixed node
Vx(n)=0
Vy(n)=0
end
It's easy to declare multiple variables of one type in the same statement, but I like to have documentation on each.[/quote]
If this is an school assasment then the better documentation you do the better grade you will get. Also one documentation tip is that add your requirements for the software in the code. IE ! ## Req ID: 1. User needs to insert these values (list). ! ## Req ID: 2. Calculate result. ! ## Req ID: 3. create schematics of the result in graphics. or whatever.
I would also imply a tag to the end of DO, WHILE, LOOP or similar that which loop ends here. When you write loops inside loops it get more easier to debug your code and also for look mistakes.
just saying...