cp2k-c/src/cp2k_input.cpp

89 lines
No EOL
2.9 KiB
C++

/*---------------------------------------------------------------------------*/
/* CP2K: A general program to perform molecular dynamics simulations */
/* Copyright (C) 2024 CP2K developers group */
/*---------------------------------------------------------------------------*/
#include <string>
#include <iomanip>
#include <iostream>
#include "global_types.h"
using namespace CP2K_NS;
void read_cp2k_section(global_environment_type *globenv) {
// Locals
int ierror, ilen, iw, source, allgrp;
std::string string;
std::string label;
// defaults
globenv->program_name = "None";
globenv->project_name = "project";
globenv->print_level = 0;
iw = globenv->scr;
// parse the input section
label = "&CP2K";
ierror = 0;
parser_init(globenv->input_file_name, label, &ierror, globenv);
if (ierror != 0 ) {
if (globenv->ionode) std::cout << " No input section &CP2K found " << std::endl;
} else {
read_line()
while (test_next() != "X") {
ilen = 6;
cfield(string, ilen);
string.upper()
switch (string) {
case "PROGRA":
ilen = 0
cfield(globenv->program_name, ilen);
globenv->program_name.upper();
break;
case "PROJEC":
ilen = 0
cfield(globenv->project_name, ilen);
break;
case "IOLEVE":
globenv->print_level = get_int();
break;
default:
p_error();
stop_prg("input_cntl", "unknown option");
}
read_line();
}
}
parser_end();
// end of parsing the input section
if (globenv->program_name == "QUICKSTEP") globenv->program_name = "QS";
if (globenv->ionode) {
// write some information to output
std::cout << std::left << std::setw(40) << " CP2K| Program name ";
std::cout << std::right << std::setw(40) << globenv->program_name << std::endl;
std::cout << std::left << std::setw(40) << " CP2K| Input file name ";
std::cout << std::right << std::setw(40) << globenv->input_file_name << std::endl;
std::cout << std::left << std::setw(40) << " CP2K| Project name ";
std::cout << std::right << std::setw(40) << globenv->project_name << std::endl;
std::cout << std::left << std::setw(76) << " CP2K| Global print level ";
std::cout << globenv->print_level << std::endl;
std::cout << std::left << std::setw(74) << " CP2K| Total number of processors ";
std::cout << globenv->num_pe << std::endl;
std::cout << std::left << std::setw(74) << " CP2K| This output from processor ";
std::cout << globenv->mepos << "\n" << std::endl;
}
}