For details regarding the ERE Report Requirements, see the ERE Report Requirements page.
This page contains the following sections:
An Example Laboratory Submission
An example laboratory, including \text{\LaTeX}, Fortran, gnuplot, and make source code, can be downloaded as tgz here. The makefile to unpack the files and compile the Fortran source code can be found here but is also included within the tgz in the src directory.
Note: You are not required to use \text{\LaTeX}.
A brief tutorial on how to explore these files using Windows and Cygwin follows. Note that the tools used include a POSIX command environment (Cygwin installation) and a \text{\LaTeX} package manager (MikTeX). Equivalent elements are readily available on ERE computers. They also can be made available by properly building a Linux or Macintosh workstation. For more information on software, see the Software Resources page.
Note: In the following instruction, $ indicates the command terminal.
-
Download and Unpack the Example Laboratory Source
- Create a directory to store the example project
and change directories to your target destination:
$ mkdir ~/Engr325
$ mkdir ~/Engr325/Labs
$ mkdir ~/Engr325/Labs/Lab00
$ cd ~/Engr325/Labs/Lab00 -
Download the
tar-zipfile andmakefileto your target directory
-
unpack the contents using the
tarcommand OR the script available in themakefile-
Unpack using terminal commands:
$ mkdir ./unpack
$ tar -xvf lab00_drs37.tgz -C ./unpack
Notes about thetarcommand:- For more information about tar, type:
$ tar --help - Three switches are passed to
tarto specify its behavior:-xspecifies extraction-vspecifies verbose mode (report paths of extracted files)-fspecifies that the next specification will be the file to extract from-Cspecifies that the output should be stored to the following directory
- For more information about tar, type:
-
Unpack using the
makefileby typing:
$ make unpack
Note that the command invokes the same sequence of commands performed manually above.
-
Unpack using terminal commands:
- Create a directory to store the example project
and change directories to your target destination:
-
Compile and Execute the
FortranandgnuplotSource Code
This step is not necessary as the results have been included in thetar-ziparchive.
However, the following steps can be used to reproduce the data from theFortransource and images from thegnuplotscripts and data produced by theFortranprogram.-
Compile the
Fortrancode usinggfortranOR the commands contained in themakefile- Compile using terminal commands
-
Switch to the
unpack/srcdirectory by typing
$ cd ./unpack/src -
Type the following command at your
terminal:
$ gfortran main.f90 calcPowerIR.f90 -o main
Notes aboutmain.f90:- the file contains the main program
-
the main program contains an internal
subroutine:
calc_voltage_ir -
the main file uses an external function:
calc_power_ir
calcPowerIR.f90:-
the file contains the external function
calc_power_irused by the programmaincontained in the filemain.f90. -
the file is listed during the
gfortrancompile command so that the compiler can search its contents for the external functioncalc_power_ir
- Compile using the
makefile
- Switch to the
unpack/srcdirectory by typing
$ cd ./unpack/src - Execute the
makefileby typing
$ make
Notes aboutmake:-
#is the comment character for themakelanguage. - The
makecommand looks within themakefilefor the first target listed. In this case
main : main.o calcPowerIR.o
which tells make that we want to create a target file calledmainwith prerequisitesmain.oandcalcPowerIR.o - The recipe to make the target,
main, is given by
$(FC) $^ $(OFLAGS) main
where
$(FC)is a variable used to store theFortrancompiler (gfortran),$^is the special character that lists all prerequisites (main.oandcalcPowerIR.o)listed for the target (main),$(OFLAGS)are the list of compiler flags specified in the variable defintion:OFLAGS = -o, andmainis the target output file required since the-oflag is specified.
- The target file will only be recompiled if changes are detected in any of the prerequisite files. The prerequisite files are also investigated by the make command.
- If the prerequisite files are missing or altered since the last compilation, the make command will seek other targets in the file allowing the creation or recreation of the prerequisites from the listed prerequisites and recipe listed for the prerequisite-target. See the
makefile's targets formain.oandcalcPowerIR.oas an example. - For more information on
makesee themaketutorial
-
- Execute the
Fortranprogram by typing./mainat the terminal - Test to see if
gnuplotis installed on your terminal by typing
$ gnuplot
This should change your terminal to the gnuplot command line. To exit type
gnuplot>
To exit, typeexitandreturn
gnuplot> exit
There is currently a gnuplot library error that does not allowgnuplotto run these scripts on the Linux side of ERE labcomputers. If this error is resolved, the following should work.
To execute thegnuplotscripts simply type the following at the command terminal../voltage.gnuto produce../output/voltage.pdf
from the data in../output/voltage.dat
Seevoltage.gnufor more details../power.gnuto produce../output/power.pdf
from the data in../output/power.dat
Thegnuplotscript provided uses the shabang-interpreter specification
#!/usr/bin/gnuplot
at the first line of the script so that the interpreter does not need to be included in the command
See thegnuplotdocumentation and the source code provided for more information. -
Compile the
- Compile the \textbf{\LaTeX} Laboratory Report
- Once all files are available, the user should change the working directory to
doc. Here you'll find onetexfile and onejpgimage file used for the cover photo. - The command
pdflatexshould be available at your terminal. Try it! If it's not installed, consult the literature on how to install a \textbf{\LaTeX} package manager for your operating system. - Compile the document by typing
$ pdflatex lab00_drs37.tex

