Next: Setting the timeLoop, Previous: Customized Coding, Up: Customized Coding
Whenever a new project is begun with the spaopen (with flags
as appropriate) command, a
FORTRAN90 main program template is loaded into the newly-created
directory. The template will have the same name as the project, but
with a .f90 extension. (Note that there is also a configuation
file generated in the directory, named settings.cfg .) Although
the template main program will compile and execute without modifications,
any useful project will require the modification of the template to fit
the specific requirements of the work.
Remember that the purpose of the main program is to interface with the subprograms of the library and of the project; this is not the place to implement calculations and new functionality since any such modifications will not be able to be transferred to the archive. As the archive changes, so too do the template programs, so a template that you created some time ago may no longer work with newer versions of the archive (although we try to maintain backwards compatiblity as much as possible). This is no problem if you've added a couple of read/write satements and a subprogram call to the template file, but will be particularly irritating if you have spent hours creating a monolithic main program out of the template. Obey good coding practices by using subroutines to abstract the functionality of your code and you will be much better off in the long run.
Each standard template file consists of nine parts:
settings.cfg:
call to getParams;
openGridFiles;
timeLoop;
getGridSize and getGridInfo;
dim:
call to makeDim;
readGrid and writeGrid.
As you can probably see from this list, much of the hard work involved in setting up for your calculations has already been done for you. Throughout the code (it would be a good idea to start a test project now so that you can follow along, if you haven't already) you will see MODIFY comments (only 5 in the current implemenation). These alert you to areas in which you may have to make changes, specifically, items 1, 3, 6, 7 and 9 above. Most of these changes will be very minor (ie declaration and allocation of data arrays for your work).
For alternate templates, such as the composite and observational
templates (accessed using the -composite and -obs flags
to the spaopen call, respectively) the nature and number of
modifications may vary. This is particularly true for the
observational template where the calls, while conceptually similar,
vary in syntax and type.