File: readfile.c

package info (click to toggle)
openmx 3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 134,876 kB
  • sloc: ansic: 152,771; python: 876; makefile: 576; xml: 63; perl: 18; sh: 4
file content (112 lines) | stat: -rw-r--r-- 2,420 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**********************************************************************
  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"

#ifdef nompi
#include "mimic_mpi.h"
#else
#include "mpi.h"
#endif

#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_level1,&numprocs);
  MPI_Comm_rank(mpi_comm_level1,&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);
  }


  if (myid<atomnum) {

    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);
      }
    }

    Set_Allocate_Atom2CPU(0,0,0); /* a simple division for atoms (get Matomnum) */

    if (Solver!=6) { /*  except for GDC */

    /*****************************
      final input
      0: atomnum, 
      1: the neighbor 
      2: elapsed time 
    *****************************/    

      Set_Allocate_Atom2CPU(1,0,0); 
    }
  } 

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

  TRAN_Check_Input(mpi_comm_level1, Solver);

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