Note |
---|
This page is only valid for OpenIFS 43r3 or earlier model releases |
Section | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited builds with FCM
...
|
Note |
---|
Note! Before running these examples, make sure you have built the model by using the ' |
Example1: Modifying compilation options
HowTo customise compiling OpenIFS explains how environment variables and editing the configuration files can alter the compiler settings for OpenIFS. In this simple example, an inherited build is used to achieve the same effect by creating a separate configuration file.
The advantage of this approach is that the source code and configuration files of OpenIFS are left unaltered and do not need any environment variables to be set.
Create directories for your own configuration files and source code. For example, create 'oifs/mymake
' in which to put your own configuration files and 'oifs/mysrc
' to put your own source code:
|
Note |
---|
Note! Before running these examples, make sure you have built the model by using the ' |
Example1: Modifying compilation options
HowTo customise compiling OpenIFS explains how environment variables and editing the configuration files can alter the compiler settings for OpenIFS. In this simple example, an inherited build is used to achieve the same effect by creating a separate configuration file.
The advantage of this approach is that the source code and configuration files of OpenIFS are left unaltered and do not need any environment variables to be set.
Create directories for your own configuration files and source code. For example, create 'oifs/mymake
' in which to put your own configuration files and 'oifs/mysrc
' to put your own source code:
Code Block |
---|
% cd oifs
% mkdir |
Code Block |
% cd oifs
% mkdir mysrc mymake
% ls
COPYING ChangeLog INSTALL LICENSE NOTICE README html make mymake mysrc src t21test
% cd mymake |
...
As in the main 'make
' directory, FCM has created a 'build
' subdirectory which in this case only contains the object file of the routine uvclr
and a new executable. You now have the original executable in 'oifs/make/build/bin/master.exe
' and this modified one for testing/debugging.
To run this new executable as a test, edit the job script in the t21test directory and alter the line: MASTER=
to point to the location of the newly built executable.
Info |
---|
Experiment with this example by adding |
Info |
Experiment with this example by adding additional lines in the To verify the new compiler options are being used add the |
Example 2: Editing existing code
In this example, we'll build on the previous example and edit an existing source file. First make a new directory to hold the modified source code and copy a source file:
...
As in example 1, the 'use' statement tells the build command FCM where to find the pre-compiled OpenIFS and all that's needed here are the changes. In this case, we now need to tell FCM where our new source code is using the 'build.source' statement - the special fcm $HERE variable means "the directory which contains this configuration file". As above, weWe'll also change the compiler options for this file. Note we don't need to include the oifs.cfg file as in the previous example, as this file doesn't contain any references to the OIFS_FFLAGS variable.
...
Note that FCM has: seen the new version of cnt0.F90, recompiled it and relinked it to the pre-compiled object code in oifs/make. The new executable can be found in the build/bin sub-directory. As in example 1, to try out this new executable in the t21test directory edit the script and change the line MASTER=
to point to the location of this executable.
A more advanced example with modules
...
Code Block | ||
---|---|---|
| ||
% fcm make -v -f new-src.cfg [init] make [init] make config-parse [info] config-file=/openifs/inherit_tests/oifs/mymake/new-src.cfg [done] make dest-init [init] make build [info] analyse 0.0 newsrc/newsub.F90 [info] analyse 0.0 ifs/module/yemct0.F90 [info] analyse 0.0 ifs/control/cnt0.F90 [info] sources: total=2193, analysed=3, elapsed-time=0.5s, total-time=0.0s [info] target-tree-analysis: elapsed-time=13.2s [info] compile 0.0 M yemct0.o <- ifs/module/yemct0.F90 [info] compile+ 0.0 M yemct0.mod <- ifs/module/yemct0.F90 [info] ext-iface 0.0 U cnt3.intfb.h <- ifs/control/cnt3.F90 [info] compile 0.0 U cnt2.o <- ifs/control/cnt2.F90 [info] ext-iface 0.0 U cnt0.intfb.h <- ifs/control/cnt0.F90 [info] compile 0.1 U cnt3.o <- ifs/control/cnt3.F90 [info] compile 0.1 M cnt0.o <- ifs/control/cnt0.F90 [FAIL] make build # 25.4s [FAIL] make # 25.6s [FAIL] mpif90 -obin/master.exe /media/hugetmp/Backedup/openifs/inherit_tests/oifs/make/build/o/master.o -L/var/tmp/tmpdir/nagcuser/jtmp.6858/LvpNtq0TxD -lmaster -fopenmp /home/rd/openifs/software/grib_api/1.9.18/grib_api-gcc-4.5.0/lib/libgrib_api_f90.a /home/rd/openifs/software/grib_api/1.9.18/grib_api-gcc-4.5.0/lib/libgrib_api.a -L/usr/local/apps/lapack/3.4.1/LP64 -llapack -lblas -lm # rc=1 [FAIL] /var/tmp/tmpdir/nagcuser/jtmp.6858/LvpNtq0TxD/libmaster.a(cnt0.o): In function `cnt0': [FAIL] /media/hugetmp/Backedup/openifs/inherit_tests/oifs/mysrc3/ifs/control/cnt0.F90:101: undefined reference to `newsub_' [FAIL] collect2: ld returned 1 exit status |
...
Code Block | ||
---|---|---|
| ||
% fcm make -v -f new-src.cfg [init] make # 2013-02-26 17:43:46Z [init] make build # 2013-02-26 17:43:46Z [info] analyse 0.0 newsrc/newsub.F90 [info] analyse 0.0 ifs/module/yemct0.F90 [info] analyse 0.0 ifs/control/cnt0.F90 [info] sources: total=2193, analysed=3, elapsed-time=0.5s, total-time=0.0s [info] target-tree-analysis: elapsed-time=13.4s [info] compile 0.0 M newsub.o <- newsrc/newsub.F90 [info] ext-iface 0.0 M newsub.intfb.h <- newsrc/newsub.F90 [info] compile 0.0 M yemct0.o <- ifs/module/yemct0.F90 [info] compile+ 0.0 M yemct0.mod <- ifs/module/yemct0.F90 [info] ext-iface 0.0 U cnt3.intfb.h <- ifs/control/cnt3.F90 [info] compile 0.0 U cnt2.o <- ifs/control/cnt2.F90 [info] ext-iface 0.0 U cnt0.intfb.h <- ifs/control/cnt0.F90 [info] compile 0.1 U cnt3.o <- ifs/control/cnt3.F90 [info] compile 0.1 M cnt0.o <- ifs/control/cnt0.F90 [info] link 1.7 M master.exe <- programs/master.F90 [info] compile targets: modified=3, unchanged=2069, total-time=0.3s [info] compile+ targets: modified=1, unchanged=625, total-time=0.0s [info] ext-iface targets: modified=1, unchanged=1247, total-time=0.0s [info] install targets: modified=0, unchanged=120, total-time=0.0s [info] link targets: modified=1, unchanged=0, total-time=1.7s [info] TOTAL targets: modified=6, unchanged=4061, elapsed-time=25.2s [done] make build # 25.8s [done] make # 26.0s |
The compilation now succeeds. Note that as well as analysing the new code, FCM has also compiled newsub.F90
and created the interface for it, newsub.intfb.h
(found in the build/include
subdirectory).
Solution 2. Another way to correct the problem is to explicitly tell FCM that the master program depends on the code in our new directory. If you have many new source files and they do not use interface statements you will need to use this approach instead (or as well as - we recommend using interfaces wherever possible).
In this case, rather than edit cnt0.F90
(though its still preferable to include the #include "newsub.intfb.h"
statement in cnt0.F90
), add another statement to the FCM configure file:
...
- If not using inherited builds, always work with copies of the code from the main 'src' directory, never edit the files in src directly - unless you are using a source versioning system, tracking changes and integrating new versions of the code is difficult.
- Inherited builds work well with small and large code changes and help to separate code changes and additions. Any code patches to the main src are automatically compiled in linked with inherited builds whereas if you maintain separate copies of the source you'll need to update every copy.
- Only copy the FCM configuration files from make/fcmcfg if you need to and then only oifs.cfg rather than the hardware and compiler settings. It helps to keep all hardware & compiler specific configuration files in one place (ie. make/fcmcfg) and either make links to them from other directories or, if you are not using inherited builds, use 'include' statements in your modified oifs.cfg file to always refer to them in the default location make/fcmcfg.
...
A more detailed description of the FCM's 'make' command and the syntax of the configuration files can be found in the FCM User's Guide provided by the UK Meteorological Office. Note that OpenIFS only uses the 'make' command and not any other FCM subcommands.
Additional help can be found in the compiling and FCM OpenIFS Frequently Asked Questions page.
The OpenIFS forums can be used to ask questions to the OpenIFS community and support team.
Any questions or problems can also be sent direct to the OpenIFS support team at: openifs-support@ecmwf.int.
...
.
Additional help can be found in the compiling and FCM OpenIFS Frequently Asked Questions page.
The OpenIFS forums can be used to ask questions to the OpenIFS community and support team.
Any questions or problems can also be sent direct to the OpenIFS support team at: openifs-support@ecmwf.int.
Excerpt Include | ||||||
---|---|---|---|---|---|---|
|