Next: Subprogram modification, Previous: Setting the timeLoop, Up: Customized Coding
An example may ease the process of learning to modify the template files and how to use the Developer's Interface to access the subprograms stored in the archive. Let's say that we want to compute the potential temperature for all times in our input file, but for some reason do not wish to use MetCal. Using the developer's interface, we would do the following.
ptmp by entering
the command spaopen ptmp;
cd ptmp_f90;
ptmp.f90 file using our
favourite text editor (ie xemacs, vi, etc);
spalist
(we find it as func_tttopt.f90);
spainfo tttopt and find that it
is part of the Thermodynamics module);
use Thermodynamics
near the first MODIFY comment in the template (ptmp.f90);
tt array
is defined by default as an example) - to allow us to store
our newly-computed potential temperature, we'll add the
pt 3D array by modifying the declaration line to look
like:
real, dimension(:,:,:), allocatable :: tt,pt
timeLoop call will act on every time in the
file, which is what we want so no changes are needed
(see for a complete description of the other options available for looping);
pt array, we need to
add a new line containing something like:
allocate(pt(ni,nj,nk));
spainfo tttopt
if we've forgotten what needs to be provided). In this
case, we're fine since all we need is temperature (the
default) - make sure here that the name of the temperature
variable (RPN Standard 'TT' by default) matches with
the dataset. Under the Calculations here...
comment, we add the call to the required function:
pt = tttopt(tt,dim) and then modify the
writeGrid call to output the potential temperature
field. Something like:
call writeGrid(output(1),pt,'PT',timer(t,:),dim)
will work just fine;
settings.cfg
file to provide the file format, and names of the input and
output files;
comp90.d to generate the Makefile;
make ptmp to create the ptmp executable; and,
ptmp executable to compute the potential
temperature field.
Although this list may look daunting at the outset, such simple modifications can take as little as a minute once you become familiar with the SPA. The code that you have developed is now ready to handle any input file containing the defined temperature field in either RPN Standard or GEMPAK format without recompiling. Congratulations on your first development with the SPA.