File: readfile.c

package info (click to toggle)
openmx 3.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 325,856 kB
  • ctags: 3,575
  • sloc: ansic: 152,655; f90: 2,080; python: 876; makefile: 675; sh: 25; perl: 18
file content (94 lines) | stat: -rw-r--r-- 2,157 bytes parent folder | download
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
/**********************************************************************
  readfile.c:

     readfile.c is a subrutine to read a input file or restart file.

  Log of readfile.c:

     22/Nov/2001  Released by T.Ozaki

***********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "openmx_common.h"
#include "mpi.h"
#include "tran_prototypes.h"


double readfile(char *argv[])
{ 
  double time0;
  double TStime,TEtime;
  FILE *fp;
  int numprocs,myid; 
  char fileMemory[YOUSO10]; 
  char buf[fp_bsize];          /* setvbuf */

  dtime(&TStime);

  MPI_Comm_size(MPI_COMM_WORLD1,&numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD1,&myid);

  /****************************************************
           Read a input file or restart file.
  ****************************************************/

  if ((fp = fopen(argv[1],"r")) != NULL){

#ifdef xt3
    setvbuf(fp,buf,_IOFBF,fp_bsize);  /* setvbuf */
#endif

    Input_std(argv[1]);
    fclose(fp);
  }
  else{
    printf("Failure of reading the input file.\n");
    exit(0);
  }

  Allocate_Arrays(2);
  Set_Allocate_Atom2CPU(0,1,0); /* for species */
  SetPara_DFT();

  if ( TRAN_Check_Region_Lead(atomnum, WhatSpecies, Spe_Atom_Cut1, Gxyz, tv)==0 ) {
    printf("\n\nERROR: PAOs of lead atoms can overlap only to the next nearest region.\n\n");
    MPI_Finalize();
    exit(1);
  }

  if ( Solver==4 ) {
    if ( TRAN_Check_Region(atomnum, WhatSpecies, Spe_Atom_Cut1, Gxyz)==0 ) {
      printf("\n\nERROR: PAOs of atoms of L|C|R can overlap only to the next nearest region.\n\n");
      MPI_Finalize();
      exit(1);
    }
  }

  /*****************************
    last input
    0: atomnum, 
    1: elapsed time 
  *****************************/    

  Set_Allocate_Atom2CPU(1,0,0); 

  /***************************************************************
   NEGF:
   check the consistency between the current and previous inputs 
  ***************************************************************/

  TRAN_Check_Input(MPI_COMM_WORLD1, Solver);

  dtime(&TEtime);
  time0 = TEtime - TStime;

  return time0;
}