1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
/**********************************************************************
Runtest.c:
Runtest.c is a subroutine to check whether OpenMX runs normally
on many platforms or not by comparing the stored *.out and generated
*.out on your machine.
Log of Runtest.c:
25/Oct/2004 Released by T.Ozaki
***********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
/* stat section */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
/* end stat section */
#include "openmx_common.h"
#include "Inputtools.h"
#ifdef nompi
#include "mimic_mpi.h"
#else
#include "mpi.h"
#endif
static void SpeciesString2int(int p);
typedef struct {
char fn[YOUSO10];
} fname_type;
void Show_DFT_DATA(char *argv[])
{
FILE *fp,*fp0,*fp1,*fp2,*fp3;
int Num_DatFiles,i,j,k,fp_OK;
int Num_Atoms;
int NGrid1_1,NGrid1_2,NGrid1_3;
int NGrid2_1,NGrid2_2,NGrid2_3;
double Utot1,Utot2,dU,dF;
double gx,gy,gz,fx,fy,fz;
double sum1,sum2;
double time1,TotalTime;
char SN[30][YOUSO10];
char SB[30][YOUSO10];
char SV[30][YOUSO10];
char fname[YOUSO10];
char fname0[YOUSO10];
char fname1[YOUSO10];
char fname2[YOUSO10];
char fname_dat[YOUSO10];
char fname_dat2[YOUSO10];
char fname_out1[YOUSO10];
char fname_out2[YOUSO10];
char ftmp[YOUSO10];
fname_type *fndat;
int numprocs,myid;
char *dir;
char input_dir[300];
char *output_file;
DIR *dp;
struct dirent *entry;
MPI_Request request;
MPI_Status status;
/* set up MPI */
MPI_Comm_size(mpi_comm_level1,&numprocs);
MPI_Comm_rank(mpi_comm_level1,&myid);
sprintf(input_dir,"%s",argv[2]);
printf("%s\n",input_dir);
/* print the header */
if (myid==Host_ID){
/* set dir */
dir = input_dir;
/* count the number of dat files */
if(( dp = opendir(dir) ) == NULL ){
printf("could not find the directry '%s'\n",input_dir);
MPI_Finalize();
exit(0);
}
Num_DatFiles = 0;
while((entry = readdir(dp)) != NULL){
if ( strstr(entry->d_name,".dat")!=NULL ){
Num_DatFiles++;
}
}
closedir(dp);
fndat = (fname_type*)malloc(sizeof(fname_type)*Num_DatFiles);
/* store the name of dat files */
if(( dp = opendir(dir) ) == NULL ){
printf("could not find the directry '%s'\n",input_dir);
MPI_Finalize();
exit(0);
}
Num_DatFiles = 0;
while((entry = readdir(dp)) != NULL){
if ( strstr(entry->d_name,".dat")!=NULL ){
sprintf(fndat[Num_DatFiles].fn,"%s/%s",input_dir,entry->d_name);
Num_DatFiles++;
}
}
closedir(dp);
} /* if (myid==Host_ID) */
if (myid==Host_ID){
printf(" %2d dat files are found in the directory '%s'.\n\n\n",Num_DatFiles,input_dir);
}
/***********************************************************
start calculations
***********************************************************/
for (i=0; i<Num_DatFiles; i++){
sprintf(fname_dat,"%s",fndat[i].fn);
input_open(fname_dat);
input_int("Species.Number",&SpeciesNum,0);
/* read Definition.of.Atomic.Species */
if (fp=input_find("<Definition.of.Atomic.Species")) {
for (k=0; k<SpeciesNum; k++){
fscanf(fp,"%s %s %s",SN[k],SB[k],SV[k]);
printf("i=%2d k=%2d %s %s\n",i,k,SB[k],SV[k]);
/*
SpeciesString2int(i);
*/
}
if (! input_last("Definition.of.Atomic.Species>")) {
MPI_Finalize();
exit(0);
}
}
input_close();
}
if (myid==Host_ID){
free(fndat);
}
MPI_Barrier(mpi_comm_level1);
MPI_Finalize();
exit(0);
}
void SpeciesString2int(int p)
{
int i,l,n,po;
char c,cstr[YOUSO10*3];
/* Get basis name */
sprintf(SpeBasisName[p],"");
i = 0;
po = 0;
while( ((c=SpeBasis[p][i])!='\0' || po==0) && i<YOUSO10 ){
if (c=='-'){
po = 1;
SpeBasisName[p][i] = '\0';
}
if (po==0) SpeBasisName[p][i] = SpeBasis[p][i];
i++;
}
if (2<=level_stdout){
printf("<Input_std> SpeBasisName=%s\n",SpeBasisName[p]);
}
/* Get basis type */
for (l=0; l<5; l++){
Spe_Num_Basis[p][l] = 0;
}
i = 0;
po = 0;
while((c=SpeBasis[p][i])!='\0'){
if (po==1){
if (c=='s'){ l=0; n=0; }
else if (c=='p'){ l=1; n=0; }
else if (c=='d'){ l=2; n=0; }
else if (c=='f'){ l=3; n=0; }
else if (c=='g'){ l=4; n=0; }
else{
if (n==0){
cstr[0] = c;
cstr[1] = '\0';
Spe_Num_Basis[p][l] = atoi(cstr);
Spe_Num_CBasis[p][l] = atoi(cstr);
n++;
}
else if (n==1){
cstr[0] = c;
cstr[1] = '\0';
Spe_Num_CBasis[p][l] = atoi(cstr);
if (Spe_Num_Basis[p][l]<Spe_Num_CBasis[p][l]){
printf("# of contracted orbitals are larger than # of primitive oribitals\n");
MPI_Finalize();
exit(1);
}
n++;
}
else {
printf("Format error in Definition of Atomic Species\n");
MPI_Finalize();
exit(1);
}
}
}
if (SpeBasis[p][i]=='-') po = 1;
i++;
}
for (l=0; l<5; l++){
if (Spe_Num_Basis[p][l]!=0) Spe_MaxL_Basis[p] = l;
if (2<=level_stdout){
printf("<Input_std> p=%2d l=%2d %2d %2d\n",
p,l,Spe_Num_Basis[p][l],Spe_Num_CBasis[p][l]);
}
}
}
|