/[MITgcm]/manual/s_autodiff/text/doc_ad_2.tex
ViewVC logotype

Diff of /manual/s_autodiff/text/doc_ad_2.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4 by heimbach, Fri Oct 5 22:22:20 2001 UTC revision 1.5 by heimbach, Wed Oct 10 16:06:41 2001 UTC
# Line 1091  for TAMC. Line 1091  for TAMC.
1091  \end{itemize}  \end{itemize}
1092    
1093    
1094  \subsubsection{File {\it data}}  \subsubsection{The input parameter files}
1095    
1096  \subsubsection{File {\it data.cost}}  \paragraph{File {\it data}}
1097    
1098  \subsubsection{File {\it data.ctrl}}  \paragraph{File {\it data.cost}}
1099    
1100  \subsubsection{File {\it data.gmredi}}  \paragraph{File {\it data.ctrl}}
1101    
1102  \subsubsection{File {\it data.grdchk}}  \paragraph{File {\it data.gmredi}}
1103    
1104  \subsubsection{File {\it data.optim}}  \paragraph{File {\it data.grdchk}}
1105    
1106  \subsubsection{File {\it data.pkg}}  \paragraph{File {\it data.optim}}
1107    
1108  \subsubsection{File {\it eedata}}  \paragraph{File {\it data.pkg}}
1109    
1110  \subsubsection{File {\it topog.bin}}  \paragraph{File {\it eedata}}
1111    
1112  \subsubsection{File {\it windx.bin, windy.bin}}  \paragraph{File {\it topog.bin}}
1113    
1114  \subsubsection{File {\it salt.bin, theta.bin}}  \paragraph{File {\it windx.bin, windy.bin}}
1115    
1116  \subsubsection{File {\it SSS.bin, SST.bin}}  \paragraph{File {\it salt.bin, theta.bin}}
1117    
1118  \subsubsection{File {\it pickup*}}  \paragraph{File {\it SSS.bin, SST.bin}}
1119    
1120  \subsection{Compiling the model and its adjoint}  \paragraph{File {\it pickup*}}
1121    
1122    \subsection{Compiling the model and its adjoint}
1123    
1124    The built process of the adjoint model is slightly more
1125    complex than that of compiling the forward code.
1126    The main reason is that the adjoint code generation requires
1127    a specific list of routines that are to be differentiated
1128    (as opposed to the automatic generation of a list of
1129    files to be compiled by genmake).
1130    This list excludes routines that don't have to be or must not be
1131    differentiated. For some of the latter routines flow directives
1132    may be necessary, a list of which has to be given as well.
1133    For this reason, a separate {\it makefile} is currently
1134    maintained in the directory {\tt adjoint/}. This
1135    makefile is responsible for the adjoint code generation.
1136    
1137    In the following we describe the build process step by step,
1138    assuming you are in the directory {\tt bin/}.
1139    A summary of steps to follow is given at the end.
1140    
1141    \paragraph{Adjoint code generation and compilation -- step by step}
1142    
1143    \begin{enumerate}
1144    %
1145    \item
1146    {\tt ln -s ../verification/???/code/.genmakerc .} \\
1147    {\tt ln -s ../verification/???/code/*.[Fh] .} \\
1148    Link your customized genmake options, header files,
1149    and modified code to the compile directory.
1150    %
1151    \item
1152    {\tt ../tools/genmake -makefile} \\
1153    Generate your Makefile (cf. Section ???).
1154    %
1155    \item
1156    {\tt make depend} \\
1157    Dependency analysis for the CPP pre-compiler (cf. Section ???).
1158    %
1159    \item
1160    {\tt make small\_f} \\
1161    This is the first difference between forward code compilation
1162    and adjoint code generation and compilation.
1163    Instead of going through the entire compilation process
1164    (CPP precompiling -- {\tt .f}, object code generation -- {\tt .o},
1165    linking of object files and libraries to generate executable),
1166    only the CPP compiler is invoked at this stage to generate
1167    the {\tt .f} files.
1168    %
1169    \item
1170    {\tt cd ../adjoint} \\
1171    {\tt make adtaf} or {\tt make adtamc} \\
1172    Depending on whether you have TAF or TAMC at your disposal,
1173    you'll choose {\tt adtaf} or {\tt adtamc} as your
1174    make target for the {\it makefile} in the directory {\tt adjoint/}.
1175    Several things happen at this stage.
1176    %
1177    \begin{enumerate}
1178    %
1179    \item
1180    The initial template file {\it adjoint\_model.F} which is part
1181    of the compiling list created by {\it genmake} is restored.
1182    %
1183    \item
1184    All Fortran routines {\tt *.f} in {\tt bin/} are
1185    concatenated into a single file (it's current name is
1186    {\it tamc\_code.f}).
1187    %
1188    \item
1189    Adjoint code is generated by TAMC or TAF.
1190    The adjoint code is written to the file {\it tamc\_code\_ad.f}.
1191    It contains all adjoint routines of the forward routines
1192    concatenated in {\it tamc\_code.f}.
1193    For a given forward routines {\tt subroutine routinename}
1194    the adjoint routine is named {\tt adsubroutine routinename}
1195    by default (that default can be changed via the flag
1196    {\tt -admark <markname>}).
1197    Furthermore, it may contain modified code which
1198    incorporates the translation of adjoint store directives
1199    into specific Fortran code.
1200    For a given forward routines {\tt subroutine routinename}
1201    the modified routine is named {\tt mdsubroutine routinename}.
1202    TAMC or TAF info is written to file
1203    {\it tamc\_code.prot} or {\it taf.log}, respectively.
1204    %
1205    \end{enumerate}
1206    %
1207    \item
1208    {\tt make adchange} \\
1209    The multi-threading capability of the MITGCM requires a slight
1210    change in the parameter list of some routines that are related to
1211    to active file handling.
1212    This postprocessing invokes the sed script {\it adjoint\_ecco\_sed.com}
1213    to insert the threading counter {\bf myThId} into the parameter list
1214    of those subroutines.
1215    The resulting code is written to file {\it tamc\_code\_sed\_ad.f}
1216    and appended to the file {\it adjoint\_model.F}.
1217    This concludes the adjoint codel generation.
1218    %
1219    \item
1220    {\tt cd ../bin} \\
1221    {\tt make} \\
1222    The file {\it adjoint\_model.F} now contains the full adjoint code.
1223    All routines are now compiled.
1224    %
1225    \end{enumerate}
1226    
1227    \paragraph{Adjoint code generation and compilation -- summary}
1228    ~ \\
1229    
1230    \[
1231    \boxed{
1232    \begin{split}
1233     ~ & \mbox{\tt cd bin} \\
1234     ~ & \mbox{\tt ln -s ../verification/my\_experiment/code/.genmakerc .} \\
1235     ~ & \mbox{\tt ln -s ../verification/my\_experiment/code/*.[Fh] .} \\
1236     ~ & \mbox{\tt ../tools/genmake -makefile} \\
1237     ~ & \mbox{\tt make depend} \\
1238     ~ & \mbox{\tt make small\_f} \\
1239     ~ & \mbox{\tt cd ../adjoint} \\
1240     ~ & \mbox{\tt make adtaf <OR: make adtamc>} \\
1241     ~ & \mbox{\tt make adchange} \\
1242     ~ & \mbox{\tt cd ../bin} \\
1243     ~ & \mbox{\tt make} \\
1244    \end{split}
1245    }
1246    \]
1247    
1248  \newpage  \newpage
1249    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.22