|
|
|
Next: 3.20 Offline Example
Up: 3.19 Sensitivity of Air-Sea
Previous: 3.19.2 Code configuration
Contents
Subsections
The built process of the adjoint model is slightly more
complex than that of compiling the forward code.
The main reason is that the adjoint code generation requires
a specific list of routines that are to be differentiated
(as opposed to the automatic generation of a list of
files to be compiled by genmake).
This list excludes routines that don't have to be or must not be
differentiated. For some of the latter routines flow directives
may be necessary, a list of which has to be given as well.
For this reason, a separate makefile is currently
maintained in the directory adjoint/. This
makefile is responsible for the adjoint code generation.
In the following we describe the build process step by step,
assuming you are in the directory bin/.
A summary of steps to follow is given at the end.
- ln -s ../verification/???/code/.genmakerc .
ln -s ../verification/???/code/*.[Fh] .
Link your customized genmake options, header files,
and modified code to the compile directory.
- ../tools/genmake -makefile
Generate your Makefile (cf. Section ???).
- make depend
Dependency analysis for the CPP pre-compiler (cf. Section ???).
- cd ../adjoint
make adtaf or make adtamc
Depending on whether you have TAF or TAMC at your disposal,
you'll choose adtaf or adtamc as your
make target for the makefile in the directory adjoint/.
Several things happen at this stage.
- make adrestore, make ftlrestore
The initial template files adjoint_model.F
and tangentlinear_model.F in pkg/autodiff
which are part
of the compiling list created by genmake are restored.
- make depend, make small_f
The bin/ directory is brought up to date,
i.e. for recent changes in header or source code
.[Fh], corresponding .f routines are generated
or re-generated.
Note that here, only CPP precompiling is performed;
no object code .o is generated as yet.
Precompiling is necessary for TAMC to see the full code.
- make allcode
All Fortran routines *.f in bin/ are
concatenated into a single file called
tamc_code.f.
- make admodeltaf/admodeltamc
Adjoint code is generated by TAMC or TAF.
The adjoint code is written to the file tamc_code_ad.f.
It contains all adjoint routines of the forward routines
concatenated in tamc_code.f.
For a given forward routines subroutine routinename
the adjoint routine is named adsubroutine routinename
by default (that default can be changed via the flag
-admark <markname>).
Furthermore, it may contain modified code which
incorporates the translation of adjoint store directives
into specific Fortran code.
For a given forward routines subroutine routinename
the modified routine is named mdsubroutine routinename.
TAMC or TAF info is written to file
tamc_code.prot or taf.log, respectively.
- make adchange
The multi-threading capability of MITgcm requires a slight
change in the parameter list of some routines that are related to
to active file handling.
This post-processing invokes the sed script adjoint_ecco_sed.com
to insert the threading counter myThId into the parameter list
of those subroutines.
The resulting code is written to file tamc_code_sed_ad.f
and appended to the file adjoint_model.F.
This concludes the adjoint code generation.
- cd ../bin
make
The file adjoint_model.F now contains the full adjoint code.
All routines are now compiled.
N.B.: The targets make adtaf/adtamc now comprise a
series of targets that in previous versions had to be
invoked separarely. This was probably preferable at a more
experimental stage, but has now been dropped in favour of
a more straightforward build process.
Next: 3.20 Offline Example
Up: 3.19 Sensitivity of Air-Sea
Previous: 3.19.2 Code configuration
Contents
mitgcm-support@mitgcm.org
Copyright © 2006
Massachusetts Institute of Technology |
Last update 2011-01-09 |
|
|