|
BUILDING A
F90 PROJECT
/home/joeusr
aero361/

labs

lab #[1-14, or some name]
src/
dat/ bin/ report/
|
All projects need to
follow the directory structure similar to the one shown on the left.
Every f90 project should have the four basic files named as
main.f90
|
main program
|
contains
the main program
|
input.f90
|
subroutine
input()
|
used only for
input
|
output.f90
|
subroutine
output()
|
used for
post-processing of results
|
solver.f90
|
subroutine/function
solver
|
calls all
other subroutines that are used to model the math. The other
subroutines are your choice. Name them appropriately.
|
global.f90
|
module global
|
Using a global
Module. Will come in handy when doing the panel project
|
|
| QUICK
GUIDE |
ATTENTION
Download source files for practice into the src/dir.
Yes you can overwrite the files you created in the previous step using
the touch command.
|
THE PROBLEM
- The purpose of this lab is to understand the steps
required when creating and executable from a set of source files.
The
problem being solved in this code is a simple volume plot represented
with spherical contour lines in 3 dimensions
w = z^2 + y^2 + x^2
This exercise will cover the following
- Creating and accessing Modules
- Creating and destroying Allocatable arrays
- passing variables through the procedure argument lists
- assigning names to Open file statements
- Reading from a file
- Writing to a file with simple formatting
- Accessing procedures from the main program
- Get a taste of Tecplot and the wonderful world of
post processing
THE SOURCE FILES
The set of source files listed below should be downloaded and saved in
the src/
directory of lab1/. Do not change the names of the files. If you notice
there is a global.f90 files included in this set, the global.f90 file
is a module file which is treated the same way as other .f90 source
files, but is accessed in a different way.
MODULE FILE: global.f90
The module file is compiled and linked the same way as any main program
or procedure files, except its function is different. This is a simple
introduction to the concept of globals that will be detailed in a later
lab. At the moment the introduction to the module file is sufficient.
Any file that accesses the module will have access to the variables and
arrays in the module file. This mitigates the use of long and
cumbersome argument lists specially when variables and arrays are being
used in more than one procedure (subroutine, function and main
program). Here is a small and concise example
module global
implicit none
save
integer :: variable1,variable2
integer,parameter :: parameter1=#
Real(kind=8) :: variable3,variable4
Real(kind=8),dimension(1:parameter1,1:parameter1) :: array1,array2
Real(kind=8),allocatable,dimension(:,:) :: array3
end module global
program main
use global
implicit none
end program main
|
For further reading
refer to the index
HOW TO CREATE THE
EXECUTABLE
This set of files will be used to appreciate the necessary steps
involved in building and executable out of a set of source files.
Whether you are programming in C, C++ or f90 the compile and link step
will be involved.
COMPILE STEP
The compile step involves the compiler to check for language
conformity. All the compile step does is check whether the proper
syntax is being used and the contents of the source code is not in
violation of any rules in the language. When the compile step is
successful a set of object files is created. Before you compile these
files as shown below there is one little catch when modules are
involved. A module creates a dependency that needs to be clarified.
When main.f90 accesses a module (global.f90) and its contents the
information required to successfully compile main.f90 is contained in
global.f90, therefore global.f90 needs to compiled before main.f90. In
this case all the files require information stored in global.f90 and
that is why global.f90 is compiled 1st.
NOTE: You
should be in the src/ dir
|
| <bash>
ifc -c -w
global.f90 main.f90 solver.f90 output.f90 input.f90 |
- -c stands for the compile only flag
- -w stands for ignore all warnings
LINK STEP
The object file cannot be read like a source file. The link step uses
the object file to connect all the procedures and access all the system
libraries from which an executable is created. The executable is when
all the object files link together successfully.
| <bash>
ifc global.o
main.o solver.o output.o input.o -o ../bin/code.x |
- -o stands for the user defined executable output flag
RUNNING THE code.x
The executable code.x will be located in ../bin directory. To run the
executable the following command is used
NOTE: You
should now be in the bin/ dir
|
Whenever a script or a program executable needs to be executed one
needs to prepend the name with a period ("."). Later on we will set it
such that its done for you.
FINAL SOLUTION
The final solution should be a volume plot with spherical contour lines
is as shown below. Till next lab play with this code create some errors
and fix them. You can also play with the "tecplot" program and get
comfortable with it. We will be assigning a lab specifically for tecplot, but i
figured i might as well give you a taste of this cool package that us
CFD
people love to use.
NOTE: You
should now be in the dat/ dir
|
<bash>
cd ../dat
<bash>
tecplot10 output.dat
|

AFTER LAB
ASSIGNMENTS
You will be expected to practice and read supplemental material prior
to the next lab. Failure will result in incompetence and lack of
understanding of future material.
- Read through the following page and get comfortable
with the code development procedure: Quick guide to Projects
- Before your next lab clean up your /home/joeusr
directory so that it
looks neat and organized (click
here)
- Spend the time getting used to the shell and
the desktop items. Play with the customization and become comfortable
launching the shell.
|
|