PSCF v1.4.0
pscf_rpc.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include <rpc/system/System.h>
9#include <prdc/crystal/getDimension.h>
10#include <pscf/chem/PolymerModel.h>
11#include <util/format/Int.h>
12#include <util/misc/Log.h>
13#include <util/misc/Memory.h>
14
15#include <iostream>
16
17namespace Pscf {
18namespace Rpc {
19
28 template <int D>
29 void run(int argc, char **argv) {
30 System<D> system;
31
32 // Process command line options
33 system.setOptions(argc, argv);
34
35 // Read parameters from default parameter file
36 system.readParam();
37
38 // Prohibit later changes to global polymer model
40
41 // Read command script and execute commands
42 system.readCommands();
43 }
44
45}
46}
47
55int main(int argc, char **argv)
56{
57
58 using namespace Util;
59 using namespace Pscf;
60
61 // Extract the dimension of space from argument of -d option
62 int D = Pscf::Prdc::getDimension(argc, argv);
63 std::cout << "dimension " << D << std::endl;
64
65 // Run relevant template specialization
66 if (1 == D) {
67 Rpc::run<1>(argc, argv);
68 } else
69 if (2 == D) {
70 Rpc::run<2>(argc, argv);
71 } else
72 if (3 == D) {
73 Rpc::run<3>(argc, argv);
74 } else {
75 std::cout << " Invalid dimension = " << D << std::endl;
76 }
77
78 // Report memory usage
79 Log::file() << "\nCPU heap array memory usage:";
80 Log::file() << "\n Maximum array memory = "
81 << Int(Memory::max(), 12) << " bytes";
82 Log::file() << "\n Final array memory = "
83 << Int(Memory::total(), 12) << " bytes";
84 Log::file() << std::endl;
85
86 fftw_cleanup();
87}
void readCommands(std::istream &in)
Read and process commands from an input stream.
virtual void readParam(std::istream &in)
Read input parameters (with opening and closing lines).
void setOptions(int argc, char **argv)
Process command line options.
A complete physical system.
Wrapper for an int, for formatted ostream output.
Definition Int.h:37
static std::ostream & file()
Get log ostream by reference.
Definition Log.cpp:59
static long int max()
Return the maximum amount of allocated heap memory thus far.
Definition Memory.cpp:52
static long int total()
Return total amount of memory currently allocated.
Definition Memory.cpp:46
void run(int argc, char **argv)
Function template for main pscf_rpc program.
Definition pscf_rpc.cpp:29
int main(int argc, char **argv)
Main pscf_rpc program.
Definition pscf_rpc.cpp:55
void lock()
Make the polymer model immutable.
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Utility classes for scientific computation.