Page 1 of 1

You know, FORTRAN isn't so bad

Posted: 27 Oct 2010, 09:48
by Meat Engine
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.

Re: You know, FORTRAN isn't so bad

Posted: 27 Oct 2010, 16:29
by rhino
[youtube]CUW0puvocTg[/youtube]

Re: You know, FORTRAN isn't so bad

Posted: 27 Oct 2010, 18:55
by scarica
:redneck:

Re: You know, FORTRAN isn't so bad

Posted: 27 Oct 2010, 20:18
by Lavabug
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)

Re: You know, FORTRAN isn't so bad

Posted: 28 Oct 2010, 05:23
by Meat Engine
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.

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.

Re: You know, FORTRAN isn't so bad

Posted: 28 Oct 2010, 09:48
by Mr. P
[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.

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. :greenie:



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... :santa: