File: Maketest.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 (135 lines) | stat: -rw-r--r-- 3,642 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**********************************************************************
  Maketest.c:

     Maketest.c is a subroutine to generate *.out files which will be
     used to check whether OpenMX runs normally on many platforms or not.

  Log of Maketest.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>
/*  end stat section */
#include "openmx_common.h"
#include "Inputtools.h"
#include "mpi.h"
 


void Maketest(char *mode, int argc, char *argv[]) 
{
  FILE *fp0,*fp1,*fp2;
  static int Num_DatFiles,i;

  static char fname0[YOUSO10];
  static char fname1[YOUSO10];
  static char fname_dat[YOUSO10];
  static char fname_dat2[YOUSO10];
  static char operate[800];
  char namemode[YOUSO10];
  char *dir;

  printf("\n*******************************************************\n"); 
  printf("*******************************************************\n"); 
  printf(" Welcome to OpenMX  Ver. %s                            \n",Version_OpenMX); 
  printf(" Copyright (C), 2002-2009, T.Ozaki                     \n"); 
  printf(" OpenMX comes with ABSOLUTELY NO WARRANTY.             \n"); 
  printf(" This is free software, and you are welcome to         \n"); 
  printf(" redistribute it under the constitution of the GNU-GPL.\n");
  printf("*******************************************************\n"); 
  printf("*******************************************************\n\n\n"); 

  if (strcasecmp(mode,"S")==0){  
    dir = "input_example";
    sprintf(namemode,"runtest");
  }
  else if (strcasecmp(mode,"L")==0){  
    dir = "large_example";
    sprintf(namemode,"runtestL");
  }
  else if (strcasecmp(mode,"L2")==0){  
    dir = "large2_example";
    sprintf(namemode,"runtestL2");
  }
  else if (strcasecmp(mode,"G")==0){  
    dir = "geoopt_example";
    sprintf(namemode,"runtestG");
  }
  else if (strcasecmp(mode,"WF")==0){  
    dir = "wf_example";
    sprintf(namemode,"runtestWF");
  }
  else if (strcasecmp(mode,"NEGF")==0){  
    dir = "negf_example";
    sprintf(namemode,"runtestNEGF");
  }

  /* print std */

  printf("\n");
  printf(" OpenMX is now in the mode in making of *.out files\n");
  printf(" which will be used in the test mode '%s'.\n",namemode);
  printf("\n");

  sprintf(operate,"ls %s/*.dat > ls_dat000000",dir);
  system(operate);

  sprintf(operate,"wc ls_dat000000 > ls_dat000001");
  system(operate);

  sprintf(fname0,"ls_dat000000");
  sprintf(fname1,"ls_dat000001");

  if ( ((fp0 = fopen(fname0,"r")) != NULL) &&
       ((fp1 = fopen(fname1,"r")) != NULL) )
    {

    fscanf(fp1,"%i",&Num_DatFiles);

    printf(" %2d dat files are found in the directory '%s'.\n\n\n",Num_DatFiles,dir);

    for (i=0; i<Num_DatFiles; i++){

      fscanf(fp0,"%s",fname_dat);

      if      (argc==2)  sprintf(operate,"./openmx %s",fname_dat);
      else if (argc==3)  sprintf(operate,"%s %s",argv[2],fname_dat);

      system(operate);

      input_open(fname_dat);
      input_string("System.Name",fname_dat2,"default");

      sprintf(operate,"cp %s.out %s/",fname_dat2,dir);
      system(operate);
       
      input_close();
    }

    fclose(fp0);
    fclose(fp1);
  }
  else{
    printf("Could not find ls_dat000000 or ls_dat000001\n");
    exit(1);
  }

  sprintf(operate,"rm ls_dat000000");
  system(operate);

  sprintf(operate,"rm ls_dat000001");
  system(operate);

  printf("\n\n\n\n");
  printf("Generated out files are stored in the directory '%s'.\n\n\n",dir);
}