modules.tex 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. This is the technical documentation of the PUMA model. In the following, the purpose of each
  2. module is given and its general structure and possible input and output
  3. parameters provided (namelist, files) are explained.
  4. %--------------------------------------------------------------------------------
  5. \begin{center}
  6. \begin{tabular}{|p{15cm}|}
  7. \hline
  8. \vspace{-5mm} \section{fftmod.f90 / fft991mod.f90} \vspace{-5mm} \\
  9. \hline
  10. \vspace{1mm} {\bf General} The module {\module fftmod.f90} contains all subroutines
  11. necessary to perform the fast fourier transformation and its inverse. The interface to the main
  12. PUMA module {\module puma.f90}
  13. is given by the subroutines {\sub gp2fc} and {\sub
  14. fc2gp} which are called in {\module puma.f90} from the subroutine {\sub gridpoint}. \vspace{3mm} \\
  15. \hline
  16. \vspace{1mm} {\bf Input/Output} {\module fftmod.f90} does not use any additional input or
  17. output files. No namelist input is required. \vspace{3mm} \\
  18. \hline
  19. \vspace{2mm} {\bf Structure} Internally, {\module fftmod.f90} uses the FORTRAN-90 module
  20. {\module fftmod}, which uses no other modules. Subroutine {\sub gp2fc} performs the
  21. transformation from gridpoint space into fourier space while the subroutine {\sub fc2gp} does
  22. the transformation from fourier space into grid point space. Both routines use several
  23. subroutines
  24. to do the direct or indirect transformation for different factors. When {\sub gp2fc} or {\sub
  25. fc2gp} is called for the first time, {\sub fftini} is called to initialize the FFT.
  26. \vspace{3mm} \\
  27. \hline
  28. \vspace{2mm} Alternatively, the module {\module fft991mod.f90} may be used
  29. instead of {\module fftmod.f90}. While {\module fftmod.f90} runs faster,
  30. {\module fft991mod.f90} can be used for resolutions that are not supported by {\module fftmod.f90}, e.g. T63 or T106.
  31. To select the appropriate module edit the file "Most15/puma/src/make\_puma".
  32. Use either:
  33. \begin{verbatim}
  34. FFTMOD=fftmod
  35. \end{verbatim}
  36. or
  37. \begin{verbatim}
  38. FFTMOD=fft991mod
  39. \end{verbatim}
  40. \vspace{3mm} \\
  41. \hline
  42. \end{tabular}
  43. \end{center}
  44. \newpage
  45. %---------------------------------------------------------------------------------------------
  46. \begin{center}
  47. \begin{tabular}{|p{15cm}|}
  48. \hline
  49. \vspace{-5mm} \section{guimod.f90 / guimod\_stub.f90} \vspace{-5mm} \\
  50. \hline
  51. \vspace{1mm} {\bf General} The module {\module guimod.f90}
  52. contains subroutines for communication with the GUI.
  53. On operating systems that do not support the Xlib library (X11R6) e.g. Windows,
  54. {\module guimod\_stub.f90} may be used as a stub replacement.
  55. \vspace{3mm} \\
  56. \hline
  57. \vspace{2mm} {\bf Structure}
  58. The following subroutines are included in {\module guimod.f90}:
  59. \begin{center}
  60. \begin{tabular}{l p{2cm} l}
  61. Subroutine & &Purpose \\
  62. && \\
  63. {\sub guistart} && initialize the GUI \\
  64. {\sub guistop} && finalize the GUI \\
  65. {\sub guistep\_puma} && called every timestep from PUMA \\
  66. {\sub guistep\_plasim} && called every timestep from PLASIM \\
  67. {\sub guips} && gather, scale, and send surface pressure to the GUI \\
  68. {\sub guihor} && gather, scale, and send a gridpoint array to the GUI \\
  69. {\sub guigv} && gather, scale, and send wind components to the GUI \\
  70. {\sub change\_disp} && called for user input into the GUI \\
  71. {\sub change\_dtep} && called for user input into the GUI \\
  72. {\sub change\_dtns} && called for user input into the GUI \\
  73. {\sub change\_co2} && called for user input into the GUI \\
  74. {\sub change\_gsol0} && called for user input into the GUI \\
  75. {\sub change\_dawn} && called for user input into the GUI \\
  76. \end{tabular}
  77. \end{center}
  78. \vspace{3mm} \\
  79. \hline
  80. \end{tabular}
  81. \end{center}
  82. \newpage
  83. %---------------------------------------------------------------------------------------------
  84. \begin{center}
  85. \begin{tabular}{|p{14cm}|}
  86. \hline
  87. \vspace{-5mm} \section{legsym.f90} \vspace{-5mm} \\
  88. \hline
  89. \vspace{1mm} {\bf General} The module {\module legsym.f90}
  90. contains all the subroutines
  91. necessary to perform the Legendre transformation and its inverse.
  92. The module legsym is written for arrays in alternate representation,
  93. which use pairs of Northern and Southern latitudes. This symmetry conserving
  94. scheme is different to the Legendre modules used in PLASIM or the preprocessor.
  95. The interface to the main
  96. PUMA module {\module puma.f90} is given by the subroutines {\sub legini}, {\sub
  97. inigau}, {\sub fc2sp}, {\sub fc3sp}, and {\sub sp2gp}
  98. which are called in {\module puma.f90}
  99. from the subroutines {\sub prolog} and {\sub gridpoint}.
  100. \vspace{3mm} \\
  101. \hline
  102. \vspace{1mm} {\bf Input/Output} {\module legsym.f90}
  103. does not use any other input or output files. No namelist input is required.
  104. \vspace{3mm} \\
  105. \hline
  106. \vspace{1mm}
  107. The following subroutines are included in {\module legsym.f90}:
  108. \begin{center}
  109. \begin{tabular}{l p{2cm} l}
  110. Subroutine & &Purpose \\
  111. && \\
  112. {\sub inigau} && compute Gaussian abscissae and weights \\
  113. {\sub legini} && compute Legendre polynomials \\
  114. {\sub fc2sp} && Fourier to Spectral transformation \\
  115. {\sub fc2spdmu} && Fourier to Spectral transformation with d/dmu \\
  116. {\sub sp2fc} && Spectral to Fourier transformation \\
  117. {\sub sp3fc} && simultaneous transformation of T, Div., and Vort. \\
  118. {\sub mktend} && compute and transform tendencies \\
  119. {\sub reg2alt} && convert regular array to alternate array \\
  120. {\sub alt2reg} && convert alternate array to regular array \\
  121. \end{tabular}
  122. \end{center}
  123. \vspace{3mm} \\
  124. \hline
  125. \end{tabular}
  126. \end{center}
  127. \newpage
  128. %--------------------------------------------------------------------------------
  129. \begin{center}
  130. \begin{tabular}{|p{15cm}|}
  131. \hline
  132. \vspace{-5mm} \section{mpimod.f90 / mpimod\_stub.f90} \vspace{-5mm}
  133. \\
  134. \hline
  135. \vspace{1mm} {\bf General} The module {\module mpimod.f90} contains the interface
  136. subroutines of the MPI ({\bf M}essage {\bf P}assing {\bf I}nterface) needed for
  137. (massive) parallel computing. Several MPI
  138. routines are called from the module. The interface to the other modules is provided by numerous
  139. subroutines with names which begin with {\sub mp}. Subroutines in {\module mpimod.f90} are
  140. called from several other modules. There are no direct calls to the MPI other than
  141. from within {\module mpimod.f90}. This encapsulation makes it possible to
  142. use {\module mpimod\_stub.f90} for single CPU runs without
  143. changing any other part of the model code.
  144. The selection is done automatically when using MoSt, or can be done manually
  145. by editing "Most16/puma/src/make\_puma". \vspace{3mm}
  146. \\
  147. \hline
  148. \vspace{1mm} {\bf Input/Output} {\module mpimod.f90} and {\module mpimod\underline{
  149. }stub} do not use any extra input or
  150. output files. No namelist input is required. \vspace{3mm} \\
  151. \hline
  152. \vspace{2mm} {\bf Structure} Internally, {\module mpimod.f90} uses the FORTRAN-90
  153. module
  154. {\module mpimod}, which in turn uses the global common module {\module pumamod} from
  155. {\module pumamod.f90} and the MPI module {\module mpi}. {\module mpimod\underline{
  156. }stub.f90} does not use any other module. The following subroutines are included in {\module
  157. mpimod.f90}:
  158. \begin{center}
  159. \begin{tabular}{l p{2cm} l}
  160. Subroutine & &Purpose \\
  161. && \\
  162. {\sub mpbci} && broadcast 1 integer \\
  163. {\sub mpbcin} & &broadcast n integers \\
  164. {\sub mpbcr} & &broadcast 1 real \\
  165. {\sub mpbcrn} & &broadcast n reals \\
  166. {\sub mpbcl} && broadcast 1 logical \\
  167. {\sub mpscin} & &scatter n integers \\
  168. {\sub mpscrn} && scatter n reals \\
  169. {\sub mpscgp} && scatter grid point field \\
  170. {\sub mpgagp} && gather grid point field \\
  171. {\sub mpgallgp} && gather grid point field to all \\
  172. {\sub mpscsp} & &scatter spectral field \\
  173. {\sub mpgasp} && gather spectral field \\
  174. {\sub mpgacs} && gather cross section \\
  175. {\sub mpgallsp} && gather spectral field to all \\
  176. {\sub mpsum} && sum spectral field \\
  177. {\sub mpsumsc} && sum and scatter spectral field \\
  178. {\sub mpsumr} && sum n reals \\
  179. {\sub mpsumbcr}& & sum and broadcast n reals \\
  180. {\sub mpstart} & &initialize MPI \\
  181. {\sub mpstop} & &terminate MPI \\
  182. \end{tabular}
  183. \end{center}
  184. \vspace{3mm} \\
  185. \hline
  186. \end{tabular}
  187. \end{center}
  188. \newpage
  189. \begin{center}
  190. \begin{tabular}{|p{15cm}|}
  191. \hline
  192. \begin{center}
  193. \begin{tabular}{l p{2cm} l}
  194. Subroutine & &Purpose \\
  195. && \\
  196. {\sub mpreadgp}& & read and scatter grid point field \\
  197. {\sub mpwritegp}& & gather and write grid point field \\
  198. {\sub mpwritegph} && gather and write (with header) grid point field \\
  199. {\sub mpreadsp} & &read and scatter spectral field \\
  200. {\sub mpwritesp} &&gather and write spectral field \\
  201. {\sub mpi\_info} && report information about setup \\
  202. {\sub mpgetsp} && read spectral array from restart file \\
  203. {\sub mpgetgp} && read gridpoint array from restart file \\
  204. {\sub mpputsp} && write spectral array to restart file \\
  205. {\sub mpputgp} && write gridpoint array to restart file \\
  206. {\sub mpmaxval} && compute maximum value of an array \\
  207. {\sub mpsumval} && compute sum of all array elements \\
  208. \end{tabular}
  209. \end{center}
  210. \vspace{3mm} \\
  211. \hline
  212. \end{tabular}
  213. \end{center}
  214. \newpage
  215. %--------------------------------------------------------------------------------
  216. \begin{center}
  217. \begin{tabular}{|p{15cm}|}
  218. \hline
  219. \vspace{-5mm} \section{puma.f90} \vspace{-5mm} \\
  220. \hline
  221. \vspace{1mm} {\bf General} The module {\module puma.f90}
  222. is the main module of the
  223. model. It includes the main program {\sub puma} and controls the run.
  224. The interface routines to all other modules are
  225. called from {\module puma.f90}.
  226. The output is performed by calling the subroutine to {\module outsp}, and
  227. the adiabatic tendencies and the horizontal
  228. diffusion are also computed in {\module puma.f90}.
  229. To do the necessary transformations, calls to the modules {\module fftmod.f90}
  230. and {\module legsym.f90} are used. \vspace{3mm} \\
  231. \hline
  232. \vspace{1mm} {\bf Input/Output} {\module puma.f90}
  233. A diagnostic printout is written to the standard output
  234. (usually redirected with the operator "$>$" to a file). {\module puma.f90} is
  235. controlled by the namelist {\nam inp} which is part of the namelist file {\file
  236. puma$\_$namelist}. For a complete list of namelist variables see
  237. Appendix C. Here is a table of the most important ones:
  238. \vspace{1mm}
  239. \begin{center}
  240. \begin{tabular}{l l p{6cm} c}
  241. Parameter & Type & Purpose & Default \\
  242. &&&\\
  243. MPSTEP & Integer & MPSTEP (Minutes Per STEP) defines the length of the
  244. time step. Recommended values are 60 min. for T21
  245. and 20 min for T42. The values are not checked
  246. so take care not to violate the CFL
  247. (Courant-Friedrichs-Levy) criterion! & 60 \\
  248. NYEARS & Integer & Number of years to be run & 1 \\
  249. NMONTHS & Integer & Number of months to be run : NYEARS and NMONTHS
  250. may be used together. The simulation length in
  251. days is: NYEARS * 360 + NMONTHS * 30. & 0 \\
  252. NOUTPUT & Integer & NOUTPUT is a global switch for enabling (1)
  253. or disabling (0) writing to {\bf puma\_output}. & 1 \\
  254. NWPD & Integer & NWPD (Number of Writes Per Day) defines the
  255. output interval for writing model arrays to the
  256. file {\bf puma\_output}. Possible values range
  257. from 1 (daily output) to 24 (hourly). & 1 \\
  258. NDIAG & Integer & NDIAG sets the interval (in time steps) for
  259. printing out some diagnostic arrays and values
  260. to the standard output. & 12 \\
  261. \end{tabular}
  262. \end{center}
  263. \vspace{3mm} \\
  264. \hline
  265. \end{tabular}
  266. \end{center}
  267. \newpage
  268. \begin{center}
  269. \begin{tabular}{|p{15cm}|}
  270. \hline
  271. \begin{center}
  272. \begin{tabular}{l l p{5cm} c} %{p{3cm} p{2cm} p{6cm} p{2cm}}
  273. Parameter & Type & Purpose & Default \\
  274. &&&\\
  275. NDL(NLEV) & Integer Array & Switch for diagnostic print out of a level (0~=~off; 1~=~on)
  276. & NLEV $\cdot$ 0 \\
  277. DTEP & Real & Equator to pole temperature difference [K] for Newtonian cooling & 60.0 \\
  278. DTNS & Real & North to South pole temperature difference [K] for Newtonian cooling & 0.0 \\
  279. DTROP & Real & Tropopause height [m] for Newtonian cooling & 12000.0 \\
  280. DTTRP & Real & Smoothing of the tropopause [K] for Newtonian cooling & 2 \\
  281. TGR & Real & Surface temperature [K] for Newtonian cooling & 288 \\
  282. TDISS & Real & Time scale [d] for the horizontal diffusion & 0.25 \\
  283. PSURF & Real & Global mean sea level pressure [Pa] & 101100.00 \\
  284. RESTIM(NLEV) & Real Array & Time scale [d] for Newtonian cooling & 0.0 \\
  285. T0K(NLEV) & Real Array & Reference temperature used in the discretization scheme & 250.0 \\
  286. TFRC(NLEV) & Real Array & Time scale [d] for Rayleigh friction (0.0~=~off)& 0.0
  287. \end{tabular}
  288. \end{center}
  289. \vspace{3mm} \\
  290. \hline
  291. \vspace{2mm} {\bf Structure}
  292. After starting MPI, the main program {\sub puma} calls {\sub
  293. prolog} to initialize the model. Then {\sub master} is called to do the time stepping.
  294. Finally, subroutine {\sub epilog} terminates the run. In subroutine {\sub prolog} calls to
  295. different subroutines, which are part of {\module puma.f90} or are provided by other
  296. modules, initialize various parts of the model: {\sub gauaw} and {\sub inilat} build the grid,
  297. {\sub readnl} reads the namelist file and sets parameters using the namelist input,
  298. {\sub initpm} and {\sub initsi} initialize parameters for the physics and the semi
  299. implicit scheme respectively, and {\sub outini} starts the output.
  300. The program then checks for the existence of a file named "puma\_restart".
  301. If the file can be opened then the restart record
  302. is read by {\sub restart}, otherwise {\sub initfd} sets the prognostic variables
  303. to their initial values.
  304. Finally, the global averaged surface
  305. pressure is set using PSURF and the orography. The subroutine {\sub master} controls the
  306. time stepping. First, if it is not a restart, the initial NKITS explicit forward time steps are
  307. performed.
  308. The main loop is defined by calling {\sub gridpoint} to set the nonlinear tendencies,
  309. and {\sub spectral} to add the linear tendencies. The run is finalized by subroutine
  310. {\sub epilog} which writes the restart records and terminates the MPI. \vspace{3mm} \\
  311. \hline
  312. \end{tabular}
  313. \end{center}
  314. \newpage
  315. %---------------------------------------------------------------------------------------
  316. \begin{center}
  317. \begin{tabular}{|p{15cm}|}
  318. \hline
  319. \vspace{-5mm} \section{pumamod.f90} \vspace{-5mm} \\
  320. \hline
  321. \vspace{1mm} {\bf General} The module {\module pumamod.f90} contains all the parameters
  322. and
  323. variables which may be used to share information between {\module puma.f90} and other
  324. modules. No subroutines or programs are included. \vspace{3mm} \\
  325. \hline
  326. \vspace{1mm} {\bf Input/Output} {\module pumamod.f90} does not use any extra input
  327. or output files. No namelist input is required. \vspace{3mm} \\
  328. \hline
  329. \vspace{2mm} {\bf Structure} Internally, {\module pumamod.f90} is a FORTRAN-90
  330. module named {\module pumamod}. Names for global parameters, scalars and arrays are
  331. declared and, if possible, values are preset.\vspace{3mm} \\
  332. \hline
  333. \end{tabular}
  334. \end{center}
  335. \newpage
  336. %---------------------------------------------------------------------------------------------
  337. \begin{center}
  338. \begin{tabular}{|p{15cm}|}
  339. \hline
  340. \vspace{-5mm} \section{restartmod.f90} \vspace{-5mm} \\
  341. \hline
  342. \vspace{1mm} {\bf General} The module {\module restartmod.f90}
  343. contains routines for opening, reading and writing the restart files.
  344. The scalars and arrays of the restart files
  345. are identified by name. This enables adding or removing
  346. variables from the restart files without loosing compatibility.
  347. There is also no dependence on the sequence of variables.
  348. In parallel runs
  349. these routines are either called from the root process,
  350. which takes care of broadcasting, or from subroutines in
  351. {\module mpimod.f90} which gather before writing,
  352. or scatter after reading, the arrays.
  353. \vspace{3mm} \\
  354. \hline
  355. \vspace{2mm} {\bf Structure}
  356. \begin{center}
  357. \begin{tabular}{l p{2cm} l}
  358. Subroutine & &Purpose \\
  359. && \\
  360. {\sub restart\_ini} && Scan restart file and store pointer \\
  361. {\sub restart\_prepare} && Open file for restart ouput \\
  362. {\sub restart\_stop} && Close files \\
  363. {\sub get\_restart\_integer} && Read integer scalar \\
  364. {\sub get\_restart\_array} && Read real array \\
  365. {\sub put\_restart\_integer} && Write integer scalar \\
  366. {\sub put\_restart\_array} && Write real array \\
  367. {\sub fileseek} && position filepointer to requested variable \\
  368. {\sub check\_equality} && May be used as debug tool \\
  369. \end{tabular}
  370. \end{center}
  371. \vspace{3mm} \\
  372. \hline
  373. \end{tabular}
  374. \end{center}
  375. \newpage
  376. %---------------------------------------------------------------------------------------------