1%
2% $Id$
3%
4\label{sec:toplevel}
5
6Top-level directives are directives that can affect all modules in the
7code.  Some specify molecular properties (e.g., total charge) or other
8data that should apply to all subsequent calculations with the current
9database.  However, most top-level directives provide the user with
10the means to manage the resources for a calculation and to start
11computations.  As the first step in the execution of a job, NWChem
12scans the entire input file looking for start-up directives, which
13NWChem must process before all other input.  The input file is then
14rewound and processed sequentially, and each directive is processed in
15the order in which it is encountered.  In this second pass, start-up
16directives are ignored.
17
18The following sections describe each of the top-level directives in
19detail, noting all keywords, options, required input, and defaults.
20
21\section{{\tt START} and {\tt RESTART} --- Start-up mode}
22\label{sec:start}
23
24A {\tt START} or {\tt RESTART} directive is
25optional.  If one of these two directives is not specified
26explicitly, the code will infer one, based upon the name of the
27input file and the availability of the database.  When allowing NWChem
28to infer the start-up directive, the user must be quite certain that
29the contents of the database will result in the desired action.  It
30is usually more prudent to specify the directive explicitly, using the
31following format:
32
33\begin{verbatim}
34(RESTART || START)   \
35            [<string file_prefix default $input_file_prefix$>] \
36            [rtdb <string rtdb_file_name default $file_prefix$.db>]
37\end{verbatim}
38
39The \verb+START+ directive indicates that the calculation is one in
40which a new database is to be created.  Any relevant information that
41already exists in a previous database of the same name is destroyed.
42The string variable {\tt <file\_prefix>} will be used as the prefix to
43name any files created in the course of the calculation.
44
45E.g., to start a new calculation on water, one might specify
46\begin{verbatim}
47  start water
48\end{verbatim}
49which will make all files begin with {\tt "water."}.
50
51If the user does not specify an entry for {\tt <file\_prefix>} on the
52\verb+START+ directive (or omits the \verb+START+ directive
53altogether), the code uses the base-name of the input file as the file
54prefix.  That is, the variable {\tt <file\_prefix>} is assigned the
55name of the input file (not its full pathname), but without the last
56``dot-suffix''.  For example, the input file name
57\verb+/home/dave/job.2.nw+ yields \verb+job.2+ as the file prefix, if
58a name is not assigned explicitly using the \verb+START+ directive.
59
60The user also has the option of
61specifying a unique name for the database, using the keyword {\tt
62  rtdb}.  When this keyword is entered, the string entered for {\tt
63  rtdb\_file\_name} is used as the database name.  If the keyword {\tt
64  rtbd} is omitted, the name of the database defaults to
65\verb+$<file_prefix>$.db+ in the directory for permanent files.
66
67If a calculation is to start from a previous calculation and go on
68using the existing database, the \verb+RESTART+ directive
69must be used.  In such a case, the previous
70database must already exist.  The name specified for {\tt <file\_prefix>}
71usually should
72not be changed when restarting a calculation.  If it is changed, NWChem
73will not
74be able to find needed files when going on with the
75calculation.
76
77In the most common
78situation, the previous calculation was completed (with or without an error
79condition), and it is desired to perform a new task or restart the
80previous one, perhaps with some input changes.  In these instances,
81the \verb+RESTART+ directive should be used.  This reuses the previous
82database and associated files, and reads the input file for new input
83and task information.
84
85The \verb+RESTART+ directive looks immediately for new input and task
86information, deleting information about previous incomplete tasks.
87For example, when doing a \verb+RESTART+ there is no need
88to specify geometry or basis set declaration because the
89program will detect this information since it is stored in the
90run-time database.
91
92If a calculation runs out of time, for example because it is
93on a queuing system, this is another instance where doing a
94\verb+RESTART+ is advisable.  Simply include nothing after the
95\verb+RESTART+ directive except those tasks that are unfinished.
96
97NOTE: Due to changes in the runtime database structure, \verb+RESTART+
98will not work on database files generated by NWChem versions 4.0.1 and
99older.
100
101To summarize the default options for this start-up directive, if the
102input file does {\em not} contain a \verb+START+ or a
103\verb+RESTART+ directive, then
104\begin{itemize}
105  \item the variable {\tt <file\_prefix>} is assigned the name of the
106input file for the job, without the suffix (which is usually \verb+.nw+)
107  \item the variable {\tt <rtdb\_file\_name>} is assigned the default name,
108\verb+$file_prefix$.db+
109\end{itemize}
110If the database with name \verb+$file_prefix$.db+ does {\em not}
111already exist,
112the calculation is carried out as if a \verb+START+ directive had
113been encountered.  If the database with name \verb+$file_prefix$.db+
114{\em does} exist, then the calculation is performed as if a
115\verb+RESTART+ directive had been encountered.
116
117For example, NWChem can be run using an input file with the name
118\verb+water.nw+
119by typing the UNIX command line,
120
121\begin{verbatim}
122   nwchem water.nw
123\end{verbatim}
124
125If the NWChem input file \verb+water.nw+ does not contain
126a \verb+START+  or \verb+RESTART+ directive, the code
127sets the variable {\tt <file\_prefix>} to {\tt water}.  Files created
128by the job will have this prefix, and the database will be named
129{\tt water.db}.  If the database \verb+water.db+ does {\em not} exist already,
130the code behaves as if the input file contains the directive,
131
132\begin{verbatim}
133  start water
134\end{verbatim}
135
136If the database \verb+water.db+ {\em does} exist,
137the code behaves as if the input file contained the directive,
138
139\begin{verbatim}
140  restart water
141\end{verbatim}
142
143
144\section{{\tt SCRATCH\_DIR} and {\tt PERMANENT\_DIR} --- File directories}
145\label{sec:dirs}
146
147These are start-up directives that allow the user to specify the
148directory location of scratch and permanent files created by NWChem.
149NWChem distinguishes between permanent (or persistent) files and
150scratch (or temporary) files, and allows the user the option of
151putting them in different locations.  In most installations, however,
152permanent and scratch files are all written to the current directory
153by default.  What constitutes ``local'' disk space may also differ from
154machine to machine.
155
156The conventions for file storage are at the discretion of the specific
157installation, and are quite likely to be different on different machines.
158When assigning locations for permanent and
159scratch files,
160the user must be cognizant of the characteristics of the installation
161on a particular platform.
162To consider just a few examples, on
163clusters, machine-specific or process-specific
164names must be supplied for both local and shared file
165systems, while on SMPs it is useful to specify scratch file directories
166with automated striping across processors with round-robin allocation.
167On SMP clusters (a.k.a. constellations), both of these specifications
168are required.
169
170The \verb+SCRATCH_DIR+ and \verb+PERMANENT_DIR+ directives are
171identical in format and capability, and enable the user to specify a
172single directory for all processes, or different directories for
173different processes.  The general form of the directive is as follows:
174
175\begin{verbatim}
176   (PERMANENT_DIR || SCRATCH_DIR) [(<string host>||<integer process>):] \
177                                       <string directory> \
178                                  [...]
179\end{verbatim}
180
181Directories are extracted from the user input by executing the
182following steps, in sequence:
183\begin{enumerate}
184\item Look for a directory qualified by the process ID number of the
185  invoking process.  Processes are numbered from zero.  Else,
186\item If there is a list of directories qualified by the name of the
187  host machine\footnote{As returned by {\tt util\_hostname()} which
188    maps to the output of the command {\tt hostname} on Unix
189    workstations.}, then use round-robin allocation from the list for
190  processes executing on the given host.  Else,
191\item If there is a list of directories unqualified by any hostname
192  or process ID, then use round-robin allocation from this list.
193\end{enumerate}
194If directory allocation directive(s) are not specified in the input
195file, or if no match is found to the directory names specified by
196input using these directives, then the  steps above are executed using
197the installation-specific defaults.  If the code cannot find a valid
198directory name based on the input specified in either the directive(s)
199or the system defaults, files are automatically written to the current
200working directory (\verb+"."+).
201
202The following is a list of examples of specific allocations of scratch
203directory locations:
204\begin{itemize}
205\item Put scratch files from all processes in the local scratch directory
206(Warning: the definition of ``local scratch directory'' may change from
207machine to machine):
208\begin{verbatim}
209      scratch_dir /localscratch
210\end{verbatim}
211\item Put scratch files from Process 0 in \verb+/piofs/rjh+, but put all
212other scratch files in \verb+/scratch+:
213\begin{verbatim}
214      scratch_dir /scratch 0:/piofs/rjh
215\end{verbatim}
216\item Put scratch files from Process 0 in directory \verb+scr1+, those from
217Process 1 in \verb+scr2+, and so forth, in a round-robin fashion, using the
218given list of directories:
219\begin{verbatim}
220      scratch_dir /scr1 /scr2 /scr3 /scr4 /scr5
221\end{verbatim}
222\item Allocate files in a round-robin fashion from
223  host-specific lists for processes distributed across two
224 SGI multi-processor machines (node names {\em coho} and {\em bohr}):
225\begin{verbatim}
226      scratch_dir coho:/xfs1/rjh coho:/xfs2/rjh coho:/xfs3/rjh \
227          bohr:/disk01/rjh bohr:/disk02/rjh bohr:/disk13/rjh
228\end{verbatim}
229\end{itemize}
230
231\section{{\tt MEMORY} --- Control of memory limits}
232
233This is a start-up directive that allows the user to specify the
234amount of memory that NWChem can use for the job.  If this directive
235is not specified, memory is allocated according to
236installation-dependent defaults.  {\em The defaults should generally
237  suffice for most calculations, since the defaults usually correspond
238  to the total amount of memory available on the machine.  It should
239usually be unnecessary to provide a memory directive!!!}
240
241The general form of the directive is as follows:
242
243\begin{verbatim}
244  MEMORY [[total] <integer total_size>] \
245         [stack <integer stack_size>] \
246         [heap <integer heap_size>] \
247         [global <integer global_size>] \
248         [units <string units default real>] \
249         [(verify||noverify)] \
250         [(nohardfail||hardfail)] \
251\end{verbatim}
252
253NWChem recognizes the following memory units:
254\begin{itemize}
255\item \verb+real+ and \verb+double+ (synonyms)
256\item \verb+integer+
257\item \verb+byte+
258\item \verb+kb+ (kilobytes)
259\item \verb+mb+ (megabytes)
260\item \verb+mw+ (megawords, 64-bit word)
261\end{itemize}
262
263In most cases, the user need specify only the total memory limit to
264adjust the amount of memory used by NWChem. The following specifications
265all provide for eight megabytes of total
266memory (assuming 64-bit floating point numbers), which will be
267distributed according to the default partitioning:
268\begin{verbatim}
269  memory 1048576
270  memory 1048576 real
271  memory 1 mw
272  memory 8 mb
273  memory total 8 mb
274  memory total 1048576
275\end{verbatim}
276
277In NWChem there are three distinct regions of memory: stack, heap,
278and global. Stack and heap are node-private, while the union of the
279global region on all processors is used to provide globally-shared memory.
280The allowed limits on each category are determined from a default
281partitioning (currently 25\% heap, 25\% stack, and 50\% global).
282Alternatively, the keywords \verb+stack+, \verb+heap+, and
283\verb+global+ can be used to define specific allocations for each of
284these categories.  If the user sets only one of the stack, heap, or
285global limits by input, the limits for the other two categories are
286obtained by partitioning the remainder of the total memory available
287in proportion to the weight of those two categories in the default
288memory partitioning.  If two of the category limits are given, the
289third is obtained by subtracting the two given limits from the total
290limit (which may have been specified or may be a default value).  If
291all three category limits are specified, they determine the total
292memory allocated.  However, if the total memory is also specified, it
293must be larger than the sum of all three categories.  The code will
294abort if it detects an inconsistent memory specification.
295
296The following memory directives also allocate 8 megabytes, but specify
297a complete partitioning as well:
298
299\begin{verbatim}
300  memory total 8 stack 2 heap 2 global 4 mb
301  memory stack 2 heap 2 global 4 mb
302\end{verbatim}
303
304The optional keywords \verb+verify+ and \verb+noverify+ in the
305directive give the user the option of enabling or disabling automatic
306detection of corruption of allocated memory.  The default is
307\verb+verify+, which enables the feature. This incurs some
308overhead (which can be around 10\% increase in walltime on some platforms),
309which can be eliminated by specifying \verb+noverify+.
310
311The keywords \verb+hardfail+ and \verb+nohardfail+ give the user the
312option of forcing (or not forcing) the local memory management
313routines to generate an internal fatal error if any memory operation
314fails.  The default is \verb+nohardfail+, which allows the code to
315continue past any memory operation failure, and perhaps generate a
316more meaningful error message before terminating the calculation.
317Forcing a hard-fail can be useful when poorly coded applications do
318not check the return status of memory management routines.
319
320When assigning the specific memory allocations using the keywords
321\verb+stack+, \verb+heap+, and \verb+global+ in the \verb+MEMORY+
322directive, the user should be aware that some of the distinctions
323among these categories of memory have been blurred in their actual
324implementation in the code.  The memory allocator (MA) allocates both
325the heap and the stack from a single memory region of size {\tt
326  heap+stack}, without enforcing the partition.  The heap vs.\ stack
327partition is meaningful only to applications developers, and can be
328ignored by most users.  Further complicating matters, the global array
329(GA) toolkit is allocated from within the MA space on distributed
330memory machines, while on shared-memory machines it is
331separate\footnote{This is because on true shared-memory machines there
332  is no choice but to allocate GAs from within a shared-memory
333  segment, which is managed differently by the operating system.}.
334
335On distributed memory platforms, the MA region is actually the total
336size of
337\begin{verbatim}
338   stack+heap+global
339\end{verbatim}
340All three types of memory allocation
341compete for the same pool of memory, with no limits except on the
342total available memory.  This relaxation of the memory category
343definitions usually benefits the user, since it can allow allocation
344requests to succeed where a stricter memory model would cause the
345directive to fail.  These implementation characteristics must be kept
346in mind when reading program output that relates to memory usage.
347
348Standard default for memory is currently 400 MB.
349
350\section{{\tt ECHO} --- Print input file}
351\label{sec:echo}
352
353This start-up directive is provided as a convenient way to include a
354listing of the input file in the output of a calculation.  It causes
355the entire input file to be printed to Fortran unit six (standard
356output).  It has no keywords, arguments, or options, and consists of
357the single line:
358
359\begin{verbatim}
360  ECHO
361\end{verbatim}
362
363The \verb+ECHO+ directive is processed only
364once, by Process 0 when the input file is read.
365
366\section{{\tt TITLE} --- Specify job title}
367
368This top-level directive allows the user to identify a job or series
369of jobs that use a particular database.  It is an optional directive,
370and if omitted, the character string containing the input title will
371be empty.  Multiple {\tt TITLE} directives may appear in the input
372file (e.g., the example file in Section \ref{sec:realsample}) in which
373case a task will use the one most recently specified.  The format for
374the directive is as follows:
375
376\begin{verbatim}
377  TITLE <string title>
378\end{verbatim}
379
380The character string \verb+<title>+ is assigned to the contents of the
381string following the \verb+TITLE+ directive.  If the string contains
382white space, it must be surrounded by double quotes.  For example,
383
384\begin{verbatim}
385  title "This is the title of my NWChem job"
386\end{verbatim}
387
388The title is stored in the database and will be used in all subsequent
389tasks/jobs until redefined in the input.
390
391\section{{\tt PRINT} and {\tt NOPRINT} --- Print control}
392\label{sec:printcontrol}
393
394The \verb+PRINT+ and \verb+NOPRINT+ directives allow the user to
395control how much output NWChem generates.  These two directives are
396special in that the compound directives for {\em all} modules are
397supposed to recognize them. Each module can control both the overall
398print level (general verbosity) and the printing of individual items
399which are identified by name (see below).  The standard form of the
400\verb+PRINT+ directive is as follows:
401
402\begin{verbatim}
403  PRINT [(none || low || medium || high || debug) default medium] \
404        [<string list_of_names ... >]
405
406  NOPRINT <string list_of_names ... >
407\end{verbatim}
408The default print level is medium.
409
410Every output that is printed by NWChem has a print threshold
411associated with it. If this threshold is equal to or lower than the
412print level requested by the user, then the output is generated.  For
413example, the threshold for printing the SCF energy at convergence is
414\verb+low+ (Section \ref{sec:scfprint}).  This means that if the
415user-specified print level on the \verb+PRINT+ directive is
416\verb+low+, \verb+medium+, \verb+high+, or \verb+debug+, then the SCF
417energy will be printed at convergence.
418
419The overall print level specified
420using the \verb+PRINT+ directive is a convenient tool for controlling
421the verbosity
422of NWChem. Setting the print level to \verb+high+ might be helpful in
423diagnosing convergence problems.  The print level of \verb+debug+ might
424also be of use in evaluating problem cases, but the user should be aware
425that this can generate a huge amount of output.  Setting the print level
426to \verb+low+ might be the preferable choice for geometry
427optimizations that will perform many steps which are in themselves of
428little interest to the user.
429
430In addition, it is possible to enable the printing of specific
431items by naming them in the \verb+PRINT+ directive in the
432\verb+<list_of_names>+.  Items identified in this way will be printed,
433regardless of the overall print level specified.  Similarly, the
434\verb+NOPRINT+ directive can be used to suppress the printing of specific
435items by naming them in its \verb+<list_of_names>+.  These items will
436{\em not} be printed, regardless of the overall print level, or the
437specific print level of the individual items.
438
439The list of items that can be printed for each module is documented
440as part of the input instructions for that module.
441The items recognized by the top level of the code, and their thresholds,
442are:
443\begin{table}[htbp]
444\begin{center}
445\begin{tabular}{lcc}
446  {\bf Name}          & {\bf Print Level} & {\bf Description} \\
447 ``total time''        & medium & Print cpu and wall time at job end\\
448 ``task time''         & high   & Print cpu and wall time for each task\\
449 ``rtdb''              & high    & Print names of RTDB entries\\
450 ``rtdbvalues''        & high    & Print name and values of RTDB entries\\
451 ``ga summary''        & medium & Summarize GA allocations at job end \\
452 ``ga stats''          & high   & Print GA usage statistics at job end \\
453 ``ma summary''        & medium & Summarize MA allocations at job end \\
454 ``ma stats''          & high   & Print MA usage statistics at job end \\
455 ``version''           & debug  & Print version number of all compiled routines \\
456  ``tcgmsg''           & never  & Print TCGMSG debug information \\
457\end{tabular}
458\end{center}
459\caption{Top Level Print Control Specifications}
460\end{table}
461
462
463The following example shows how a \verb+PRINT+ directive for the top level
464process can be used to limit printout to only essential information.
465The directive is
466
467\begin{verbatim}
468  print none "ma stats" rtdb
469\end{verbatim}
470
471This directive instructs the NWChem main program to print nothing,
472except for the memory usage statistics (\verb+ma stats+) and
473the names of all items stored in the database at the end of the job.
474
475The print level within a module is inherited from the
476calling layer.  For instance, by specifying the print to be low
477within the MP2 module will cause the SCF, CPHF and gradient modules
478when invoked from the MP2 to default to low print.  Explicit user
479input of print thresholds overrides the inherited value.
480
481\section{{\tt SET} --- Enter data in the RTDB}
482\label{sec:set}
483
484This top-level directive allows the user to enter data directly into the
485run-time
486database (see Section \ref{sec:database} for a description of the database).
487The format of the directive is as follows:
488
489\begin{verbatim}
490  SET <string name> [<string type default automatic>] <$type$ data>
491\end{verbatim}
492
493The entry for variable \verb+<name>+ is the name of
494data to be entered into the database.  This must be specified; there is no default.  The variable \verb+<type>+, which is
495optional, allows the user to define a string specifying the type of
496data in the array \verb+<name>+.  The data type can be explicitly
497specified as \verb+integer+, \verb+real+, \verb+double+,
498\verb+logical+, or \verb+string+.  If no entry for \verb+<type>+ is
499specified on the directive, its value is inferred from the data type
500of the {\em first} datum.  In such a case, floating-point data
501entered using this directive must include either an exponent or a
502decimal point, to ensure that the correct default type will be
503inferred.  The correct default type will be inferred for logical
504values if logical-true values are specified as \verb+.true.+,
505\verb+true+, or \verb+t+, and logical-false values are specified as
506\verb+.false.+, \verb+false+, or \verb+f+.  One exception to the
507automatic detection of the data type is that the data type {\bf must}
508be explicitly stated to input integer ranges, unless the first
509element in the list is an integer that is not a range (c.f.,
510\ref{sec:syntax}).  For example,
511\begin{verbatim}
512  set atomid 1 3:7 21
513\end{verbatim}
514will be interpreted as a list of integers.  However,
515\begin{verbatim}
516  set atomid 3:7 21
517\end{verbatim}
518will not work since the first element will be interpreted as a
519string and not an integer.  To work around this feature, use instead
520\begin{verbatim}
521  set atomid integer 3:7 21
522\end{verbatim}
523which says to write  three through seven, as well as twenty-one.
524
525
526The \verb+SET+ directive is useful for providing indirection by
527associating the name of a basis set or geometry with the standard
528object names (such as \verb+"ao basis"+ or \verb+geometry+) used by
529NWChem.  The following input file shows an example using the
530\verb+SET+ directive to direct different tasks to different
531geometries.  The required input lines are as follows:
532
533\begin{verbatim}
534  title "Ar dimer BSSE corrected MP2 interaction energy"
535  geometry "Ar+Ar"
536    Ar1 0 0 0
537    Ar2 0 0 2
538  end
539
540  geometry "Ar+ghost"
541    Ar1 0 0 0
542    Bq2 0 0 2
543  end
544
545  basis
546    Ar1 library aug-cc-pvdz
547    Ar2 library aug-cc-pvdz
548    Bq2 library Ar aug-cc-pvdz
549  end
550
551  set geometry "Ar+Ar"
552  task mp2
553
554  scf; vectors atomic; end
555
556  set geometry "Ar+ghost"
557  task mp2
558\end{verbatim}
559
560This input tells the code to perform MP2 energy calculations
561on an argon dimer in the first task, and then
562on the argon atom in the presence of the ``ghost'' basis of the other
563atom.
564
565The \verb+SET+ directive can also be used as an indirect means of
566supplying input to a part of the code that does not have a separate
567input module (e.g., the atomic SCF, Section \ref{sec:atomscf}).
568Additional examples of applications of this directive can be found in
569the sample input files (see Section \ref{sec:realsample}), and
570its usage with basis sets (Section \ref{sec:basis}) and geometries
571(Section \ref{sec:geom}). Also see Section \ref{sec:database} for
572an example of how to store an array in the database.
573
574\section{{\tt UNSET} --- Delete data in the RTDB}
575\label{sec:unset}
576
577This directive gives the user a way to delete simple entries from the
578database.  The general form of the directive is as follows:
579
580\begin{verbatim}
581  UNSET <string name>[*]
582\end{verbatim}
583
584This directive cannot be used with complex objects such as geometries
585and basis sets\footnote{Complex objects are stored using a structured
586  naming convention that is not matched by a simple wild card.}.  A
587wild-card (*) specified at the end of the string \verb+<name>+ will
588cause {\em all} entries whose name begins with that string to be
589deleted.  This is very useful as a way to reset modules to their
590default behavior, since modules typically store information in the
591database with names that begin with \verb+module:+.  For example, the
592SCF program can be restored to its default behavior by deleting all
593database entries beginning with \verb+scf:+, using the directive
594
595\begin{verbatim}
596  unset scf:*
597\end{verbatim}
598
599Section \ref{sec:fragguess} has an example  using
600\verb+ unset+ on a water dimer calculation.
601
602The following example makes an entry in the database using the
603\verb+SET+ directive, and then immediately deletes it using the
604\verb+UNSET+ directive:
605
606\begin{verbatim}
607  set mylist 1 2 3 4
608  unset mylist
609\end{verbatim}
610
611
612\section{{\tt STOP} --- Terminate processing}
613
614This top-level directive provides a convenient way of verifying
615an input file without actually running the calculation.  It consists
616of the single line,
617
618\begin{verbatim}
619  STOP
620\end{verbatim}
621
622As soon as this directive is encountered, all processing ceases and
623the calculation terminates with an error condition.
624
625\section{{\tt TASK} --- Perform a task}
626\label{sec:task}
627
628The \verb+TASK+ directive is used to tell the code what to do.  The
629input directives are parsed sequentially until a \verb+TASK+ directive
630is encountered, as described in Section \ref{sec:inputstructure}.  At
631that point, the calculation or operation specified in the \verb+TASK+
632directive is performed.  When that task is completed, the code looks
633for additional input to process until the next \verb+TASK+ directive
634is encountered, which is then executed.  This process continues to the
635end of the input file.  NWChem expects the last directive before the
636end-of-file to be a \verb+TASK+ directive.  If it is not, a warning
637message is printed.  Since the database is persistent, multiple tasks
638within one job behave {\em exactly} the same as multiple restart jobs
639with the same sequence of input.
640
641There are four main forms of the the \verb+TASK+ directive.  The most
642common form is used to tell the code at what level of theory to
643perform an electronic structure calculation, and which specific
644calculations to perform.  The second form is used to specify tasks
645that do not involve electronic structure calculations or tasks that
646have not been fully implemented at all theory levels in NWChem, such
647as simple property evaluations.  The third form is used to execute
648UNIX commands on machines having a Bourne shell.  The fourth form is
649specific to combined quantum-mechanics and molecular-mechanics (QM/MM)
650calculations.
651
652By default, the program terminates when a task does not complete
653successfully.  The keyword \verb+ignore+ can be used to prevent this
654termination, and is recognized by all forms of the \verb+TASK+
655directive.  When a \verb+TASK+ directive includes the keyword
656\verb+ignore+, a warning message is printed if the task fails, and
657code execution continues with the next task. An example of this feature
658is given in the sample input file
659in Section \ref{sec:DFTsample}.
660
661The input options, keywords, and defaults for each of these four forms
662for the \verb+TASK+ directive are discussed in the following sections.
663
664\subsection{{\tt TASK} Directive for Electronic Structure Calculations}
665\label{sec:first_task}
666
667This is the most commonly used version of the \verb+TASK+ directive, and
668it has the following form:
669
670\begin{verbatim}
671  TASK <string theory> [<string operation default energy>] [ignore]
672\end{verbatim}
673
674The string \verb+<theory>+ specifies the level of theory to be used in the
675calculations for this task.  NWChem currently supports ten different
676options.  These are listed below, with the corresponding entry for
677the variable {\tt <theory>}:
678\begin{itemize}
679 \item \verb+scf+ --- Hartree-Fock
680 \item \verb+dft+ --- Density functional theory for molecules
681 \item \verb+sodft+ --- Spin-Orbit Density functional theory
682% \item \verb+gapss+ --- Density functional theory for periodic systems
683 \item \verb+mp2+ --- MP2 using a semi-direct algorithm
684 \item \verb+direct_mp2+ --- MP2 using a full-direct algorithm
685 \item \verb+rimp2+ --- MP2 using the RI approximation
686 \item \verb+ccsd+ --- Coupled-cluster single and double excitations
687 \item \verb+ccsd(t)+ --- Coupled-cluster linearized triples approximation
688 \item \verb#ccsd+t(ccsd)# --- Fourth order triples contribution
689 \item \verb+mcscf+ --- Multiconfiguration SCF
690 \item \verb+selci+ --- Selected configuration interaction with perturbation
691   correction
692 \item \verb+md+ --- Classical molecular dynamics simulation
693 \item \verb+pspw+ --- Pseudopotential plane-wave density functional theory for molecules and insulating solids using NWPW
694 \item \verb+band+ --- Pseudopotential plane-wave
695density functional theory for solids using NWPW
696 \item \verb+tce+ --- Tensor Contraction Engine (please see
697Section \ref{sec:inputsyntax} for a complete description of this task directive
698
699\end{itemize}
700
701The string \verb+<operation>+ specifies the calculation that will
702be performed in the task.  The default operation is a single point energy
703evaluation.  The following list gives the selection of operations currently
704available in NWChem:
705\begin{itemize}
706\item \verb+energy+ --- Evaluate the single point energy.
707\item \verb+gradient+ --- Evaluate the derivative of the energy with respect to\
708   nuclear coordinates.
709\item \verb+optimize+ --- Minimize the energy by varying the molecular
710   structure.  By default, this geometry optimization is presently driven by the Driver
711   module (see Section \ref{sec:driver}), but the Stepper module
712   (see Section \ref{sec:stepper}) may also be used.
713\item \verb+saddle+ --- Conduct a search for a transition state (or saddle point)
714  using either Driver (Section \ref{sec:driver}, the default) or
715  Stepper (Section \ref{sec:stepper}).
716\item \verb+hessian+ --- Compute second derivatives.  See Section \ref{sec:hess}
717  for analytic hessians.
718\item \verb+frequencies+ or \verb+freq+ --- Compute second derivatives
719  and print out an analysis of molecular vibrations.  See Section \ref{sec:vib}
720  for controls for vibration calculations.
721\item \verb+property+ --- Calculate the properties for the wave function.
722\item \verb+dynamics+ --- Perform classical molecular dynamics.
723\item \verb+thermodynamics+ --- Perform multi-con\-fig\-ura\-tion
724  thermo\-dynamic integ\-ration using classical MD
725\end{itemize}
726
727NOTE: See Section \ref{sec:pspw_tasks}  for the complete list of operations
728that accompany the NWPW module.
729
730The user should be aware that some of these operations (gradient,
731optimize, dynamics, thermodynamics) require computation of
732derivatives of the energy with respect to the molecular coordinates.
733If analytical derivatives are not available (Section
734\ref{sec:functionality}), they must be computed numerically, which can
735be very computationally intensive.
736
737Here are some examples of the \verb+TASK+ directive, to illustrate the
738input needed to specify particular calculations with the code.  To
739perform a single point energy evaluation using any level of theory, the
740directive is very simple, since the energy evaluation is the default
741for the string \verb+operation+.  For an SCF energy calculation, the
742input line is simply
743\begin{verbatim}
744  task scf
745\end{verbatim}
746Equivalently, the operation can be specified explicitly, using the
747directive
748\begin{verbatim}
749  task scf energy
750\end{verbatim}
751
752Similarly, to perform a geometry optimization using density functional
753theory, the \verb+TASK+ directive is
754\begin{verbatim}
755  task dft optimize
756\end{verbatim}
757
758The optional keyword \verb+ignore+ can be used to allow execution to
759continue even if the task fails, as discussed above.
760An example with the keyword \verb+ignore+
761can be found in Section \ref{sec:DFTsample}.
762
763\subsection{{\tt TASK} Directive for Special Operations}
764
765This form of the \verb+TASK+ directive is used in instances where the
766task to be performed does not fit the model of the previous version
767(such as execution of a Python program, Section \ref{sec:python}), or
768if the operation has not yet been implemented in a fashion that
769applies to a wide range of theories (e.g., property evaluation).
770Instead of requiring \verb+theory+ and \verb+operation+ as input, the
771directive needs only a string identifying the task.  The form of the
772directive in such cases is as follows:
773
774\begin{verbatim}
775  TASK <string task> [ignore]
776\end{verbatim}
777
778The supported tasks that can be accessed with this form of the \verb+TASK+
779directive are listed
780below, with the corresponding entries for string variable \verb+<task>+.
781
782\begin{itemize}
783  \item \verb+python+ --- Execute a Python program (Section \ref{sec:python}).
784  \item \verb+rtdbprint+ --- Print the contents of the database.
785  \item \verb+cphf+ --- Invoke the CPHF module.
786  \item \verb+property+ --- Perform miscellaneous property calculations.
787  \item \verb+dplot+ --- Execute a DPLOT run (Section \ref{sec:dplot})
788\end{itemize}
789
790This directive also recognizes the keyword \verb+ignore+, which allows
791execution to continue after a task has failed.
792
793\subsection{{\tt TASK} Directive for the Bourne Shell}
794
795This form of the \verb+TASK+ directive is supported only on machines
796with a fully UNIX-style operating system.  This directive causes
797specified processes to be executed using the Bourne shell.  This form
798of the task directive is:
799
800\begin{verbatim}
801  TASK shell [(<integer-range process = 0>||all)] \
802             <string command>
803\end{verbatim}
804
805The keyword \verb+shell+ is required for this directive.  It specifies
806that the given command will be executed in the Bourne shell.  The user
807can also specify which process(es) will execute this command by
808entering values for \verb+process+ on the directive.  The default is
809for only process zero to execute the command.  A range of processes
810may be specified, using Fortran triplet notation\footnote{The notation
811{\tt lo:hi:inc} denotes the integers {\tt lo}, {\tt lo+inc},
812{\tt lo+2*inc}, \ldots, {\tt hi}}.  Alternatively, all
813processes can be specified simply by entering the keyword \verb+all+.
814The input entered for \verb+command+ must form a single string, and
815must consist of valid UNIX command(s).  If the string includes white space,
816it must be enclosed in double quotes.
817
818For example, the \verb+TASK+ directive to tell process zero to copy the
819molecular orbitals file to a backup location \verb+/piofs/save+ can be input as follows:
820
821\begin{verbatim}
822  task shell "cp *.movecs /piofs/save"
823\end{verbatim}
824
825The \verb+TASK+ directive to tell all processes to list the contents of
826their \verb+/scratch+ directories is as follows:
827
828\begin{verbatim}
829  task shell all "ls -l /scratch"
830\end{verbatim}
831
832The \verb+TASK+ directive to tell processes 0 to 10 to remove the
833contents of the current directory is as follows:
834
835\begin{verbatim}
836  task shell 0:10:1 "/bin/rm -f *"
837\end{verbatim}
838
839Note that NWChem's ability to quote special input characters is {\em
840  very} limited when compared with that of the Bourne shell.  To
841execute all but the simplest UNIX commands, it is usually much easier
842to put the shell script in a file and execute the file from within
843NWChem.
844
845\subsection{{\tt TASK} Directive for QM/MM simulations}
846
847This is very similar to the most commonly used version of the
848\verb+TASK+ directive described in Section \ref{sec:first_task}, and
849it has the following form;
850
851\begin{verbatim}
852  TASK QMMM <string theory> [<string operation default energy>] [ignore]
853\end{verbatim}
854
855The string \verb+<theory>+ specifies the QM theory to be used in the
856QM/MM simulation\footnote{If theory is ``{\tt md}'' this is not a QM/MM
857simulation and will result in an appropriate error}.  The level of
858theory may be any QM method that can compute gradients but those
859algorithms in NWChem that do not support analytic gradients should be
860avoided (c.f., Section \ref{sec:functionality}).
861
862The string \verb+<operation>+ is used to specify the calculation that will
863be performed in the QM/MM task.  The default operation is a single point energy
864evaluation.  The following list gives the selection of operations currently
865available in the NWChem QM/MM module;
866\begin{itemize}
867\item \verb+energy+ --- single point energy evaluation
868\item \verb+optimize+ --- minimize the energy by variation of the molecular
869   structure.
870\item \verb+dynamics+ --- molecular dynamics using nwARGOS
871\end{itemize}
872
873Here are some examples of the \verb+TASK+ directive for QM/MM
874simulations.  To perform a single point energy of a QM/MM system using
875any QM level of theory, the directive is very simple. As with the
876general task directive, the QM/MM energy evaluation is the
877default. For a DFT energy calculation the task directive input is,
878\begin{verbatim}
879  task qmmm dft
880\end{verbatim}
881or completely as
882\begin{verbatim}
883  task qmmm dft energy
884\end{verbatim}
885
886To do a molecular dynamics simulation of a QM/MM system using the SCF
887level of theory the task directive input would be
888\begin{verbatim}
889  task qmmm scf dynamics
890\end{verbatim}
891
892The optional keyword \verb+ignore+ can be used to allow execution to
893continue even if the task fails, as discussed above.
894
895\subsection{{\tt TASK} Directive for BSSE calculations}
896\label{sec:bsse_task}
897
898NWChem computes the basis set superposition error (BSSE) when two or more
899fragments are interacting by using the counterpoise method.
900This directive is performed if the \verb+BSSE+ section is present.
901Single point energies, energy gradients, geometry
902optimizations, Hessians and frequencies, at the level of theory that allows these tasks, can be obtained with the BSSE correction.
903The input options for the BSSE section are:
904
905\begin{verbatim}
906BSSE
907  MON <string monomer name> <integer natoms> \
908   [INPUT  [<string input>]] \
909   [INPUT_WGHOST[<string input>]] \
910   [CHARGE [< real charge>]] \
911  [OFF] \
912  [ON] \
913END
914\end{verbatim}
915
916\verb+MON+ defines the monomer's name and its atoms;
917 <string monomer name> defines the
918name of the monomer, <integer atoms> is the list of atoms corresponding to the
919monomer (where such a list is relative to the initial geometry).
920This information is needed for each monomer.
921With the tag \verb+INPUT+ the user can modify any calculation attributes for
922each monomer without ghost.
923For example, the iterations number and the grid can be
924changed in a DFT calculation (see the example of the interaction between $Zn^{2+}$ and
925water).  \verb+INPUT_WGHOST+ is the same than \verb+INPUT+ but for the monomer with ghost.
926The input changes will be applied within this and for the following calculations,
927you should be cautious reverting the changes for the next monomers.
928\verb+CHARGE+
929assigns a charge to a monomer and it must be consistent with the total charge
930in the whole system (see Section \ref{sec:charge}). The options \verb+OFF+ and  \verb+ON+
931turns off and on any BSSE calculation.
932
933The energy evaluation involves 1 + 2N calculations, i.e. one for the supermolecule and
934two for the N monomers. [S. Simon, M. Duran, J. J. Dannenberg, J. Chem. Phys., 105, 11024 (1996)]
935NWChem stores the vector files for each calculation (\verb+<string monomer name>.bsse.movecs+),
936and one hessian file (\verb+<string monomer name>.bsse.hess+).
937The code does not assign automatically the basis set for the ghost atoms,
938you must assign the corresponding bqX for each element, instead.
939
940\subsection*{Examples}
941
942The dimer $(FH)_2$
943
944\begin{verbatim}
945title dimer
946start dimer
947geometry units angstrom
948symmetry c1
949  F        1.47189        2.47463       -0.00000
950  H        1.47206        3.29987        0.00000
951  F        1.46367       -0.45168        0.00000
952  H        1.45804        0.37497       -0.00000
953end
954
955basis "ao basis"
956 F library 6-31G
957 H library 6-31G
958 bqF library F 6-31G
959 bqH library H 6-31G
960end
961dft; xc slater 1.0 vwn_5 1.0; direct; end
962bsse
963  mon first 1 2
964  mon second 3 4
965end
966
967task dft energy
968
969\end{verbatim}
970
971Changing {\tt maxiter} for a  specific monomer: $Zn^{2+}(H_2O)$
972
973\begin{verbatim}
974title znwater
975start znwater
976
977echo
978geometry noautoz units angstrom
979symmetry c1
980  Zn      -1.89334       -0.72741       -0.00000
981  O       -0.20798        0.25012        0.00000
982  H       -0.14200        1.24982       -0.00000
983  H        0.69236       -0.18874       -0.00000
984end
985
986basis "ao basis"
987 O library 6-31G
988 Zn library 6-31G
989 H library 6-31G
990 bqO library O 6-31G
991 bqZn library Zn 6-31G
992 bqH library H 6-31G
993end
994charge 2
995scf; direct; end
996mp2; end
997
998bsse
999  mon metal 1
1000    charge 2
1001    input_wghost "scf\;  maxiter 200\; end"
1002  mon water 2 3 4
1003end
1004
1005task mp2 optimize
1006\end{verbatim}
1007
1008\section{{\tt CHARGE} --- Total system charge}
1009\label{sec:charge}
1010
1011This is an optional top-level directive that allows the user to specify
1012the total charge of the system.  The form of the directive is as follows:
1013\begin{verbatim}
1014  CHARGE <real charge default 0>
1015\end{verbatim}
1016
1017The default charge\footnote{The charge directive, in conjunction with
1018  the charges of atomic nuclei (which can be changed via the geometry
1019  input, cf. Section \ref{sec:cart}), determines the total number of
1020  electrons in the chemical system.  Therefore, a {\tt charge n}
1021  specification removes "n" electrons from the chemical system.
1022  Similarly, {\tt charge -n} adds "n" electrons.} is zero
1023if this directive is omitted.  An example of a case where the
1024directive would be needed is for a calculation on a doubly charged
1025cation.  In such a case, the directive is simply,
1026\begin{verbatim}
1027  charge 2
1028\end{verbatim}
1029
1030If centers with fractional charge have been specified (Section
1031\ref{sec:geom}) the net charge of the system should be adjusted to
1032ensure that there are an integral number of electrons.
1033
1034The charge may be changed between tasks, and is used by all
1035wavefunction types.  For instance, in order to compute the first two
1036vertical ionization energies of $LiH$, one might optimize the geometry
1037of $LiH$ using a UHF SCF wavefunction, and then perform energy
1038calculations at the optimized geometry on $LiH^+$ and
1039$LiH^{2+}$ in turn.  This is accomplished with the following input:
1040\begin{verbatim}
1041  geometry; Li 0 0 0; H  0 0 1.64; end
1042  basis; Li library 3-21g; H library 3-21g; end
1043
1044  scf; uhf; singlet; end
1045  task scf optimize
1046
1047  charge 1
1048  scf; uhf; doublet; end
1049  task scf
1050
1051  charge 2
1052  scf; uhf; singlet; end
1053  task scf
1054\end{verbatim}
1055The \verb+GEOMETRY+, \verb+BASIS+, and \verb+SCF+ directives are
1056described below (Sections \ref{sec:geom}, \ref{sec:basis} and
1057\ref{sec:scf} respectively) but their intent should be clear.  The
1058\verb+TASK+ directive is described above (Section \ref{sec:task}).
1059
1060\section{{\tt ECCE\_PRINT} --- Print information for Ecce}
1061\label{sec:ecce}
1062
1063The \verb+ECCE_PRINT+ directive allows the user to print out a file,
1064usually called ecce.out, that will allow the calculation and its
1065results to be imported into \htmladdnormallink{Ecce}
1066{http://ecce.pnl.gov}.
1067
1068\begin{verbatim}
1069  ECCE_PRINT <string name>
1070\end{verbatim}
1071
1072The entry for variable \verb+<name>+ is the name of the file
1073that will contain the Ecce import information and should include
1074the full path to the directory where you want that file.  For example
1075
1076\begin{verbatim}
1077  ecce_print /home/user/job/ecce.out
1078\end{verbatim}
1079
1080If the full path is not given and only the file name is given, the file
1081will be located in whatever directory the job is started in.  For example,
1082if the line
1083
1084\begin{verbatim}
1085  ecce_print ecce.out
1086\end{verbatim}
1087
1088is in the input file, the file could end up in the scratch directory if
1089the user is using a batch script that copies the input file to a local
1090scratch directory and then launches NWChem from there.  If the system
1091then automatically removes files in the scratch space at the end of the
1092job, the ecce.out file will be lost.  So, the best
1093practice is to include the full path name for the file.
1094
1095
1096
1097