Changeset 56
- Timestamp:
- 08/30/11 11:18:11 (21 months ago)
- File:
-
- 1 edited
-
trunk/src/read_upf.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_upf.c
r50 r56 24 24 25 25 #include <pspio.h> 26 #include <stdio.h>26 #include "stdio.h" 27 27 28 /** 29 * Init the UPF file read 30 * @param[in,out] psp_data the data structure 31 * @param[in] fp a stream of the input file 32 * @return error code 33 */ 34 int pspio_upf_init(char FILE * fp, pspio_pspdata_t * psp_data); 35 int pspio_upf_end(pspio_pspdata_t * psp_data); 36 int pspio_upf_file_read(FILE * fp, pspio_pspdata_t * psp_data); 28 37 29 int init_tag(int unit, char * string, int go_back); 38 int tag_isdef(FILE * fp, char * string); 39 int init_tag(FILE * fp, char * string, int go_back); 30 40 int check_end_tag(char * tag); 31 int ps_upf_init(pspio_pspdata_t * ps_upf, char * filename);32 int ps_upf_end(pspio_pspdata_t * ps_upf);33 int ps_upf_file_read(int unit, pspio_pspdata_t * ps_upf);34 int tag_isdef(int unit, char * string);35 41 36 int ps_upf_cutoff_radii(pspio_pspdata_t * ps_upf); 42 int pspio_upf_cutoff_radii(pspio_pspdata_t * psp_data); 43 37 44 /** 38 45 * checks normalization of the pseudo wavefunctions 39 46 */ 40 int ps_upf_check_rphi(pspio_pspdata_t * ps_upf); 47 int pspio_upf_check_rphi(pspio_pspdata_t * psp_data); 48 49 50 51 /* start the implementations */ 52 /*****************************/ 53 int pspio_upf_init(char FILE * fp, pspio_pspdata_t * psp_data){ 54 char tmp_filename[256]; 55 int ierr; 56 57 pspio_upf_file_read(fp,psp_data); 58 } 59 60 int pspio_upf_file_read(FILE * fp, pspio_pspdata_t * psp_data){ 61 int ierr; 62 int version_number; 63 char line[MAX_LINE + 1]; 64 65 init_tag(fp,"PP_HEADER", 1); 66 fscanf(fp,"%d",version_number); //read the version number 67 fgets(line, sizeof line, fp); //skip the rest of the line 68 fgets(psp_data->symbol, sizeof line, fp); //read the symbol 69 fgets(line, 2, fp); // kind of pseudo-potentials US|NC|PAW "Ultrasoft|Norm conserving|Projector-augmented" 70 if (!strncpm(line,"NC",2)) { 71 printf("LIBPSP_IO can only read norm-conserving pseudo-potentials from UPF format."); 72 return PSPIO_TYPE_ERROR; 73 } 74 fscanf(fp,"%d",psp_data->nlcc); // read the nonlinear core correction 75 fgets(line, sizeof line, fp); //skip the rest of the line 76 fscanf(fp,"%d",psp_data->exchange); //read the exchange-correlation functional !!CORRECTION NEEDED!!!!!!!!!!!!!!!!! either we have to skipt or read it like in LIBXC 77 //read(unit,*) dummy ! dft "Exch-Corr" 78 fgets(line, sizeof line, fp); //skip the rest of the line 79 fscanf(fp,"%4.11f",psp_data->zvalence); //read the Z valence 80 fgets(line, sizeof line, fp); //skip the rest of the line 81 fgets(line, sizeof line, fp); //skip the total energy 82 fscanf(fp,"4.7f",psp_data->rc); //read the suggested cutoff for wfc 83 //fscanf ??? read the suggested cutoff for rho 84 fgets(line, sizeof line, fp); //skip the rest of the line 85 fscanf(fp,"%d",psp_data->lmax); //read the max angular momentun component (Note: is not the lmax needed by Octopus 86 fgets(line, sizeof line, fp); //skip the rest of the line 87 fscanf(fp,"%d",psp_data->states->np); //read the number of points in mesh 88 fgets(line, sizeof line, fp); //skip the rest of the line 89 fscanf(fp,"%d %d",psp_data->n_states,psp_data->pspio_kb_projectors_t->nproj); //read the number of wavefunctions, projector 90 91 //read the wavefuntions: @todo 92 93 } 94 95 int init_tag(FILE * fp, char * string, int go_back){ 96 char line[MAX_LINE + 1]; 97 char * compare_string = NULL; 98 if (go_back) rewind(fp); 99 100 strcat(compare_string,"<"); 101 strncat(compare_string,string,strlen(string)); 102 strcat(compare_string,">"); 103 104 while(fgets(line, sizeof line, fp) != NULL){ 105 if( strcamp(line,compare_string) ) return; 106 } 107 } 108
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/libpspio/chrome/site/your_project_logo.png)