Note: The harpoon.sty file was not available on the ERE Linux distribution. This missing style file will produce an error during compilation. To resolve this issue, comment out the line
\usepackage{harpoon}
by typing a % sign in front of the usepackage command - no commands from the harpoon package is used in this document.
If you perform this command on a Linux machine, you may receive apdflatexcompilation error due to a missing file:makefile(.)
This error would be reported in thepdflatexprogress. To resolve this issue, delete the period aftermakefileon line 359 oflab00_drs37.texand try again.
Old Code:
\includecode{../src/makefile.}{make}\newpage
New Code:
\includecode{../src/makefile}{make}\newpage
The output is stored inlab00_drs37.pdf. The output file is the input file name with a.pdfinstead of a.texextension.
and retry to compile.
- Take a look at
lab00_drs37.pdfand try to match the contents in the document to the code written inlab00_drs37.tex
I've received some reports that the permissions may not allow you to read the pdf. The terminal commandchmodcan resolve the issue for us.chmodchanges the permission of target files. While in thedocdirectory try typing:
$ chmod 755 *
This will provide full access to all files in the directory for all users. See thechmoddocumentation for more details. Use the --help switch by typing
$ chmod --help
Notes aboutlab00_drs37.tex:%is the comment character in \text{\LaTeX}- \text{\LaTeX} documents contain two sections:
- Preamble: used for specifying the document class, formatting, custom definitions, and custom functions used in the document.
- Body: where the content of the printed document is entered
- Preamble
- the example document uses a large number of \text{\LaTeX} packages to enable inclusion of images, special formatting, math typefaces, embedded files, automatic inclusion of source code, hypertext referencing, bookmarks, custom names, custom vector symbols, and more.
- Each package has detailed documentation available on the internet. Simply search the package name with the LaTeX keyword.
- Custom definitions are included allowing the centralization of things like the author's name, lab number, etc. at the top of the document. These definitions are reused several times in the document allowing for changes throughout the document to occur in one location. Learn more about definitions by reading any of the many online resources for \text{\LaTeX}
- Custom commands, or macros, are included in the file that make typesetting mathematical expression faster and more compact.
- This document uses the fancy heading package which requires specifying the different sections of the header and footer.
- Body
- The body of the document is included between the commands:
\begin{document} ... \end{document}. - The document is broken up into sections using the
\sectionand\subsectioncommands. \begin{figure}[H] ... \end{figure}commands create a figure environment.- The
[H]at the end of the\begin{figure}command forces the image to stay at the place the figure was included in the document, otherwise the figure would "float." Thefloatpackage allows us this functionality. - When compiled, the
\captioncommand is used to build a list of figures in the document. - The
\labelcommand is used to specify a referencing label for the image. This allows automatic updating of figure numbers and the references to them.
- The
\begin{table}[H] ... \end{table}commands create a table environment.\begin{tabular}{} ... \end{tabular}manually specifies a table. See the command's literature.
- The body of the document is included between the commands:
- Once all files are available, the user should change the working directory to
- Study the Source Code
Once you've successfully compiled the \text{\LaTeX} document, you should look into the \text{\LaTeX},Fortran,gnuplot, andmakesource code provided to understand how this all works. Use the notes provided as a guideline. Additional details about software elements can be found on the Software Resources page.
To report errors in this tutorial or ask additional questions, please send an e-mail todoug<at>humboldt.edu
Note: The \text{\LaTeX} laboratory report template provided can be adapted to the required project report format. - Packing the file for Moodle submission
- As you've likely noted, this example laboratory consists of multpile files. To submit this assignment to Moodle, we will need to package all relevant content into a single file (
tar-zip) and upload to Moodle. - To
tar-zipthe relevant files, you can either use terminal commands OR use the pack command in the makefile.- Using terminal commands to package the files
- Change directory to
Lab00/src. If you are starting in theLab00/docdirectory, simply type at the command line:
$ cd ../src
- Make a script of the program compiling and running. Use the following commands to create the script:
$ script script.txt
$ gfortran main.f90 calcPowerIR.f90 -o main
$./main
$ exit
- Switch to the top of the unpack directory. From the
srcdirecotry type:
$ cd .. -
Use the following commands to create the
tar-zip.
Note:<user>is a placeholder for your user ID.
$ tar -czf lab00_<user>.tgz ./src/script.txt ./src/main.f90 ./src/calcPowerIR.f90 ./doc/lab00_<user>.pdf - Submit your tar-zip archive to Moodle
- As you've likely noted, this example laboratory consists of multpile files. To submit this assignment to Moodle, we will need to package all relevant content into a single file (
