3.5.5 Compiling and linking user-defined code

The compiling and linking of user-defined code into a model run is done via the shellscript mrun. The simplest (however not the most comfortable) way is by giving the filenames of the files containing the user-defined code as an argument of the shellscript option -s. If the user-defined subroutines are located e.g. on the two files user1.f90 and user2.f90, then the mrun call has to be:

mrun... -s "user1.f90 user2.f90" ... .

For this call the user has to be in the working directory ~/palm/current_version/SOURCE, because the file with the source code of the main program is located here. The main program is compiled with each model run (without the appropriate filename given as argument for the option -s).

The call

is simpler and causes the compilation of all files with suffix .f90 located in the working directory and having user write permissions.  Unchanged sources of the default model have read permission only and therefore are not compiled with that call.

Typically, users may have different versions of user-defined code which are to be used for different model runs. According to the method just described for starting a certain model run, the associated user-defined code would have to be copied into the working directory and code for other runs may have to be removed (otherwise theses files would be compiled as well and the routines like user_actions would occur twice or several times which would lead to compiling errors). This procedure is quite tedious and can lead to errors if different model runs with restarts are to be carried out at the same time. It is better to store the different versions of user-defined code in different subdirectories using the base file name of the respective model run as subdirectory name. In this case a line like

has to be added to the mrun configuration file. If you call mrun now with

the additional entry in the configuration file causes that the files given as argument of the option -s are also looked for in the directory $HOME/palm/current_version/SOURCE/USER_CODE/run1, in case they are not found in the current working directory. The specification of -s TEST in the mrun call now causes compilation of all files with suffix .f90 and user write permissions which are located in the working directory or in the directory indicated by add_source_path. In this case no files with the same name are allowed to be in these two directories.

Further detailed information for linking user-defined code with mrun can be found in chapter 7 of the mrun documentation (only in German).

While programming user-defined code, errors are frequently made. Possible ways of error tracing are described in the next chapter.
 



Last change:  15/04/05 (SR)