Next: , Previous: Subprogram interfaces, Up: Customized Coding


5.4 Modifying Subprograms

Suppose now that you are not happy with the result of your efforts in the previous section. You wind up with a potential temperature field that defies hydrostacy and you want to know why. Is something wrong with the func_tttopt.f90 subprogram in the SPA? That is, of course, always possible - so you want to have a greater level of control over the function.

Begin by following all of the steps in the interfacing section (see Subprogram interfaces) - which you presumably have already done to get to the problem. The following steps will allow you to gain complete control over the SPA's calculation of potential temperature.

  1. Run make distclean to remove any dependency-related extractions that may have ended up in the project directory;
  2. Enter spaextract tttopt to create a local copy of the subprogram's source in the project directory;
  3. Use your favourite editor to hack the source in any way you see fit;
  4. Run comp90.d to regenerate the Makefile with updated dependencies for the func_tttopt.o object; and,
  5. Enter make ptmp to create the executable.

It is as easy as that to obtain, modify, and recompile sections of the SPA. Note that the SPA keeps track of internal dependencies and extracts dependent files into the project directory during step 4 above. These files should not be modified since the make distclean command will remove them. Should you subsequently wish to modify one of the dependent files, make sure to repeat all of these steps (in order) so that you do not end up modifying a temporary file.

Changing the argument interface to SPA subprograms is a little more difficult, but certainly not impossible. For this, you will need to extract Interface_MRG.f90 along with the subprogram of iterest. Once you have made your modifications to the subprogram argument list, find the related interface block in Interface_MRG.f90 and modify it accordingly. At this point, running comp90.d will cause the extraction of many subprograms, but once they are compiled they will be of little consequence to the project.