00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 #include <stdlib.h>
00149 #include <stdarg.h>
00150 #include <string.h>
00151 #include <ctype.h>
00152 #include <errno.h>
00153 #include <time.h>
00154
00155 #include "qmplugin.h"
00156 #include "unit_conversion.h"
00157 #include "periodic_table.h"
00158
00159 #define ANGSTROM 0
00160 #define BOHR 1
00161
00162
00163
00164
00165
00166
00167
00168
00169 #ifdef DEBUGGING
00170 #define PRINTERR fprintf(stderr, "\n In file %s, line %d: \n %s \n \n", \
00171 __FILE__, __LINE__, strerror(errno))
00172 #else
00173 #define PRINTERR (void)(0)
00174 #endif
00175
00176
00177
00178
00179
00180 #define GET_LINE(x,y) if (!fgets(x, sizeof(x), y)) return FALSE
00181
00182
00183 #define NOTFOUND 0
00184 #define FOUND 1
00185 #define STOPPED 2
00186
00187
00188 #define GAMESSUNKNOWN 0
00189 #define GAMESSPRE20050627 1
00190 #define GAMESSPOST20050627 2
00191 #define FIREFLY8PRE6695 3
00192 #define FIREFLY8POST6695 4
00193
00194
00195 typedef struct
00196 {
00197 int version;
00198
00199
00200
00201
00202
00203
00204
00205 int have_pcgamess;
00206
00207
00208
00209
00210
00211
00212 int have_fmo;
00213
00214 } gmsdata;
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 static int parse_static_data(qmdata_t *, int *);
00225
00226
00227 static void print_input_data(qmdata_t *);
00228
00229
00230
00231 static int have_gamess(qmdata_t *, gmsdata *);
00232
00233
00234 static int get_proc_mem(qmdata_t *, gmsdata *);
00235
00236
00237 static int get_basis_options(qmdata_t *);
00238
00239
00240 static int get_runtitle(qmdata_t *);
00241
00242
00243 static int get_input_structure(qmdata_t *data, gmsdata *gms);
00244
00245
00246
00247
00248 static int get_basis_stats(qmdata_t *);
00249
00250
00251
00252
00253 static int get_contrl_firefly(qmdata_t *);
00254
00255
00256
00257
00258 static int get_contrl(qmdata_t *);
00259
00260
00261
00262
00263 static int get_properties_input(qmdata_t *);
00264
00265
00266 static int get_symmetry(qmdata_t *);
00267
00268
00269 static int get_guess_options(qmdata_t *);
00270
00271
00272 static int get_mcscf(qmdata_t *data);
00273
00274
00275
00276
00277 static int get_final_properties (qmdata_t *);
00278
00279
00280 static int get_coordinates(FILE *file, qm_atom_t **atoms, int unit,
00281 int *numatoms);
00282
00283
00284
00285 static int get_fmoxyz(FILE *file, qm_atom_t **atoms, int unit,
00286 int *numatoms);
00287
00288
00289 static int get_basis (qmdata_t *);
00290
00291
00292 static int read_shell_primitives(qmdata_t *, prim_t **prim,
00293 char *shelltype, int icoeff, int pcgamess);
00294
00295
00296 static int shelltype_int(char type);
00297
00298
00299 static int fill_basis_arrays(qmdata_t *);
00300
00301
00302 static int read_first_frame(qmdata_t *);
00303
00304
00305 static int get_traj_frame(qmdata_t *, qm_atom_t *, int);
00306
00307
00308 static int analyze_traj(qmdata_t *, gmsdata *);
00309
00310
00311
00312 static int get_scfdata(qmdata_t *, qm_timestep_t *);
00313
00314
00315
00316 static int check_add_wavefunctions(qmdata_t *data,
00317 qm_timestep_t *ts);
00318
00319
00320 static int get_wavefunction(qmdata_t *, qm_timestep_t *, qm_wavefunction_t *);
00321
00322
00323 static int read_coeff_block(FILE *file, int wavef_size,
00324 float *wave_coeff, int *angular_momentum);
00325
00326
00327 static int read_localized_orbitals(qmdata_t *data);
00328
00329
00330 static int get_population(qmdata_t *, qm_timestep_t *);
00331
00332
00333 static int get_gradient(qmdata_t *, qm_timestep_t *ts);
00334
00335
00336 static int get_final_gradient(qmdata_t *, qm_timestep_t *ts);
00337
00338
00339 static int get_esp_charges(qmdata_t *data);
00340
00341
00342
00343
00344 static int get_int_coords(qmdata_t *);
00345
00346
00347 static int get_int_hessian(qmdata_t *);
00348
00349
00350
00351 static int get_cart_hessian(qmdata_t *);
00352
00353
00354
00355 static int get_normal_modes(qmdata_t *);
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 static void *open_gamess_read(const char *filename,
00376 const char *filetype, int *natoms) {
00377
00378 FILE *fd;
00379 qmdata_t *data = NULL;
00380 gmsdata *gms;
00381
00382
00383 fd = fopen(filename, "rb");
00384
00385 if (!fd) {
00386 PRINTERR;
00387 return NULL;
00388 }
00389
00390
00391 data = init_qmdata();
00392
00393
00394 if (data == NULL) {
00395 PRINTERR;
00396 return NULL;
00397 }
00398
00399
00400 gms = (gmsdata *)calloc(1,sizeof(gmsdata));
00401 data->format_specific_data = gms;
00402
00403 gms->version = 0;
00404 gms->have_pcgamess = 0;
00405 gms->have_fmo = 0;
00406
00407
00408
00409 data->file = fd;
00410
00411
00412
00413
00414 if (have_gamess(data, gms)==TRUE) {
00415 if (gms->have_pcgamess) {
00416 printf("gamessplugin) Warning: PC GAMESS/FIREFLY is not yet fully supported!\n");
00417
00418 }
00419
00420
00421 if (gms->version==GAMESSUNKNOWN) {
00422 printf("gamessplugin) GAMESS version %s not supported. \n",
00423 data->version_string);
00424 return NULL;
00425 }
00426
00427
00428 if (parse_static_data(data, natoms) == FALSE)
00429 return NULL;
00430 }
00431 else {
00432 printf("gamessplugin) This seems to not be a GAMESS logfile.\n");
00433 return NULL;
00434 }
00435
00436 return data;
00437 }
00438
00439
00440
00441
00442
00443
00444
00445
00446 static int read_gamess_structure(void *mydata, int *optflags,
00447 molfile_atom_t *atoms)
00448 {
00449 qmdata_t *data = (qmdata_t *)mydata;
00450 qm_atom_t *cur_atom;
00451 molfile_atom_t *atom;
00452 int i = 0;
00453
00454
00455 *optflags = MOLFILE_ATOMICNUMBER;
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 cur_atom = data->atoms;
00469
00470 for(i=0; i<data->numatoms; i++) {
00471 atom = atoms+i;
00472 strncpy(atom->name, cur_atom->type, sizeof(atom->name));
00473 strncpy(atom->type, cur_atom->type, sizeof(atom->type));
00474 strncpy(atom->resname,"", sizeof(atom->resname));
00475 atom->resid = 1;
00476 atom->chain[0] = '\0';
00477 atom->segid[0] = '\0';
00478 atom->atomicnumber = cur_atom->atomicnum;
00479 #ifdef DEBUGGING
00480 printf("gamessplugin) atomicnum[%d] = %d\n", i, atom->atomicnumber);
00481 #endif
00482
00483
00484
00485
00486 cur_atom++;
00487 }
00488
00489 return MOLFILE_SUCCESS;
00490 }
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 static int read_gamess_metadata(void *mydata,
00501 molfile_qm_metadata_t *metadata) {
00502
00503 qmdata_t *data = (qmdata_t *)mydata;
00504
00505 if (data->runtype == MOLFILE_RUNTYPE_HESSIAN) {
00506 metadata->ncart = (3*data->numatoms);
00507 metadata->nimag = data->nimag;
00508
00509 if (data->have_internals) {
00510 metadata->nintcoords = data->nintcoords;
00511 } else {
00512 metadata->nintcoords = 0;
00513 }
00514 }
00515 else {
00516 metadata->ncart = 0;
00517 metadata->nimag = 0;
00518 metadata->nintcoords = 0;
00519 }
00520
00521
00522 metadata->num_basis_funcs = data->num_basis_funcs;
00523 metadata->num_basis_atoms = data->num_basis_atoms;
00524 metadata->num_shells = data->num_shells;
00525 metadata->wavef_size = data->wavef_size;
00526
00527 #if vmdplugin_ABIVERSION > 11
00528
00529 metadata->have_sysinfo = 1;
00530
00531
00532 metadata->have_carthessian = data->have_cart_hessian;
00533 metadata->have_inthessian = data->have_int_hessian;
00534
00535
00536 metadata->have_normalmodes = data->have_normal_modes;
00537 #endif
00538
00539 return MOLFILE_SUCCESS;
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 static int read_gamess_rundata(void *mydata,
00551 molfile_qm_t *qm_data) {
00552
00553 qmdata_t *data = (qmdata_t *)mydata;
00554 int i, j;
00555 int ncart;
00556 molfile_qm_hessian_t *hessian_data = &qm_data->hess;
00557 molfile_qm_basis_t *basis_data = &qm_data->basis;
00558 molfile_qm_sysinfo_t *sys_data = &qm_data->run;
00559
00560
00561 if (data->runtype == MOLFILE_RUNTYPE_HESSIAN) {
00562 ncart = 3*data->numatoms;
00563
00564
00565 if (data->have_cart_hessian) {
00566 for (i=0; i<ncart; i++) {
00567 for (j=0; j<=i; j++) {
00568 hessian_data->carthessian[ncart*i+j] = data->carthessian[ncart*i+j];
00569 hessian_data->carthessian[ncart*j+i] = data->carthessian[ncart*i+j];
00570 }
00571 }
00572 }
00573
00574
00575 if (data->have_int_hessian) {
00576 for (i=0; i<(data->nintcoords)*(data->nintcoords); i++) {
00577 hessian_data->inthessian[i] = data->inthessian[i];
00578 }
00579 }
00580
00581
00582 if (data->have_normal_modes) {
00583 for (i=0; i<ncart*ncart; i++) {
00584 hessian_data->normalmodes[i] = data->normal_modes[i];
00585 }
00586 for (i=0; i<ncart; i++) {
00587 hessian_data->wavenumbers[i] = data->wavenumbers[i];
00588 hessian_data->intensities[i] = data->intensities[i];
00589 }
00590 }
00591
00592
00593 for (i=0; i<data->nimag; i++) {
00594
00595 hessian_data->imag_modes[i] = data->imag_modes[i];
00596 }
00597 }
00598
00599
00600 sys_data->runtype = data->runtype;
00601 sys_data->scftype = data->scftype;
00602 sys_data->nproc = data->nproc;
00603 sys_data->num_electrons = data->num_electrons;
00604 sys_data->totalcharge = data->totalcharge;
00605 sys_data->num_occupied_A = data->num_occupied_A;
00606 sys_data->num_occupied_B = data->num_occupied_B;
00607 sys_data->status = data->status;
00608
00609
00610 strncpy(sys_data->basis_string, data->basis_string,
00611 sizeof(sys_data->basis_string));
00612
00613 sys_data->memory = 0;
00614
00615 strncpy(sys_data->runtitle, data->runtitle, sizeof(sys_data->runtitle));
00616 strncpy(sys_data->geometry, data->geometry, sizeof(sys_data->geometry));
00617 strncpy(sys_data->version_string, data->version_string,
00618 sizeof(sys_data->version_string));
00619
00620 #if vmdplugin_ABIVERSION > 11
00621
00622 if (data->num_basis_funcs) {
00623 for (i=0; i<data->num_basis_atoms; i++) {
00624 basis_data->num_shells_per_atom[i] = data->num_shells_per_atom[i];
00625 basis_data->atomic_number[i] = data->atomicnum_per_basisatom[i];
00626 }
00627
00628 for (i=0; i<data->num_shells; i++) {
00629 basis_data->num_prim_per_shell[i] = data->num_prim_per_shell[i];
00630 basis_data->shell_types[i] = data->shell_types[i];
00631 }
00632
00633 for (i=0; i<2*data->num_basis_funcs; i++) {
00634 basis_data->basis[i] = data->basis[i];
00635 }
00636
00637 for (i=0; i<3*data->wavef_size; i++) {
00638 basis_data->angular_momentum[i] = data->angular_momentum[i];
00639 }
00640 }
00641 #endif
00642
00643 return MOLFILE_SUCCESS;
00644 }
00645
00646
00647
00648
00649 #if vmdplugin_ABIVERSION > 11
00650
00651
00652
00653
00654
00655 static int read_timestep_metadata(void *mydata,
00656 molfile_timestep_metadata_t *meta) {
00657 meta->count = -1;
00658 meta->has_velocities = 0;
00659
00660 return MOLFILE_SUCCESS;
00661 }
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 static int read_qm_timestep_metadata(void *mydata,
00672 molfile_qm_timestep_metadata_t *meta) {
00673 int have = 0;
00674
00675 qmdata_t *data = (qmdata_t *)mydata;
00676
00677 meta->count = -1;
00678
00679 if (data->num_frames_read > data->num_frames_sent) {
00680 have = 1;
00681 }
00682 else if (data->num_frames_read < data->num_frames) {
00683
00684
00685 have = get_traj_frame(data, data->atoms, data->numatoms);
00686 }
00687
00688 if (have) {
00689 int i;
00690 qm_timestep_t *cur_ts;
00691
00692
00693 cur_ts = data->qm_timestep+data->num_frames_sent;
00694
00695 for (i=0; (i<MOLFILE_MAXWAVEPERTS && i<cur_ts->numwave); i++) {
00696 meta->num_orbitals_per_wavef[i] = cur_ts->wave[i].num_orbitals;
00697 meta->has_occup_per_wavef[i] = cur_ts->wave[i].has_occup;
00698 meta->has_orben_per_wavef[i] = cur_ts->wave[i].has_orben;
00699 }
00700 meta->wavef_size = data->wavef_size;
00701 meta->num_wavef = cur_ts->numwave;
00702 meta->num_scfiter = cur_ts->num_scfiter;
00703 meta->num_charge_sets = cur_ts->have_mulliken +
00704 cur_ts->have_lowdin + cur_ts->have_esp;
00705 if (cur_ts->gradient) meta->has_gradient = TRUE;
00706
00707 } else {
00708 meta->has_gradient = FALSE;
00709 meta->num_scfiter = 0;
00710 meta->num_orbitals_per_wavef[0] = 0;
00711 meta->has_occup_per_wavef[0] = FALSE;
00712 meta->num_wavef = 0;
00713 meta->wavef_size = 0;
00714 meta->num_charge_sets = 0;
00715 data->trajectory_done = TRUE;
00716 }
00717
00718 return MOLFILE_SUCCESS;
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 static int read_timestep(void *mydata, int natoms,
00732 molfile_timestep_t *ts, molfile_qm_metadata_t *qm_metadata,
00733 molfile_qm_timestep_t *qm_ts)
00734 {
00735 qmdata_t *data = (qmdata_t *)mydata;
00736 qm_timestep_t *cur_ts;
00737 int offset;
00738 int i = 0;
00739 int num_charge_sets = 0;
00740
00741 if (data->trajectory_done == TRUE) return MOLFILE_ERROR;
00742
00743
00744
00745 for (i=0; i<natoms; i++) {
00746 ts->coords[3*i ] = data->atoms[i].x;
00747 ts->coords[3*i+1] = data->atoms[i].y;
00748 ts->coords[3*i+2] = data->atoms[i].z;
00749 }
00750
00751
00752 cur_ts = data->qm_timestep+data->num_frames_sent;
00753
00754
00755 for (i=0; i<cur_ts->num_scfiter; i++) {
00756 qm_ts->scfenergies[i] = cur_ts->scfenergies[i];
00757 }
00758
00759
00760 if (cur_ts->gradient) {
00761 for (i=0; i<3*natoms; i++) {
00762 qm_ts->gradient[i] = cur_ts->gradient[i];
00763 }
00764 }
00765
00766
00767 if (cur_ts->have_mulliken) {
00768 offset = num_charge_sets*data->numatoms;
00769 for (i=0; i<data->numatoms; i++) {
00770 qm_ts->charges[offset+i] = cur_ts->mulliken_charges[i];
00771 }
00772 qm_ts->charge_types[num_charge_sets] = MOLFILE_QMCHARGE_MULLIKEN;
00773 num_charge_sets++;
00774 }
00775
00776 if (cur_ts->have_lowdin) {
00777 offset = num_charge_sets*data->numatoms;
00778 for (i=0; i<data->numatoms; i++) {
00779 qm_ts->charges[offset+i] = cur_ts->lowdin_charges[i];
00780 }
00781 qm_ts->charge_types[num_charge_sets] = MOLFILE_QMCHARGE_LOWDIN;
00782 num_charge_sets++;
00783 }
00784 if (cur_ts->have_esp) {
00785 offset = num_charge_sets*data->numatoms;
00786 for (i=0; i<data->numatoms; i++) {
00787 qm_ts->charges[offset+i] = cur_ts->esp_charges[i];
00788 }
00789 qm_ts->charge_types[num_charge_sets] = MOLFILE_QMCHARGE_ESP;
00790 num_charge_sets++;
00791 }
00792
00793
00794
00795 if (cur_ts->wave) {
00796 for (i=0; i<cur_ts->numwave; i++) {
00797 qm_wavefunction_t *wave = &cur_ts->wave[i];
00798 qm_ts->wave[i].type = wave->type;
00799 qm_ts->wave[i].spin = wave->spin;
00800 qm_ts->wave[i].excitation = wave->exci;
00801 qm_ts->wave[i].multiplicity = wave->mult;
00802 qm_ts->wave[i].energy = wave->energy;
00803 strncpy(qm_ts->wave[i].info, wave->info, MOLFILE_BUFSIZ);
00804
00805 if (wave->wave_coeffs) {
00806 memcpy(qm_ts->wave[i].wave_coeffs, wave->wave_coeffs,
00807 wave->num_orbitals*data->wavef_size*sizeof(float));
00808 }
00809 if (wave->orb_energies) {
00810 memcpy(qm_ts->wave[i].orbital_energies, wave->orb_energies,
00811 wave->num_orbitals*sizeof(float));
00812 }
00813 if (wave->has_occup) {
00814 memcpy(qm_ts->wave[i].occupancies, wave->orb_occupancies,
00815 wave->num_orbitals*sizeof(float));
00816 }
00817 }
00818 }
00819
00820 if (data->runtype == MOLFILE_RUNTYPE_ENERGY ||
00821 data->runtype == MOLFILE_RUNTYPE_HESSIAN) {
00822
00823 data->trajectory_done = TRUE;
00824 }
00825
00826 data->num_frames_sent++;
00827
00828 return MOLFILE_SUCCESS;
00829 }
00830 #endif
00831
00832
00833
00834
00835
00836
00837
00838
00839 static void close_gamess_read(void *mydata) {
00840
00841 qmdata_t *data = (qmdata_t *)mydata;
00842 int i, j;
00843 fclose(data->file);
00844
00845 free(data->atoms);
00846 free(data->basis);
00847 free(data->shell_types);
00848 free(data->atomicnum_per_basisatom);
00849 free(data->num_shells_per_atom);
00850 free(data->num_prim_per_shell);
00851 free(data->bonds);
00852 free(data->angles);
00853 free(data->dihedrals);
00854 free(data->impropers);
00855 free(data->internal_coordinates);
00856 free(data->bond_force_const);
00857 free(data->angle_force_const);
00858 free(data->dihedral_force_const);
00859 free(data->improper_force_const);
00860 free(data->inthessian);
00861 free(data->carthessian);
00862 free(data->wavenumbers);
00863 free(data->intensities);
00864 free(data->normal_modes);
00865 free(data->imag_modes);
00866 free(data->angular_momentum);
00867 free(data->filepos_array);
00868
00869 if (data->basis_set) {
00870 for(i=0; i<data->num_basis_atoms; i++) {
00871 for (j=0; j<data->basis_set[i].numshells; j++) {
00872 free(data->basis_set[i].shell[j].prim);
00873 }
00874 free(data->basis_set[i].shell);
00875 }
00876 free(data->basis_set);
00877 }
00878
00879 for (i=0; i<data->num_frames; i++) {
00880 free(data->qm_timestep[i].scfenergies);
00881 free(data->qm_timestep[i].gradient);
00882 free(data->qm_timestep[i].mulliken_charges);
00883 free(data->qm_timestep[i].lowdin_charges);
00884 free(data->qm_timestep[i].esp_charges);
00885 for (j=0; j<data->qm_timestep[i].numwave; j++) {
00886 free(data->qm_timestep[i].wave[j].wave_coeffs);
00887 free(data->qm_timestep[i].wave[j].orb_energies);
00888 free(data->qm_timestep[i].wave[j].orb_occupancies);
00889 }
00890 free(data->qm_timestep[i].wave);
00891 }
00892 free(data->qm_timestep);
00893 free(data->format_specific_data);
00894 free(data);
00895 }
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910 static int parse_static_data(qmdata_t *data, int *natoms)
00911 {
00912
00913 gmsdata *gms = (gmsdata *)data->format_specific_data;
00914
00915
00916
00917 get_proc_mem(data, gms);
00918
00919
00920 if (!get_basis_options(data)) return FALSE;
00921
00922
00923 if (!get_runtitle(data)) return FALSE;
00924
00925
00926
00927
00928
00929
00930 if (gms->have_pcgamess){
00931 if (!get_contrl_firefly(data)) return FALSE;
00932 }
00933 else {
00934 if (!get_contrl(data)) return FALSE;
00935 }
00936
00937
00938 if (!get_input_structure(data, gms)) return FALSE;
00939
00940
00941 if (!get_basis(data)) return FALSE;
00942
00943
00944
00945 if (!get_basis_stats(data)) return FALSE;
00946
00947
00948
00949
00950 if (!get_properties_input(data)) return FALSE;
00951
00952
00953 get_int_coords(data);
00954
00955
00956 if (!get_symmetry(data)) return FALSE;
00957
00958
00959 get_guess_options(data);
00960
00961 if (data->scftype==MOLFILE_SCFTYPE_MCSCF) {
00962 if (!get_mcscf(data)) return FALSE;
00963 }
00964
00965
00966
00967
00968
00969 if (!analyze_traj(data, gms)) {
00970 printf("gamessplugin) WARNING: Truncated or abnormally terminated file!\n\n");
00971 }
00972
00973
00974
00975 *natoms = data->numatoms;
00976
00977
00978 read_first_frame(data);
00979
00980
00981 get_final_properties(data);
00982
00983 #ifdef DEBUGGING
00984 printf("gamessplugin) num_frames_read = %d\n", data->num_frames_read);
00985 printf("gamessplugin) num_frames_sent = %d\n", data->num_frames_sent);
00986
00987
00988 print_input_data(data);
00989 #endif
00990
00991 return TRUE;
00992 }
00993
00994
00995 #define TORF(x) (x ? "T" : "F")
00996
00997 static void print_input_data(qmdata_t *data) {
00998 int i, j, k;
00999 int primcount=0;
01000 int shellcount=0;
01001
01002 printf("\nDATA READ FROM FILE:\n\n");
01003 printf(" %10s WORDS OF MEMORY AVAILABLE\n", data->memory);
01004 printf("\n");
01005 printf(" BASIS OPTIONS\n");
01006 printf(" -------------\n");
01007 printf("%s\n", data->basis_string);
01008 printf("\n\n\n");
01009 printf(" RUN TITLE\n");
01010 printf(" ---------\n");
01011 printf(" %s\n", data->runtitle);
01012 printf("\n");
01013 printf(" THE POINT GROUP OF THE MOLECULE IS %s\n", "XXX");
01014 printf(" THE ORDER OF THE PRINCIPAL AXIS IS %5i\n", 0);
01015 printf("\n");
01016 printf(" YOUR FULLY SUBSTITUTED Z-MATRIX IS\n");
01017 printf("\n");
01018 printf(" THE MOMENTS OF INERTIA ARE (AMU-ANGSTROM**2)\n");
01019 printf(" IXX=%10.3f IYY=%10.3f IZZ=%10.3f\n", 0.0, 0.0, 0.0);
01020 printf("\n");
01021 printf(" ATOM ATOMIC COORDINATES (BOHR)\n");
01022 printf(" CHARGE X Y Z\n");
01023 for (i=0; i<data->numatoms; i++) {
01024 printf(" %-8s %6d", data->atoms[i].type, data->atoms[i].atomicnum);
01025
01026 printf("%17.10f", ANGS_TO_BOHR*data->atoms[i].x);
01027 printf("%20.10f", ANGS_TO_BOHR*data->atoms[i].y);
01028 printf("%20.10f\n", ANGS_TO_BOHR*data->atoms[i].z);
01029 }
01030 printf("\n");
01031 printf(" ATOMIC BASIS SET\n");
01032 printf(" ----------------\n");
01033 printf(" THE CONTRACTED PRIMITIVE FUNCTIONS HAVE BEEN UNNORMALIZED\n");
01034 printf(" THE CONTRACTED BASIS FUNCTIONS ARE NOW NORMALIZED TO UNITY\n");
01035 printf("\n");
01036 printf(" SHELL TYPE PRIMITIVE EXPONENT CONTRACTION COEFFICIENT(S)\n");
01037 printf("\n");
01038
01039 #if 0
01040 for (i=0; i<data->numatoms; i++) {
01041 printf("%-8s\n\n", data->atoms[i].type);
01042 printf("\n");
01043 printf("nshells=%d\n", data->num_shells_per_atom[i]);
01044
01045 for (j=0; j<data->num_shells_per_atom[i]; j++) {
01046 printf("nprim=%d\n", data->num_prim_per_shell[shellcount]);
01047
01048 for (k=0; k<data->num_prim_per_shell[shellcount]; k++) {
01049 printf("%6d %d %7d %22f%22f\n", j, data->shell_types[shellcount],
01050 primcount+1, data->basis[2*primcount], data->basis[2*primcount+1]);
01051 primcount++;
01052 }
01053
01054 printf("\n");
01055 shellcount++;
01056 }
01057 }
01058 #endif
01059 printf("gamessplugin) =================================================================\n");
01060 for (i=0; i<data->num_basis_atoms; i++) {
01061 printf("%-8s (%10s)\n\n", data->atoms[i].type, data->basis_set[i].name);
01062 printf("\n");
01063
01064 for (j=0; j<data->basis_set[i].numshells; j++) {
01065
01066 for (k=0; k<data->basis_set[i].shell[j].numprims; k++) {
01067 printf("%6d %d %7d %22f%22f\n", j,
01068 data->basis_set[i].shell[j].type,
01069 primcount+1,
01070 data->basis_set[i].shell[j].prim[k].exponent,
01071 data->basis_set[i].shell[j].prim[k].contraction_coeff);
01072 primcount++;
01073 }
01074
01075 printf("\n");
01076 shellcount++;
01077 }
01078 }
01079 printf("\n");
01080 printf(" TOTAL NUMBER OF BASIS SET SHELLS =%5d\n", data->num_shells);
01081 printf(" NUMBER OF CARTESIAN GAUSSIAN BASIS FUNCTIONS =%5d\n", data->wavef_size);
01082 printf(" NUMBER OF ELECTRONS =%5d\n", data->num_electrons);
01083 printf(" CHARGE OF MOLECULE =%5d\n", data->totalcharge);
01084 printf(" SPIN MULTIPLICITY =%5d\n", data->multiplicity);
01085 printf(" NUMBER OF OCCUPIED ORBITALS (ALPHA) =%5d\n", data->num_occupied_A);
01086 printf(" NUMBER OF OCCUPIED ORBITALS (BETA ) =%5d\n", data->num_occupied_B);
01087 printf(" TOTAL NUMBER OF ATOMS =%5i\n", data->numatoms);
01088 printf("\n");
01089 }
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099 static int have_gamess(qmdata_t *data, gmsdata *gms)
01100 {
01101 char word[3][BUFSIZ];
01102 char buffer[BUFSIZ];
01103 char versionstr[BUFSIZ];
01104 int day, year;
01105 char month[BUFSIZ], rev[BUFSIZ];
01106 int i = 0;
01107 int program;
01108 int ver,build;
01109 buffer[0] = '\0';
01110 for (i=0; i<3; i++) word[i][0] = '\0';
01111
01112
01113
01114 program = goto_keyline(data->file,
01115 "PC GAMESS version",
01116 "GAMESS VERSION =",
01117 "Firefly version",NULL);
01118 if (program==1) {
01119 gms->have_pcgamess = 1;
01120 gms->version = 1;
01121 strcpy(data->version_string, "PC GAMESS ");
01122 } else if (program==2) {
01123 gms->have_pcgamess = 0;
01124 strcpy(data->version_string, "GAMESS ");
01125 } else if (program==3) {
01126 gms->have_pcgamess = 1;
01127 gms->version = FIREFLY8PRE6695;
01128 strcpy(data->version_string, "Firefly ");
01129 } else {
01130 printf("gamessplugin) This is no GAMESS/PCGAMESS/Firefly logfile!\n");
01131 return FALSE;
01132 }
01133
01134 GET_LINE(buffer, data->file);
01135
01136 if (gms->have_pcgamess) {
01137 if (strstr(buffer,"version") != NULL) {
01138 strncpy(versionstr, strstr(buffer,"version")+8, 16);
01139 *strchr(versionstr, ' ') = '\0';
01140 sscanf(buffer, "%*s %*s %*s %*s %*s %*s %d", &build);
01141 sscanf(versionstr, "%1d%*s", &ver);
01142 printf("gamessplugin) Firefly build = %d %d\n",
01143 ver,build);
01144 if (ver >= 8 && build >= 6695)
01145 gms->version = FIREFLY8POST6695;
01146 else
01147 gms->version = FIREFLY8PRE6695;
01148 }
01149 } else {
01150
01151
01152 if (strstr(buffer,"=") != NULL) {
01153 strncpy(versionstr, strstr(buffer,"=")+2, 16);
01154 versionstr[16] = '\0';
01155 }
01156
01157
01158
01159 sscanf(versionstr, "%d %s %d %s", &day, month, &year, rev);
01160
01161 if ( ( year >= 2006 ) ||
01162 ( year == 2005 && !strcmp(month,"JUN") ) ||
01163 ( year == 2005 && !strcmp(month,"NOV") ) ||
01164 ( year == 2005 && !strcmp(month,"DEC") ) )
01165 {
01166 gms->version = GAMESSPOST20050627;
01167 } else {
01168 gms->version = GAMESSPRE20050627;
01169 }
01170 }
01171
01172 strcat(data->version_string, versionstr);
01173
01174 printf("gamessplugin) Version = %s\n",
01175 data->version_string);
01176
01177 return TRUE;
01178 }
01179
01180
01181
01182
01183
01184
01185
01186
01187 static int get_proc_mem(qmdata_t *data, gmsdata *gms) {
01188
01189 char word[4][BUFSIZ];
01190 char buffer[BUFSIZ];
01191 char *temp;
01192 int nproc;
01193 int i;
01194
01195 buffer[0] = '\0';
01196 for (i=0; i<3; i++) word[i][0] = '\0';
01197
01198 rewind(data->file);
01199
01200
01201
01202
01203 if (gms->have_pcgamess == 1) {
01204
01205
01206 nproc = 1;
01207 do {
01208 GET_LINE(buffer, data->file);
01209 sscanf(buffer,"%s %d %s",&word[0][0],&nproc,&word[1][0]);
01210 if (!strcmp(&word[0][0],"PARALLEL") &&
01211 !strcmp(&word[0][1],"RUNNING")) {
01212 sscanf(buffer,"%*s %*s %*s %*s %*s %d %*s %*s",&nproc);
01213 break;
01214 }
01215 } while (strcmp(&word[0][0],"ECHO") ||
01216 strcmp(&word[1][0],"THE") );
01217
01218 }
01219 else {
01220 do {
01221 GET_LINE(buffer, data->file);
01222 sscanf(buffer,"%s %d %s",&word[0][0],&nproc,&word[1][0]);
01223
01224 if (!strcmp(&word[0][0],"Initiating") &&
01225 !strcmp(&word[1][0],"compute")) {
01226 break;
01227 }
01228
01229 else if (!strcmp(&word[0][0],"Initiating") &&
01230 !strcmp(&word[1][0],"processes")) {
01231 break;
01232 }
01233
01234
01235 else if (!strcmp(&word[0][0],"PARALLEL") &&
01236 !strcmp(&word[0][1],"RUNNING")) {
01237 sscanf(buffer,"%*s %*s %*s %*s %d %*s",&nproc);
01238 break;
01239 }
01240
01241 } while (strcmp(&word[0][0],"ECHO") ||
01242 strcmp(&word[1][0],"THE") );
01243 }
01244
01245
01246 data->nproc = nproc;
01247
01248
01249
01250 do {
01251 GET_LINE(buffer, data->file);
01252 sscanf(buffer,"%s %s",&word[0][0],&word[1][0]);
01253
01254 } while( strcmp(&word[0][0],"$SYSTEM") ||
01255 strcmp(&word[1][0],"OPTIONS") );
01256
01257 eatline(data->file, 1);
01258
01259
01260
01261
01262 if (gms->have_pcgamess == 1) {
01263 GET_LINE(buffer, data->file);
01264
01265
01266 if ((temp = strstr(buffer,"MEMORY=")+8)==NULL) return FALSE;
01267 strncpy(data->memory,trimright(temp),sizeof(data->memory));
01268 }
01269 else {
01270 GET_LINE(buffer, data->file);
01271 sscanf(buffer,"%s %s %s",&word[0][0],&word[1][0],&word[2][0]);
01272
01273
01274 strncpy(data->memory,&word[2][0],sizeof(data->memory));
01275 }
01276
01277 printf("gamessplugin) GAMESS used %d compute processes \n", nproc);
01278 printf("gamessplugin) GAMESS used %s words of memory \n", data->memory);
01279
01280 return TRUE;
01281 }
01282
01283
01284
01285
01286
01287
01288
01289 static int get_basis_options(qmdata_t *data) {
01290
01291 char buffer[BUFSIZ];
01292 char diffuse[BUFSIZ];
01293 char polarization[BUFSIZ];
01294 int ngauss;
01295
01296 buffer[0] = '\0';
01297 diffuse[0] = '\0';
01298 polarization[0] = '\0';
01299
01300
01301
01302 rewind(data->file);
01303
01304
01305 if (pass_keyline(data->file, "BASIS OPTIONS",
01306 "RUN TITLE") != FOUND) {
01307
01308
01309 return TRUE;
01310 }
01311
01312 eatline(data->file, 1);
01313
01314
01315
01316
01317
01318 GET_LINE(buffer, data->file);
01319 sscanf(buffer," GBASIS=%s IGAUSS= %d", data->gbasis, &ngauss);
01320
01321
01322
01323
01324
01325
01326 if ( !strncmp(data->gbasis,"N311",sizeof(data->gbasis)) ||
01327 !strncmp(data->gbasis,"N31",sizeof(data->gbasis)) ||
01328 !strncmp(data->gbasis,"N21",sizeof(data->gbasis)) ||
01329 !strncmp(data->gbasis,"STO",sizeof(data->gbasis)) )
01330 {
01331 int npfunc, ndfunc, nffunc;
01332 int diffs=FALSE, diffsp=FALSE;
01333 char torf;
01334
01335
01336
01337 GET_LINE(buffer, data->file);
01338 if (sscanf(buffer," NDFUNC= %d NFFUNC= %d DIFFSP= %c",
01339 &ndfunc, &nffunc, &torf) != 3) {
01340 sscanf(buffer," NDFUNC= %d DIFFSP= %c", &ndfunc, &torf);
01341 }
01342
01343
01344 if (torf=='T') diffsp = TRUE;
01345
01346
01347
01348
01349 GET_LINE(buffer, data->file);
01350 sscanf(buffer," NPFUNC= %d DIFFS= %c", &npfunc, &torf);
01351
01352
01353 if (torf=='T') diffs = TRUE;
01354
01355
01356
01357
01358
01359
01360 if (diffs && diffsp) {
01361 strncpy(diffuse,"++",sizeof(diffuse));
01362 }
01363 else if (diffsp) {
01364 strncpy(diffuse,"+",sizeof(diffuse));
01365 }
01366 else {
01367 strncpy(diffuse,"",sizeof(diffuse));
01368 }
01369
01370
01371
01372 if (npfunc>0 && ndfunc>0 && nffunc>0) {
01373 sprintf(polarization, "(%dp,%dd,%df)", npfunc, ndfunc, nffunc);
01374 } else if (npfunc>0 && ndfunc>0) {
01375 sprintf(polarization, "(%dp,%dd)", npfunc, ndfunc);
01376 }
01377 else if (npfunc>0) {
01378 sprintf(polarization, "(%dp)", npfunc);
01379 }
01380 else if (ndfunc>0) {
01381 sprintf(polarization, "(%dd)", ndfunc);
01382 }
01383 else {
01384 strncpy(polarization, "", sizeof(polarization));
01385 }
01386
01387
01388 if (!strcmp(data->gbasis, "STO")) {
01389 sprintf(data->basis_string, "STO-%dG%s%s",
01390 ngauss, diffuse, polarization);
01391 }
01392 else {
01393 sprintf(data->basis_string, "%d-%s%sG%s",
01394 ngauss, (data->gbasis+1), diffuse,
01395 polarization);
01396 }
01397 }
01398
01399
01400 else if (!strncmp(data->gbasis, "CC", 2)) {
01401 strcpy(data->basis_string, "cc-p");
01402 if (strlen(data->gbasis)==4 && data->gbasis[3]=='C') {
01403 strcat(data->basis_string, "C");
01404 }
01405 strcat(data->basis_string, "V");
01406 strncat(data->basis_string, &data->gbasis[2], 1);
01407 strcat(data->basis_string, "Z");
01408 }
01409
01410
01411 else if (!strncmp(data->gbasis, "ACC", 3)) {
01412 strcpy(data->basis_string, "aug-cc-p");
01413 if (strlen(data->gbasis)==5 && data->gbasis[4]=='C') {
01414 strcat(data->basis_string, "C");
01415 }
01416 strcat(data->basis_string, "V");
01417 strncat(data->basis_string, &data->gbasis[3], 1);
01418 strcat(data->basis_string, "Z");
01419 }
01420
01421
01422
01423
01424
01425 else {
01426 strncpy(data->basis_string,data->gbasis,
01427 sizeof(data->basis_string));
01428 }
01429
01430 return TRUE;
01431 }
01432
01433
01434
01435
01436
01437
01438
01439
01440 static int get_runtitle(qmdata_t *data) {
01441
01442 char buffer[BUFSIZ];
01443
01444 if (pass_keyline(data->file, "RUN TITLE",
01445 "THE POINT GROUP") != FOUND) {
01446
01447
01448
01449 data->runtitle[0] = '\0';
01450 return TRUE;
01451 }
01452
01453 GET_LINE(buffer, data->file);
01454 strncpy(data->runtitle,trimright(buffer),sizeof(data->runtitle));
01455
01456 return TRUE;
01457 }
01458
01459
01460
01461
01462
01463
01464
01465 static int get_input_structure(qmdata_t *data, gmsdata *gms) {
01466 char buffer[BUFSIZ];
01467 char units[BUFSIZ];
01468 int numatoms = -1;
01469 int bohr;
01470 long filepos;
01471 filepos = ftell(data->file);
01472
01473
01474
01475
01476 if (goto_keyline(data->file,
01477 "ATOM ATOMIC COORDINATES (",
01478 "INTERNUCLEAR DISTANCES",
01479 "ATOMIC BASIS SET",
01480 "$CONTRL OPTIONS", NULL) == FOUND) {
01481
01482 GET_LINE(buffer, data->file);
01483 sscanf(buffer, " ATOM ATOMIC %*s %s", units);
01484 eatline(data->file, 1);
01485
01486 } else {
01487
01488 fseek(data->file, filepos, SEEK_SET);
01489 if (pass_keyline(data->file,
01490 "The Fragment Molecular Orbital (FMO) method.",
01491 NULL)) {
01492 gms->have_fmo = 1;
01493 printf("gamessplugin) Fragment Molecular Orbital (FMO) method.\n");
01494 }
01495
01496
01497
01498
01499 fseek(data->file, filepos, SEEK_SET);
01500 if (pass_keyline(data->file,
01501 "BEGINNING GEOMETRY SEARCH POINT NSERCH= 0",
01502 NULL) &&
01503 goto_keyline(data->file, "COORDINATES OF ALL ATOMS", NULL)) {
01504 GET_LINE(buffer, data->file);
01505 sscanf(buffer, " COORDINATES OF ALL ATOMS ARE %s", units);
01506 eatline(data->file, 2);
01507
01508 } else {
01509
01510
01511
01512
01513 rewind(data->file);
01514 if (!pass_keyline(data->file, "$CONTRL OPTIONS", NULL)) {
01515 printf("gamessplugin) Missing $CONTRL OPTIONS section!\n");
01516 return FALSE;
01517 }
01518 goto_keyline(data->file, "UNITS =", NULL);
01519 GET_LINE(buffer, data->file);
01520 sscanf(strstr(buffer, "UNITS ="), "%s", units);
01521 bohr = !strcmp(units, "BOHR");
01522
01523
01524 rewind(data->file);
01525 if (!pass_keyline(data->file, "INPUT CARD> $fmoxyz",
01526 "INPUT CARD> $FMOXYZ")) {
01527 printf("gamessplugin) No atom coordinates found!\n");
01528 return FALSE;
01529 }
01530
01531
01532 if (!get_fmoxyz(data->file, &data->atoms, bohr, &numatoms)) {
01533 printf("gamessplugin) Could not read coordinates from $FMOXYZ input!\n");
01534 return FALSE;
01535 } else {
01536 printf("gamessplugin) Fragment Molecular Orbital (FMO) method.\n");
01537 gms->have_fmo = 1;
01538 data->numatoms = numatoms;
01539 return TRUE;
01540 }
01541 }
01542 }
01543
01544
01545
01546
01547
01548
01549 bohr = !strcmp(units, "(BOHR)");
01550
01551
01552 if (get_coordinates(data->file, &data->atoms, bohr, &numatoms))
01553 data->num_frames_read = 0;
01554 else {
01555 printf("gamessplugin) Bad atom coordinate block!\n");
01556 return FALSE;
01557 }
01558
01559 fseek(data->file, filepos, SEEK_SET);
01560
01561
01562 data->numatoms = numatoms;
01563
01564 return TRUE;
01565 }
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578 static int get_coordinates(FILE *file, qm_atom_t **atoms, int unit,
01579 int *numatoms) {
01580 int i = 0;
01581 int growarray = 0;
01582
01583 if (*numatoms<0) {
01584 *atoms = (qm_atom_t*)calloc(1, sizeof(qm_atom_t));
01585 growarray = 1;
01586 }
01587
01588
01589
01590 while (1) {
01591 char buffer[BUFSIZ];
01592 char atname[BUFSIZ];
01593 float atomicnum;
01594 float x,y,z, dum;
01595 int n;
01596 qm_atom_t *atm;
01597
01598 GET_LINE(buffer, file);
01599
01600
01601
01602 n = sscanf(buffer,"%s %f %f %f %f %f",atname,&dum,&atomicnum,&x,&y,&z);
01603 if (n!=6) {
01604 n = sscanf(buffer,"%s %f %f %f %f",atname,&atomicnum,&x,&y,&z);
01605 }
01606 if (n!=5 && n!=6) break;
01607
01608 if (growarray && i>0) {
01609 *atoms = (qm_atom_t*)realloc(*atoms, (i+1)*sizeof(qm_atom_t));
01610 }
01611 atm = (*atoms)+i;
01612
01613 strncpy(atm->type, atname, sizeof(atm->type));
01614 atm->atomicnum = floor(atomicnum+0.5);
01615
01616
01617
01618 if (unit==BOHR) {
01619 x *= BOHR_TO_ANGS;
01620 y *= BOHR_TO_ANGS;
01621 z *= BOHR_TO_ANGS;
01622 }
01623
01624 atm->x = x;
01625 atm->y = y;
01626 atm->z = z;
01627 i++;
01628 }
01629
01630
01631
01632 if (*numatoms>=0 && *numatoms!=i) {
01633 (*numatoms) = i;
01634 return FALSE;
01635 }
01636
01637 (*numatoms) = i;
01638 return TRUE;
01639 }
01640
01641
01642
01643
01644
01645
01646 static int get_fmoxyz(FILE *file, qm_atom_t **atoms, int unit,
01647 int *numatoms) {
01648 int i = 0;
01649 int growarray = 0;
01650
01651 if (*numatoms<0) {
01652 *atoms = (qm_atom_t*)calloc(1, sizeof(qm_atom_t));
01653 growarray = 1;
01654 }
01655
01656
01657
01658 while (1) {
01659 char buffer[BUFSIZ];
01660 char atname[BUFSIZ], element[BUFSIZ];
01661 float x,y,z;
01662 int n;
01663 qm_atom_t *atm;
01664
01665 GET_LINE(buffer, file);
01666
01667
01668 n = sscanf(buffer+12,"%s %s %f %f %f",atname,element,&x,&y,&z);
01669
01670 if (n!=5) break;
01671
01672 if (growarray && i>0) {
01673 *atoms = (qm_atom_t*)realloc(*atoms, (i+1)*sizeof(qm_atom_t));
01674 }
01675 atm = (*atoms)+i;
01676
01677 strncpy(atm->type, atname, sizeof(atm->type));
01678 if (isalpha(element[0]))
01679 atm->atomicnum = get_pte_idx_from_string(element);
01680 else if (isdigit(element[0]))
01681 atm->atomicnum = floor(element[0]+0.5);
01682 else break;
01683
01684
01685 if (unit==BOHR) {
01686 x *= BOHR_TO_ANGS;
01687 y *= BOHR_TO_ANGS;
01688 z *= BOHR_TO_ANGS;
01689 }
01690
01691 atm->x = x;
01692 atm->y = y;
01693 atm->z = z;
01694 i++;
01695 }
01696
01697
01698
01699 if (*numatoms>=0 && *numatoms!=i) return FALSE;
01700
01701 (*numatoms) = i;
01702 return TRUE;
01703 }
01704
01705
01706
01707
01708
01709
01710
01711 static int get_contrl_firefly(qmdata_t *data) {
01712
01713 char word[3][BUFSIZ];
01714 char buffer[BUFSIZ];
01715 char *temp;
01716 long filepos;
01717 filepos = ftell(data->file);
01718
01719 word[0][0] = '\0';
01720 word[1][0] = '\0';
01721 word[2][0] = '\0';
01722 buffer[0] = '\0';
01723
01724
01725
01726
01727
01728 if (!pass_keyline(data->file, "$CONTRL OPTIONS", NULL)) {
01729 fseek(data->file, filepos, SEEK_SET);
01730 return FALSE;
01731 }
01732
01733 eatline(data->file, 1);
01734
01735
01736 GET_LINE(buffer, data->file);
01737 sscanf(buffer,"%s %s",&word[0][0],&word[1][0]);
01738
01739
01740 if (!strcmp(&word[1][0],"RUNTYP=ENERGY")) {
01741 data->runtype = MOLFILE_RUNTYPE_ENERGY;
01742 }
01743 else if (!strcmp(&word[1][0],"RUNTYP=OPTIMIZE")) {
01744 data->runtype = MOLFILE_RUNTYPE_OPTIMIZE;
01745 }
01746 else if (!strcmp(&word[1][0],"RUNTYP=SADPOINT")) {
01747 data->runtype = MOLFILE_RUNTYPE_SADPOINT;
01748 }
01749 else if (!strcmp(&word[1][0],"RUNTYP=HESSIAN")) {
01750 data->runtype = MOLFILE_RUNTYPE_HESSIAN;
01751 }
01752 else if (!strcmp(&word[1][0],"RUNTYP=SURFACE")) {
01753 data->runtype = MOLFILE_RUNTYPE_SURFACE;
01754 }
01755 else if (!strcmp(&word[1][0],"RUNTYP=GRADIENT")) {
01756 data->runtype = MOLFILE_RUNTYPE_GRADIENT;
01757 }
01758 else if (!strcmp(&word[1][0],"RUNTYP=MEX")) {
01759 data->runtype = MOLFILE_RUNTYPE_MEX;
01760 }
01761 else {
01762 #ifdef DEBUGGING
01763 printf("gamessplugin) The %s is currently not supported \n",
01764 &word[1][0]);
01765 #endif
01766 data->runtype = MOLFILE_RUNTYPE_UNKNOWN;
01767 }
01768 printf("gamessplugin) File generated via %s \n",&word[1][0]);
01769
01770
01771
01772 if (!strcmp(&word[0][0],"SCFTYP=RHF")) {
01773 data->scftype = MOLFILE_SCFTYPE_RHF;
01774 }
01775 else if (!strcmp(&word[0][0],"SCFTYP=UHF")) {
01776 data->scftype = MOLFILE_SCFTYPE_UHF;
01777 }
01778 else if (!strcmp(&word[0][0],"SCFTYP=ROHF")) {
01779 data->scftype = MOLFILE_SCFTYPE_ROHF;
01780 }
01781 else if (!strcmp(&word[0][0],"SCFTYP=GVB")) {
01782 data->scftype = MOLFILE_SCFTYPE_GVB;
01783 }
01784 else if (!strcmp(&word[0][0],"SCFTYP=MCSCF")) {
01785 data->scftype = MOLFILE_SCFTYPE_MCSCF;
01786 }
01787 else if (!strcmp(&word[0][0],"SCFTYP=NONE")) {
01788 data->scftype = MOLFILE_SCFTYPE_NONE;
01789 }
01790 else {
01791
01792
01793 printf("gamessplugin) %s is currently not supported \n",
01794 &word[0][0]);
01795 return FALSE;
01796 }
01797 printf("gamessplugin) Type of wavefunction used %s \n",
01798 &word[0][0]);
01799
01800
01801 GET_LINE(buffer, data->file);
01802 sscanf(buffer,"%s %s %*s %s",&word[0][0],&word[1][0],&word[2][0]);
01803 data->mplevel = atoi(&word[1][0]);
01804
01805
01806 GET_LINE(buffer, data->file);
01807
01808
01809
01810 while ( (temp=strstr(buffer,"COORD =")) == NULL ) {
01811 GET_LINE(buffer, data->file);;
01812 }
01813 strncpy(data->geometry, trimright(temp+7), sizeof(data->geometry));
01814 printf("gamessplugin) Coordinate type used is %s \n", data->geometry);
01815
01816 while ( (temp=strstr(buffer,"CITYP =")) == NULL ) {
01817 GET_LINE(buffer, data->file);;
01818 }
01819 strncpy(buffer, trimright(temp+7), 8);
01820
01821
01822 if (!strcmp(buffer,"NONE")) data->citype = CI_NONE;
01823 else if (!strcmp(buffer,"CIS")) data->citype = CI_CIS;
01824 else if (!strcmp(buffer,"ALDET")) data->citype = CI_ALDET;
01825 else if (!strcmp(buffer,"ORMAS")) data->citype = CI_ORMAS;
01826 else if (!strcmp(buffer,"GUGA")) data->citype = CI_GUGA;
01827 else if (!strcmp(buffer,"FSOCI")) data->citype = CI_FSOCI;
01828 else if (!strcmp(buffer,"GENCI")) data->citype = CI_GENCI;
01829 else data->citype = CI_UNKNOWN;
01830 printf("gamessplugin) CI method %s \n",buffer);
01831
01832 GET_LINE(buffer, data->file);
01833 sscanf(buffer,"%s %*s",&word[0][0]);
01834
01835
01836 if (!strncmp(&word[0][0],"DFTTYP=", 7)) {
01837 printf("gamessplugin) Density functional used is %s \n",&word[0][7]);
01838 GET_LINE(buffer, data->file);
01839 }
01840
01841
01842
01843 fseek(data->file, filepos, SEEK_SET);
01844 return TRUE;
01845 }
01846
01847
01848
01849
01850
01851
01852
01853 static int get_contrl(qmdata_t *data) {
01854
01855 char word[3][BUFSIZ];
01856 char buffer[BUFSIZ];
01857 char *temp;
01858 long filepos;
01859 filepos = ftell(data->file);
01860
01861 word[0][0] = '\0';
01862 word[1][0] = '\0';
01863 word[2][0] = '\0';
01864 buffer[0] = '\0';
01865
01866
01867
01868
01869 if (!pass_keyline(data->file, "$CONTRL OPTIONS", NULL)) {
01870 fseek(data->file, filepos, SEEK_SET);
01871 return FALSE;
01872 }
01873
01874 eatline(data->file, 1);
01875
01876
01877 GET_LINE(buffer, data->file);
01878 sscanf(buffer,"%s %s",&word[0][0],&word[1][0]);
01879
01880
01881 if (!strcmp(&word[1][0],"RUNTYP=ENERGY")) {
01882 data->runtype = MOLFILE_RUNTYPE_ENERGY;
01883 }
01884 else if (!strcmp(&word[1][0],"RUNTYP=OPTIMIZE")) {
01885 data->runtype = MOLFILE_RUNTYPE_OPTIMIZE;
01886 }
01887 else if (!strcmp(&word[1][0],"RUNTYP=SADPOINT")) {
01888 data->runtype = MOLFILE_RUNTYPE_SADPOINT;
01889 }
01890 else if (!strcmp(&word[1][0],"RUNTYP=HESSIAN")) {
01891 data->runtype = MOLFILE_RUNTYPE_HESSIAN;
01892 }
01893 else if (!strcmp(&word[1][0],"RUNTYP=SURFACE")) {
01894 data->runtype = MOLFILE_RUNTYPE_SURFACE;
01895 }
01896 else if (!strcmp(&word[1][0],"RUNTYP=GRADIENT")) {
01897 data->runtype = MOLFILE_RUNTYPE_GRADIENT;
01898 }
01899 else if (!strcmp(&word[1][0],"RUNTYP=MEX")) {
01900 data->runtype = MOLFILE_RUNTYPE_MEX;
01901 }
01902 else {
01903 #ifdef DEBUGGING
01904 printf("gamessplugin) The %s is currently not supported \n",
01905 &word[1][0]);
01906 #endif
01907 data->runtype = MOLFILE_RUNTYPE_UNKNOWN;
01908 }
01909 printf("gamessplugin) File generated via %s \n",&word[1][0]);
01910
01911
01912
01913 if (!strcmp(&word[0][0],"SCFTYP=RHF")) {
01914 data->scftype = MOLFILE_SCFTYPE_RHF;
01915 }
01916 else if (!strcmp(&word[0][0],"SCFTYP=UHF")) {
01917 data->scftype = MOLFILE_SCFTYPE_UHF;
01918 }
01919 else if (!strcmp(&word[0][0],"SCFTYP=ROHF")) {
01920 data->scftype = MOLFILE_SCFTYPE_ROHF;
01921 }
01922 else if (!strcmp(&word[0][0],"SCFTYP=GVB")) {
01923 data->scftype = MOLFILE_SCFTYPE_GVB;
01924 }
01925 else if (!strcmp(&word[0][0],"SCFTYP=MCSCF")) {
01926 data->scftype = MOLFILE_SCFTYPE_MCSCF;
01927 }
01928 else if (!strcmp(&word[0][0],"SCFTYP=NONE")) {
01929 data->scftype = MOLFILE_SCFTYPE_NONE;
01930 }
01931 else {
01932
01933
01934 printf("gamessplugin) %s is currently not supported \n",
01935 &word[0][0]);
01936 return FALSE;
01937 }
01938 printf("gamessplugin) Type of wavefunction used %s \n",
01939 &word[0][0]);
01940
01941
01942 GET_LINE(buffer, data->file);
01943 sscanf(buffer,"%s %s %*s %s",&word[0][0],&word[1][0],&word[2][0]);
01944
01945 if (!strcmp(&word[0][0],"MPLEVL=")) {
01946
01947 printf("gamessplugin) MP perturbation level %s \n",&word[1][0]);
01948 data->mplevel = atoi(&word[1][0]);
01949
01950
01951 if (!strcmp(&word[2][0],"=NONE")) data->citype = CI_NONE;
01952 else if (!strcmp(&word[2][0],"=CIS")) data->citype = CI_CIS;
01953 else if (!strcmp(&word[2][0],"=ALDET")) data->citype = CI_ALDET;
01954 else if (!strcmp(&word[2][0],"=ORMAS")) data->citype = CI_ORMAS;
01955 else if (!strcmp(&word[2][0],"=GUGA")) data->citype = CI_GUGA;
01956 else if (!strcmp(&word[2][0],"=FSOCI")) data->citype = CI_FSOCI;
01957 else if (!strcmp(&word[2][0],"=GENCI")) data->citype = CI_GENCI;
01958 else data->citype = CI_UNKNOWN;
01959 printf("gamessplugin) CI method %s \n",&word[2][1]);
01960
01961 GET_LINE(buffer, data->file);
01962 sscanf(buffer,"%s %s",&word[0][0],&word[1][0]);
01963 }
01964
01965
01966 if (!strncmp(&word[0][0],"DFTTYP=", 7)) {
01967 printf("gamessplugin) Density functional used is %s \n",&word[0][7]);
01968 GET_LINE(buffer, data->file);
01969 }
01970
01971
01972
01973 while ( (temp=strstr(buffer,"COORD =")) == NULL ) {
01974 GET_LINE(buffer, data->file);;
01975 }
01976 strncpy(data->geometry, trimright(temp+7), sizeof(data->geometry));
01977 printf("gamessplugin) Coordinate type used is %s \n", data->geometry);
01978
01979 fseek(data->file, filepos, SEEK_SET);
01980 return TRUE;
01981 }
01982
01983
01984
01985
01986
01987 static int get_properties_input(qmdata_t *data) {
01988
01989 return TRUE;
01990 }
01991
01992
01993
01994
01995
01996 static int get_symmetry(qmdata_t *data) {
01997 char buffer[BUFSIZ];
01998 char *sep, tmp[BUFSIZ];
01999
02000
02001
02002 long filepos = ftell(data->file);
02003
02004 if (goto_keyline(data->file, "THE POINT GROUP IS",
02005 "1 ELECTRON INTEGRALS", NULL) != FOUND) {
02006 printf("gamessplugin) No symmetry info found!\n");
02007 return FALSE;
02008 }
02009
02010 GET_LINE(buffer, data->file);
02011 sscanf(buffer," THE POINT GROUP IS %s", data->pointgroup);
02012
02013 sep = strchr(data->pointgroup, ',');
02014 if (sep) *sep = '\0';
02015 trimright(data->pointgroup);
02016
02017 sep = strstr(buffer, "NAXIS=") + 6;
02018 strncpy(tmp, sep, 2); tmp[2] = '\0';
02019 data->naxis = atoi(tmp);
02020
02021 sep = strstr(buffer, "ORDER=") + 6;
02022 sscanf(sep, "%d", &data->order);
02023
02024 printf("gamessplugin) Point group = %s, naxis = %d, order = %d\n",
02025 data->pointgroup, data->naxis, data->order);
02026
02027 fseek(data->file, filepos, SEEK_SET);
02028
02029 return TRUE;
02030 }
02031
02032
02033
02034 static int get_mcscf(qmdata_t *data) {
02035 gmsdata *gms = (gmsdata *)data->format_specific_data;
02036 char buffer[BUFSIZ];
02037 char *temp;
02038 long filepos;
02039 int tmp;
02040
02041 filepos = ftell(data->file);
02042
02043 if (gms->have_pcgamess){
02044 if (pass_keyline(data->file,"XMCQDPT INPUT PARAMETERS",
02045 "DONE SETTING UP THE RUN") != FOUND) {
02046
02047 if(pass_keyline(data->file, "MCSCF CALCULATION",
02048 "ITER TOTAL ENERGY") != FOUND)
02049 return FALSE;
02050
02051 if (goto_keyline(data->file, "-CORE- -INTERNAL- -EXTERNAL-",
02052 "ITER TOTAL ENERGY", NULL) != FOUND)
02053 return FALSE;
02054
02055 while ( (temp=strstr(buffer,"NFZC=")) == NULL ) {
02056 GET_LINE(buffer, data->file);
02057 }
02058 strncpy(buffer, trimright(temp+6), 5);
02059 sscanf(buffer, "%d", &data->mcscf_num_core);
02060
02061 while ( (temp=strstr(buffer,"NMCC=")) == NULL ) {
02062 GET_LINE(buffer, data->file);
02063 }
02064 strncpy(buffer, trimright(temp+6), 5);
02065 sscanf(buffer, "%d", &tmp);
02066 data-> mcscf_num_core += tmp;
02067 printf("gamessplugin) Number of MCSCF core orbitals = %d\n",
02068 data->mcscf_num_core);
02069 }
02070 else{
02071
02072 while ( (temp=strstr(buffer,"# OF FROZEN CORE ORBITALS")) == NULL ) {
02073 GET_LINE(buffer, data->file);
02074 }
02075 sscanf(buffer, "%*s %*s %*s %*s %*s %*s %d",&data->mcscf_num_core);
02076
02077 GET_LINE(buffer,data->file);
02078 sscanf(buffer, "%*s %*s %*s %*s %*s %*s %d",&tmp);
02079 data->mcscf_num_core += tmp;
02080 printf("gamessplugin) Number of MCSCF core orbitals = %d\n",
02081 data->mcscf_num_core);
02082 printf("gamessplugin) XMCQDPT2 not supported.\n");
02083
02084 data->scftype = MOLFILE_SCFTYPE_NONE;
02085
02086 }
02087 }
02088 else {
02089 if (pass_keyline(data->file, "MCSCF CALCULATION",
02090 "ITER TOTAL ENERGY") != FOUND)
02091 return FALSE;
02092
02093 if (goto_keyline(data->file, "NUMBER OF CORE ORBITALS",
02094 "ITER TOTAL ENERGY", NULL) != FOUND)
02095 return FALSE;
02096
02097 GET_LINE(buffer, data->file);
02098 sscanf(buffer," NUMBER OF CORE ORBITALS = %d",
02099 &data->mcscf_num_core);
02100
02101 printf("gamessplugin) Number of MCSCF core orbitals = %d\n",
02102 data->mcscf_num_core);
02103 }
02104
02105 fseek(data->file, filepos, SEEK_SET);
02106 return TRUE;
02107 }
02108
02109
02110
02111 static int read_first_frame(qmdata_t *data) {
02112
02113
02114
02115
02116 data->angular_momentum = (int*)calloc(3*data->wavef_size, sizeof(int));
02117
02118
02119
02120
02121 if (!get_traj_frame(data, data->atoms, data->numatoms)) {
02122 return FALSE;
02123 }
02124
02125 return TRUE;
02126 }
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139 static int get_final_properties(qmdata_t *data) {
02140 qm_timestep_t *ts;
02141 long filepos;
02142 filepos = ftell(data->file);
02143 ts = data->qm_timestep + data->num_frames-1;
02144
02145
02146 fseek(data->file, data->end_of_traj, SEEK_SET);
02147
02148 printf("gamessplugin) Reading final properties section (timestep %d):\n",
02149 data->num_frames-1);
02150 printf("gamessplugin) ===============================================\n");
02151
02152
02153
02154
02155 if (!ts->have_mulliken && get_population(data, ts)) {
02156 printf("gamessplugin) Mulliken charges found\n");
02157 }
02158
02159 if (get_esp_charges(data)) {
02160 printf("gamessplugin) ESP charges found\n");
02161 }
02162
02163 if (data->runtype == MOLFILE_RUNTYPE_GRADIENT ||
02164 data->runtype == MOLFILE_RUNTYPE_HESSIAN) {
02165 if (get_final_gradient(data, ts)) {
02166 printf("gamessplugin) Final gradient found\n");
02167 }
02168 }
02169
02170
02171 if (data->runtype == MOLFILE_RUNTYPE_HESSIAN) {
02172
02173
02174
02175
02176
02177 if (!get_int_hessian(data)) {
02178 printf("gamessplugin) No internal Hessian matrix found.\n");
02179 }
02180 if (!get_cart_hessian(data)) {
02181 printf("gamessplugin) \n");
02182 printf("gamessplugin) Could not determine the cartesian \n");
02183 printf("gamessplugin) Hessian matrix!! \n");
02184 printf("gamessplugin) \n");
02185 }
02186
02187
02188
02189 if (!get_normal_modes(data)) {
02190 printf("gamessplugin) \n");
02191 printf("gamessplugin) No normal modes found.\n");
02192 printf("gamessplugin) \n");
02193 }
02194 }
02195
02196
02197 read_localized_orbitals(data);
02198
02199
02200 fseek(data->file, filepos, SEEK_SET);
02201 return TRUE;
02202 }
02203
02204
02205
02206 static int read_localized_orbitals(qmdata_t *data) {
02207 int i;
02208 qm_timestep_t *ts;
02209 qm_wavefunction_t *wavef;
02210
02211
02212 pass_keyline(data->file, "ENERGY COMPONENTS", NULL);
02213
02214 ts = data->qm_timestep + data->num_frames-1;
02215
02216 for (i=0; i<2; i++) {
02217 wavef = add_wavefunction(ts);
02218
02219 if (get_wavefunction(data, ts, wavef) == FALSE ||
02220 (wavef->type!=MOLFILE_WAVE_BOYS &&
02221 wavef->type!=MOLFILE_WAVE_PIPEK &&
02222 wavef->type!=MOLFILE_WAVE_RUEDEN)) {
02223 del_wavefunction(ts);
02224 return FALSE;
02225 }
02226 else {
02227 char typestr[64];
02228 if (wavef->spin==SPIN_ALPHA) {
02229 strcpy(typestr, "alpha");
02230 }
02231 else if (wavef->spin==SPIN_BETA) {
02232 strcpy(typestr, "beta");
02233 }
02234 wavef->mult = data->multiplicity;
02235 wavef->energy = ts->scfenergies[ts->num_scfiter-1];
02236
02237 printf("gamessplugin) Localized orbitals (%s) found for timestep %d\n",
02238 typestr, data->num_frames-1);
02239 }
02240 }
02241
02242 return TRUE;
02243 }
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254 static int get_basis_stats(qmdata_t *data) {
02255
02256 gmsdata *gms = (gmsdata *)data->format_specific_data;
02257
02258 char buffer[BUFSIZ];
02259 char word[7][BUFSIZ];
02260 int i;
02261
02262 buffer[0] = '\0';
02263 for (i=0; i<7; i++) word[i][0] = '\0';
02264
02265
02266 if(gms->have_pcgamess){
02267 if (!pass_keyline(data->file, "TOTAL NUMBER OF SHELLS", NULL)){
02268 printf("ERROR!\n");
02269 return FALSE;
02270 }
02271
02272 GET_LINE(buffer, data->file);
02273 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %d",
02274 &(data->wavef_size));
02275
02276
02277 GET_LINE(buffer, data->file);
02278 sscanf(buffer,"%*s %*s %*s %*s %d",
02279 &(data->num_electrons));
02280
02281
02282 GET_LINE(buffer, data->file);
02283 sscanf(buffer,"%*s %*s %*s %*s %d",
02284 &(data->totalcharge));
02285
02286
02287
02288
02289
02290
02291
02292 GET_LINE(buffer, data->file);
02293 sscanf(buffer,"%*s %*s %*s %d",
02294 &(data->multiplicity));
02295
02296
02297
02298
02299 GET_LINE(buffer, data->file);
02300 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %d",
02301 &(data->num_occupied_A));
02302
02303
02304 GET_LINE(buffer, data->file);
02305 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %*s %d",
02306 &(data->num_occupied_B));
02307
02308 }
02309 else {
02310 if (!pass_keyline(data->file, "TOTAL NUMBER OF BASIS", NULL))
02311 return FALSE;
02312
02313
02314 GET_LINE(buffer, data->file);
02315 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %*s %d",
02316 &(data->wavef_size));
02317
02318
02319 GET_LINE(buffer, data->file);
02320 sscanf(buffer,"%*s %*s %*s %*s %d",
02321 &(data->num_electrons));
02322
02323
02324 GET_LINE(buffer, data->file);
02325 sscanf(buffer,"%*s %*s %*s %*s %d",
02326 &(data->totalcharge));
02327
02328
02329
02330
02331
02332
02333
02334 GET_LINE(buffer, data->file);
02335 sscanf(buffer,"%*s %*s %*s %d",
02336 &(data->multiplicity));
02337
02338
02339
02340
02341 GET_LINE(buffer, data->file);
02342 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %d",
02343 &(data->num_occupied_A));
02344
02345
02346 GET_LINE(buffer, data->file);
02347 sscanf(buffer,"%*s %*s %*s %*s %*s %*s %*s %d",
02348 &(data->num_occupied_B));
02349 }
02350
02351
02352 printf("gamessplugin) Number of Electrons: %d \n",
02353 data->num_electrons);
02354
02355 printf("gamessplugin) Charge of Molecule : %d \n",
02356 data->totalcharge);
02357
02358 printf("gamessplugin) Multiplicity of Wavefunction: %d \n",
02359 data->multiplicity);
02360
02361 printf("gamessplugin) Number of occupied A / B orbitals: %d / %d \n",\
02362 data->num_occupied_A, data->num_occupied_B);
02363
02364 printf("gamessplugin) Number of gaussian basis functions: %d \n",\
02365 data->wavef_size);
02366
02367
02368 return TRUE;
02369 }
02370
02371
02372
02373
02374
02375
02376
02377
02378 static int get_guess_options(qmdata_t *data)
02379 {
02380 char word[BUFSIZ];
02381 char buffer[BUFSIZ];
02382 long filepos;
02383 filepos = ftell(data->file);
02384
02385
02386 buffer[0] = '\0';
02387 word[0] = '\0';
02388
02389
02390 if (pass_keyline(data->file, "GUESS OPTIONS",
02391 "2 ELECTRON INTEGRALS") != FOUND) {
02392 printf("gamessplugin) No GUESS OPTIONS found.\n");
02393 fseek(data->file, filepos, SEEK_SET);
02394
02395
02396
02397
02398 return TRUE;
02399 }
02400
02401
02402 eatline(data->file, 1);
02403 GET_LINE(buffer, data->file);
02404 sscanf(buffer," GUESS %s NORB",&word[0]);
02405
02406
02407 strncpy(data->guess,&word[1], sizeof(data->guess));
02408
02409 printf("gamessplugin) Run was performed with GUESS = %s \n",
02410 data->guess);
02411
02412
02413
02414 fseek(data->file, filepos, SEEK_SET);
02415
02416 return TRUE;
02417 }
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427 int get_basis(qmdata_t *data) {
02428
02429 gmsdata *gms = (gmsdata *)data->format_specific_data;
02430
02431 char buffer[BUFSIZ];
02432 char word[4][BUFSIZ];
02433 int i = 0;
02434 int success = 0;
02435 int numread, numshells;
02436 shell_t *shell;
02437 long filepos;
02438
02439 if (!strcmp(data->gbasis, "MNDO") ||
02440 !strcmp(data->gbasis, "AM1") ||
02441 !strcmp(data->gbasis, "PM3")) {
02442
02443
02444
02445
02446
02447
02448 return TRUE;
02449 }
02450
02451
02452 if (pass_keyline(data->file, "ATOMIC BASIS SET",
02453 "$CONTRL OPTIONS") !=FOUND ) {
02454 printf("gamessplugin) No basis set found!\n");
02455
02456 return FALSE;
02457 }
02458
02459
02460 buffer[0] = '\0';
02461 for (i=0; i<3; i++) word[i][0] = '\0';
02462
02463
02464
02465 eatline(data->file, 5);
02466
02467
02468
02469
02470 data->basis_set = (basis_atom_t*)calloc(data->numatoms, sizeof(basis_atom_t));
02471
02472
02473 i = 0;
02474
02475 do {
02476 prim_t *prim = NULL;
02477 char shelltype;
02478 int numprim = 0;
02479 int icoeff = 0;
02480 filepos = ftell(data->file);
02481 GET_LINE(buffer, data->file);
02482
02483
02484 numread = sscanf(buffer,"%s %s %s %s",&word[0][0], &word[1][0],
02485 &word[2][0], &word[3][0]);
02486
02487 switch (numread) {
02488 case 1:
02489
02490 strcpy(data->basis_set[i].name, &word[0][0]);
02491
02492
02493 eatline(data->file, 1);
02494
02495
02496 shell = (shell_t*)calloc(1, sizeof(shell_t));
02497 numshells = 0;
02498
02499 do {
02500 filepos = ftell(data->file);
02501 numprim = read_shell_primitives(data, &prim, &shelltype, icoeff, gms->have_pcgamess);
02502
02503 if (numprim>0) {
02504
02505 if ( (shelltype!='S' && shelltype!='L' && shelltype!='P' &&
02506 shelltype!='D' && shelltype!='F' && shelltype!='G') ) {
02507 printf("gamessplugin) WARNING ... %c shells are not supported \n", shelltype);
02508 }
02509
02510
02511 if (numshells) {
02512 shell = (shell_t*)realloc(shell, (numshells+1)*sizeof(shell_t));
02513 }
02514 shell[numshells].numprims = numprim;
02515
02516 shell[numshells].type = shelltype_int(shelltype);
02517 shell[numshells].prim = prim;
02518 data->num_basis_funcs += numprim;
02519
02520
02521
02522
02523 if (shelltype=='L' && !icoeff) {
02524 fseek(data->file, filepos, SEEK_SET);
02525 icoeff++;
02526 } else if (shelltype=='L' && icoeff) {
02527 shell[numshells].type = SP_P_SHELL;
02528 icoeff = 0;
02529 }
02530
02531 numshells++;
02532 }
02533 } while (numprim);
02534
02535
02536 data->basis_set[i].numshells = numshells;
02537 data->basis_set[i].shell = shell;
02538
02539
02540 data->num_shells += numshells;
02541 i++;
02542
02543
02544
02545 fseek(data->file, filepos, SEEK_SET);
02546
02547 break;
02548
02549 case 4:
02550
02551 if(gms->have_pcgamess){
02552 if (!strcmp(&word[0][0],"TOTAL") &&
02553 !strcmp(&word[1][0],"NUMBER") &&
02554 !strcmp(&word[2][0],"OF") &&
02555 !strcmp(&word[3][0],"SHELLS")) {
02556 success = 1;
02557
02558
02559 fseek(data->file, filepos, SEEK_SET);
02560 }
02561 }
02562 else {
02563 if (!strcmp(&word[0][0],"TOTAL") &&
02564 !strcmp(&word[1][0],"NUMBER") &&
02565 !strcmp(&word[2][0],"OF") &&
02566 !strcmp(&word[3][0],"BASIS")) {
02567 success = 1;
02568
02569
02570 fseek(data->file, filepos, SEEK_SET);
02571 }
02572 }
02573 break;
02574 }
02575
02576 } while (!success);
02577
02578
02579 printf("gamessplugin) Parsed %d uncontracted basis functions for %d atoms.\n",
02580 data->num_basis_funcs, i);
02581
02582 data->num_basis_atoms = i;
02583
02584
02585
02586 return fill_basis_arrays(data);
02587 }
02588
02589
02590
02591
02592
02593
02594
02595 static int shelltype_int(char type) {
02596 int shelltype;
02597
02598 switch (type) {
02599 case 'L':
02600
02601 shelltype = SP_S_SHELL;
02602 break;
02603 case 'S':
02604 shelltype = S_SHELL;
02605 break;
02606 case 'P':
02607 shelltype = P_SHELL;
02608 break;
02609 case 'D':
02610 shelltype = D_SHELL;
02611 break;
02612 case 'F':
02613 shelltype = F_SHELL;
02614 break;
02615 case 'G':
02616 shelltype = G_SHELL;
02617 break;
02618 default:
02619 shelltype = UNK_SHELL;
02620 break;
02621 }
02622
02623 return shelltype;
02624 }
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634 static int fill_basis_arrays(qmdata_t *data) {
02635 gmsdata *gms = (gmsdata *)data->format_specific_data;
02636 int i, j, k;
02637 int shellcount = 0;
02638 int primcount = 0;
02639
02640 float *basis;
02641 int *num_shells_per_atom;
02642 int *num_prim_per_shell;
02643 int *shell_types;
02644 int *atomicnum_per_basisatom;
02645
02646
02647
02648 for(i=0; i<data->num_basis_atoms; i++) {
02649 for (j=0; j<data->basis_set[i].numshells; j++) {
02650 primcount += data->basis_set[i].shell[j].numprims;
02651 }
02652 }
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662 basis = (float *)calloc(2*primcount,sizeof(float));
02663
02664
02665 if (basis == NULL) {
02666 PRINTERR;
02667 return FALSE;
02668 }
02669
02670 shell_types = (int *)calloc(data->num_shells, sizeof(int));
02671
02672
02673 if (shell_types == NULL) {
02674 PRINTERR;
02675 return FALSE;
02676 }
02677
02678 num_shells_per_atom = (int *)calloc(data->num_basis_atoms, sizeof(int));
02679
02680
02681 if (num_shells_per_atom == NULL) {
02682 PRINTERR;
02683 return FALSE;
02684 }
02685
02686 num_prim_per_shell = (int *)calloc(data->num_shells, sizeof(int));
02687
02688
02689 if (num_prim_per_shell == NULL) {
02690 PRINTERR;
02691 return FALSE;
02692 }
02693
02694 atomicnum_per_basisatom = (int *)calloc(data->num_basis_atoms, sizeof(int));
02695
02696
02697 if (atomicnum_per_basisatom == NULL) {
02698 PRINTERR;
02699 return FALSE;
02700 }
02701
02702
02703
02704 data->basis = basis;
02705 data->shell_types = shell_types;
02706 data->num_shells_per_atom = num_shells_per_atom;
02707 data->num_prim_per_shell = num_prim_per_shell;
02708 data->atomicnum_per_basisatom = atomicnum_per_basisatom;
02709
02710
02711
02712
02713
02714
02715
02716 primcount = 0;
02717 for (i=0; i<data->num_basis_atoms; i++) {
02718 int found = 0;
02719
02720
02721
02722 for(j=0; j<data->numatoms; j++) {
02723 char basisname[BUFSIZ];
02724 strcpy(basisname, data->basis_set[i].name);
02725
02726
02727
02728 if (gms->have_fmo) {
02729 *strchr(basisname, '-') = '\0';
02730 }
02731
02732 if (!strcmp(data->atoms[j].type, basisname)) {
02733 found = 1;
02734 break;
02735 }
02736 }
02737 if (!found) {
02738 printf("gamessplugin) WARNING: Couldn't find atomic number for basis set atom %s\n",
02739 data->basis_set[i].name);
02740 data->basis_set[i].atomicnum = 0;
02741 atomicnum_per_basisatom[i] = 0;
02742 } else {
02743
02744 data->basis_set[i].atomicnum = data->atoms[j].atomicnum;
02745 atomicnum_per_basisatom[i] = data->atoms[j].atomicnum;
02746 }
02747 num_shells_per_atom[i] = data->basis_set[i].numshells;
02748
02749 for (j=0; j<data->basis_set[i].numshells; j++) {
02750 shell_types[shellcount] = data->basis_set[i].shell[j].type;
02751 num_prim_per_shell[shellcount] = data->basis_set[i].shell[j].numprims;
02752
02753 for (k=0; k<data->basis_set[i].shell[j].numprims; k++) {
02754 basis[2*primcount ] = data->basis_set[i].shell[j].prim[k].exponent;
02755 basis[2*primcount+1] = data->basis_set[i].shell[j].prim[k].contraction_coeff;
02756 primcount++;
02757 }
02758 shellcount++;
02759 }
02760 }
02761
02762 return TRUE;
02763 }
02764
02765
02766
02767
02768
02769
02770
02771 static int read_shell_primitives(qmdata_t *data, prim_t **prim, char *shelltype,
02772 int icoeff, int pcgamess) {
02773 char buffer[BUFSIZ];
02774 float exponent = 0.0;
02775 float contract[2] = {0.0, 0.0};
02776 int shell, success;
02777 int primcounter = 0;
02778 (*prim) = (prim_t*)calloc(1, sizeof(prim_t));
02779
02780 do {
02781 GET_LINE(buffer, data->file);
02782 if (pcgamess)
02783 success = sscanf(buffer,"%d %c %*s %f %f %*s %*s %f", &shell,
02784 shelltype,
02785 &exponent, &contract[0], &contract[1]);
02786
02787 else
02788 success = sscanf(buffer,"%d %c %*s %f %f %f", &shell,
02789 shelltype,
02790 &exponent, &contract[0], &contract[1]);
02791
02792
02793 switch (success) {
02794 case 4:
02795 if (primcounter) {
02796 *prim = (prim_t*)realloc(*prim, (primcounter+1)*sizeof(prim_t));
02797 }
02798
02799
02800 (*prim)[primcounter].exponent = exponent;
02801
02802
02803 (*prim)[primcounter].contraction_coeff = contract[0];
02804
02805 primcounter++;
02806 break;
02807
02808 case 5:
02809 if (primcounter) {
02810 *prim = (prim_t*)realloc(*prim, (primcounter+1)*sizeof(prim_t));
02811 }
02812
02813
02814 (*prim)[primcounter].exponent = exponent;
02815
02816
02817 (*prim)[primcounter].contraction_coeff = contract[icoeff];
02818
02819 primcounter++;
02820 break;
02821
02822 case -1:
02823
02824 break;
02825
02826 case 1:
02827
02828 success = -1;
02829 break;
02830 }
02831
02832 } while(success>0);
02833
02834 if (!primcounter) free(*prim);
02835
02836 return primcounter;
02837 }
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847 static int get_traj_frame(qmdata_t *data, qm_atom_t *atoms,
02848 int natoms) {
02849 gmsdata *gms = (gmsdata *)data->format_specific_data;
02850 qm_timestep_t *cur_ts;
02851 char buffer[BUFSIZ];
02852 char word[BUFSIZ];
02853 int units;
02854 buffer[0] = '\0';
02855 word[0] = '\0';
02856
02857 printf("gamessplugin) Timestep %d:\n", data->num_frames_read);
02858 printf("gamessplugin) ============\n");
02859
02860 fseek(data->file, data->filepos_array[data->num_frames_read], SEEK_SET);
02861
02862
02863 if (data->runtype==MOLFILE_RUNTYPE_OPTIMIZE ||
02864 data->runtype==MOLFILE_RUNTYPE_SADPOINT) {
02865 goto_keyline(data->file, "COORDINATES OF ALL ATOMS", NULL);
02866
02867 GET_LINE(buffer, data->file);
02868 sscanf(buffer, " COORDINATES OF ALL ATOMS ARE %s", word);
02869 units = !strcmp(word, "(BOHR)");
02870 eatline(data->file, 2);
02871
02872 if (!get_coordinates(data->file, &data->atoms, units, &natoms)) {
02873 printf("gamessplugin) Couldn't find coordinates for timestep %d\n", data->num_frames_read);
02874 }
02875 }
02876 else if (data->runtype==MOLFILE_RUNTYPE_SURFACE) {
02877 if (pass_keyline(data->file, "HAS ENERGY VALUE",
02878 "...... END OF ONE-ELECTRON INTEGRALS ......")
02879 == FOUND) {
02880
02881
02882 int i, n;
02883 for (i=0; i<natoms; i++) {
02884 char atname[BUFSIZ];
02885 float x,y,z;
02886 GET_LINE(buffer, data->file);
02887 n = sscanf(buffer,"%s %f %f %f", atname, &x,&y,&z);
02888 if (n!=4 || strcmp(atname, data->atoms[i].type)) break;
02889 data->atoms[i].x = x;
02890 data->atoms[i].y = y;
02891 data->atoms[i].z = z;
02892 }
02893 if (i!=natoms) {
02894 printf("gamessplugin) Couldn't read surface mapping geometry for timestep %d\n", data->num_frames_read);
02895 }
02896 }
02897 else {
02898
02899
02900 goto_keyline(data->file, "ATOM ATOMIC", NULL);
02901
02902 GET_LINE(buffer, data->file);
02903 sscanf(buffer, " ATOM ATOMIC COORDINATES %s", word);
02904 units = !strcmp(word, "(BOHR)");
02905 eatline(data->file, 1);
02906
02907 if (!get_coordinates(data->file, &data->atoms, units, &natoms)) {
02908 printf("gamessplugin) Couldn't find coordinates for timestep %d\n", data->num_frames_read);
02909 }
02910 }
02911 }
02912
02913 else if (data->runtype==MOLFILE_RUNTYPE_MEX) {
02914 int numuniqueatoms = natoms;
02915 goto_keyline(data->file, "COORDINATES OF SYMMETRY UNIQUE ATOMS", NULL);
02916
02917 GET_LINE(buffer, data->file);
02918 sscanf(buffer, " COORDINATES OF SYMMETRY UNIQUE ATOMS ARE %s", word);
02919 units = !strcmp(word, "(BOHR)");
02920 eatline(data->file, 2);
02921 if (!get_coordinates(data->file, &data->atoms, units, &numuniqueatoms)) {
02922 printf("gamessplugin) Expanding symmetry unique coordinates for timestep %d\n", data->num_frames_read);
02923
02924
02925
02926 symmetry_expand(&data->atoms, numuniqueatoms, natoms,
02927 data->pointgroup, data->naxis);
02928 }
02929 }
02930
02931
02932
02933
02934
02935
02936
02937 if (gms->have_fmo) {
02938 data->num_frames_read++;
02939 return TRUE;
02940 }
02941
02942
02943 cur_ts = data->qm_timestep + data->num_frames_read;
02944
02945
02946 if (get_scfdata(data, cur_ts) == FALSE) {
02947 printf("gamessplugin) Couldn't find SCF iterations for timestep %d\n",
02948 data->num_frames_read);
02949 }
02950
02951
02952 check_add_wavefunctions(data, cur_ts);
02953
02954
02955
02956
02957
02958
02959 if (!cur_ts->have_mulliken &&
02960 get_population(data, cur_ts)) {
02961 printf("gamessplugin) Mulliken/Loewdin charges found\n");
02962 }
02963
02964 if (data->citype==CI_GUGA) {
02965 if (pass_keyline(data->file, "CI DENSITY MATRIX AND NATURAL ORBITALS",
02966 "GRADIENT (HARTREE/BOHR)")) {
02967 int i, numstates=0, state;
02968 qm_wavefunction_t *wave_ci;
02969 goto_keyline(data->file, "NUMBER OF STATES", NULL);
02970 GET_LINE(buffer, data->file);
02971 trimleft(buffer);
02972 sscanf(buffer, " NUMBER OF STATES = %d", &numstates);
02973 printf("gamessplugin) Number of CI states = %d\n", numstates);
02974
02975 for (i=0; i<numstates; i++) {
02976 float cienergy = 0.f;
02977 goto_keyline(data->file, "CI EIGENSTATE", NULL);
02978 GET_LINE(buffer, data->file);
02979 sscanf(buffer," CI EIGENSTATE %d %*s %*s %*s %f", &state, &cienergy);
02980 printf("gamessplugin) CI energy[%d] = %f\n", state-1, cienergy);
02981
02982 wave_ci = add_wavefunction(cur_ts);
02983
02984 if (get_wavefunction(data, cur_ts, wave_ci) == FALSE) {
02985 del_wavefunction(cur_ts);
02986 break;
02987 }
02988 else {
02989
02990 wave_ci->exci = state-1;
02991 wave_ci->energy = cienergy;
02992 wave_ci->mult = data->multiplicity;
02993
02994 printf("gamessplugin) Found %d CI natural orbitals for excited state %d, mult=%d\n",
02995 wave_ci->num_orbitals, state-1, wave_ci->mult);
02996 }
02997 }
02998 }
02999 }
03000 else if (data->citype==CI_CIS) {
03001 if (pass_keyline(data->file,
03002 "USING DAVIDSON ALGORITHM TO FIND CIS EIGENVALUES",
03003 NULL)) {
03004 int i, numstates=0, state;
03005 qm_wavefunction_t *wave_ci;
03006 float *state_energies, *state_spinquant;
03007 goto_keyline(data->file, "NUMBER OF STATES REQUESTED", NULL);
03008 GET_LINE(buffer, data->file);
03009 trimleft(buffer);
03010 sscanf(buffer, " NUMBER OF STATES REQUESTED = %d", &numstates);
03011 printf("gamessplugin) Number of CIS states = %d\n", numstates);
03012
03013
03014
03015
03016
03017 state_energies = calloc(numstates+1, sizeof(float));
03018 state_spinquant = calloc(numstates+1, sizeof(float));
03019 goto_keyline(data->file, "RHF REFERENCE ENERGY =", NULL);
03020 GET_LINE(buffer, data->file);
03021 trimleft(buffer);
03022 sscanf(buffer, " RHF REFERENCE ENERGY = %f", &state_energies[0]);
03023 state_spinquant[0] = 1.f;
03024
03025 for (i=1; i<=numstates; i++) {
03026 goto_keyline(data->file, "EXCITED STATE", NULL);
03027 GET_LINE(buffer, data->file);
03028 trimleft(buffer);
03029 sscanf(buffer, " EXCITED STATE %*d ENERGY= %f S = %f",
03030 &state_energies[i], &state_spinquant[i]);
03031 }
03032
03033 goto_keyline(data->file,
03034 "CIS NATURAL ORBITAL OCCUPATION NUMBERS FOR EXCITED STATE",
03035 NULL);
03036 GET_LINE(buffer, data->file);
03037 trimleft(buffer);
03038 sscanf(buffer,
03039 " CIS NATURAL ORBITAL OCCUPATION NUMBERS FOR EXCITED STATE %d",
03040 &state);
03041
03042 wave_ci = add_wavefunction(cur_ts);
03043
03044 if (get_wavefunction(data, cur_ts, wave_ci) == FALSE) {
03045 del_wavefunction(cur_ts);
03046 }
03047 else {
03048 wave_ci->exci = state;
03049 wave_ci->energy = state_energies[state];
03050 wave_ci->mult = 2*(int)state_spinquant[state]+1;
03051 printf("gamessplugin) Found %d CIS natural orbitals for excited state %d\n",
03052 wave_ci->num_orbitals, state);
03053 }
03054
03055 free(state_energies);
03056 free(state_spinquant);
03057 }
03058 }
03059
03060
03061
03062 if (get_gradient(data, cur_ts)) {
03063 printf("gamessplugin) Energy gradient found.\n");
03064 }
03065
03066
03067
03068
03069
03070 if ((data->runtype == MOLFILE_RUNTYPE_OPTIMIZE ||
03071 data->runtype == MOLFILE_RUNTYPE_SADPOINT) &&
03072 (data->num_frames_read+1 == data->num_frames &&
03073 (data->status == MOLFILE_QMSTATUS_UNKNOWN ||
03074 data->status == MOLFILE_QMSTATUS_OPT_CONV ||
03075 data->status == MOLFILE_QMSTATUS_OPT_NOT_CONV))) {
03076
03077
03078
03079
03080 if (data->status == MOLFILE_QMSTATUS_OPT_CONV ||
03081 data->status == MOLFILE_QMSTATUS_OPT_NOT_CONV) {
03082 fseek(data->file, data->end_of_traj, SEEK_SET);
03083 }
03084
03085
03086
03087
03088
03089
03090 check_add_wavefunctions(data, cur_ts);
03091 }
03092
03093
03094
03095
03096
03097
03098
03099 if (cur_ts->numwave>=2 &&
03100 cur_ts->wave[cur_ts->numwave-1].type==MOLFILE_WAVE_MCSCFOPT &&
03101 cur_ts->wave[cur_ts->numwave-2].type==MOLFILE_WAVE_MCSCFNAT) {
03102 int i;
03103 qm_wavefunction_t *waveopt = &cur_ts->wave[cur_ts->numwave-1];
03104 qm_wavefunction_t *wavenat = &cur_ts->wave[cur_ts->numwave-2];
03105 waveopt->orb_occupancies = (float *)calloc(waveopt->num_orbitals,
03106 sizeof(float));
03107
03108
03109
03110 for (i=0; i<wavenat->num_orbitals; i++) {
03111 waveopt->orb_occupancies[i] = wavenat->orb_occupancies[i];
03112 }
03113 for (i=wavenat->num_orbitals; i<waveopt->num_orbitals; i++) {
03114 waveopt->orb_occupancies[i] = 0.f;
03115 }
03116 waveopt->has_occup = TRUE;
03117 }
03118
03119
03120 data->num_frames_read++;
03121
03122 return TRUE;
03123 }
03124
03125
03126
03127
03128
03129
03130
03131 static int analyze_traj(qmdata_t *data, gmsdata *gms) {
03132 char buffer[BUFSIZ], nserch[BUFSIZ];
03133 char *line;
03134 long filepos;
03135 filepos = ftell(data->file);
03136
03137 data->filepos_array = (long* )calloc(1, sizeof(long ));
03138
03139 if (data->runtype==MOLFILE_RUNTYPE_OPTIMIZE ||
03140 data->runtype==MOLFILE_RUNTYPE_SADPOINT) {
03141 pass_keyline(data->file,
03142 "PARAMETERS CONTROLLING GEOMETRY SEARCH", NULL);
03143 eatline(data->file, 2);
03144
03145 GET_LINE(buffer, data->file);
03146 sscanf(buffer, "NSTEP = %d", &data->max_opt_steps);
03147 eatline(data->file, 3);
03148 GET_LINE(buffer, data->file);
03149 sscanf(buffer, "OPTTOL = %f", &data->opt_tol);
03150
03151
03152
03153
03154
03155 }
03156 else if (data->runtype==MOLFILE_RUNTYPE_SURFACE) {
03157 if (pass_keyline(data->file,
03158 "POTENTIAL SURFACE MAP INPUT", NULL)) {
03159
03160 int coord1[2];
03161 int mplevel1=-1, mplevel2=-1, nstep1;
03162 float origin1, disp1;
03163 char runtype1[BUFSIZ], runtype2[BUFSIZ];
03164 char scftype1[BUFSIZ], scftype2[BUFSIZ];
03165 char dfttype1[BUFSIZ], dfttype2[BUFSIZ];
03166 char citype1[BUFSIZ], citype2[BUFSIZ];
03167 char cctype1[BUFSIZ], cctype2[BUFSIZ];
03168 char *tmp;
03169 int n;
03170
03171 eatline(data->file, 1);
03172
03173 GET_LINE(buffer, data->file);
03174 n=sscanf(buffer, " JOB 1 IS RUNTYP=%s SCFTYP=%s CITYP=%s",
03175 runtype1, scftype1, citype1);
03176 if (n==3) {
03177 GET_LINE(buffer, data->file);
03178 sscanf(buffer, " MPLEVL= %d CCTYP=%s, DFTTYP=%s\n",
03179 &mplevel1, dfttype1, cctype1);
03180 GET_LINE(buffer, data->file);
03181 }
03182 n=sscanf(buffer, " JOB 2 IS RUNTYP=%s SCFTYP=%s CITYP=%s",
03183 runtype2, scftype2, citype2);
03184 if (n==3) {
03185 GET_LINE(buffer, data->file);
03186 sscanf(buffer, " MPLEVL= %d CCTYP=%s, DFTTYP=%s\n",
03187 &mplevel2, dfttype2, cctype2);
03188 GET_LINE(buffer, data->file);
03189 }
03190
03191 sscanf(buffer, " COORD 1 LYING ALONG ATOM PAIR %d %d",
03192 coord1, coord1+1);
03193 GET_LINE(buffer, data->file);
03194 tmp = strstr(buffer, "ORIGIN=") + 7;
03195 sscanf(tmp, "%f", &origin1);
03196 tmp = strstr(buffer, "DISPLACEMENT=") + 13;
03197 sscanf(tmp, "%f", &disp1);
03198 tmp = strstr(buffer, "AND") + 3;
03199 sscanf(tmp, "%d STEPS.", &nstep1);
03200 printf("gamessplugin) origin=%f, displacement=%f nstep=%d\n", origin1, disp1, nstep1);
03201 }
03202 }
03203 else if (data->runtype==MOLFILE_RUNTYPE_MEX) {
03204 char scftype1[BUFSIZ];
03205 char scftype2[BUFSIZ];
03206 rewind(data->file);
03207 if (!pass_keyline(data->file, "$MEX OPTIONS", NULL)) {
03208 printf("gamessplugin) No $MEX OPTIONS found!\n");
03209 return FALSE;
03210 }
03211 eatline(data->file, 2);
03212 GET_LINE(buffer, data->file);
03213 sscanf(strstr(buffer, "SCF1 =")+7, "%s", scftype1);
03214 sscanf(strstr(buffer, "SCF2 =")+7, "%s", scftype2);
03215 printf("gamessplugin) MEX SCF1=%s SCF2=%s\n", scftype1, scftype2);
03216
03217 }
03218 else {
03219
03220 data->num_frames = 1;
03221 pass_keyline(data->file, "1 ELECTRON INTEGRALS",
03222 "ENERGY COMPONENTS");
03223 data->filepos_array[0] = ftell(data->file);
03224
03225
03226 if (pass_keyline(data->file,
03227 "SCF IS UNCONVERGED, TOO MANY ITERATIONS",
03228 "ENERGY COMPONENTS")==FOUND) {
03229 printf("gamessplugin) SCF IS UNCONVERGED, TOO MANY ITERATIONS\n");
03230 data->status = MOLFILE_QMSTATUS_SCF_NOT_CONV;
03231 } else {
03232 data->status = MOLFILE_QMSTATUS_OPT_CONV;
03233 fseek(data->file, data->filepos_array[0], SEEK_SET);
03234 }
03235
03236 pass_keyline(data->file, "ENERGY COMPONENTS", NULL);
03237 data->end_of_traj = ftell(data->file);
03238
03239
03240 data->qm_timestep = (qm_timestep_t *)calloc(1, sizeof(qm_timestep_t));
03241 memset(data->qm_timestep, 0, sizeof(qm_timestep_t));
03242
03243 return TRUE;
03244 }
03245
03246 printf("gamessplugin) Analyzing trajectory...\n");
03247 data->status = MOLFILE_QMSTATUS_UNKNOWN;
03248
03249 while (1) {
03250 if (!fgets(buffer, sizeof(buffer), data->file)) break;
03251 line = trimleft(buffer);
03252
03253
03254
03255
03256
03257 if (gms->version==FIREFLY8POST6695){
03258 strcpy(nserch, "NSERCH=");
03259 }
03260 else if (gms->version==FIREFLY8PRE6695) {
03261 strcpy(nserch, "1NSERCH=");
03262 }
03263 else if (gms->version==GAMESSPRE20050627) {
03264 strcpy(nserch, "1NSERCH=");
03265 }
03266 else if (gms->version==GAMESSPOST20050627) {
03267 strcpy(nserch, "BEGINNING GEOMETRY SEARCH POINT NSERCH=");
03268 }
03269
03270 if (strstr(line, nserch) ||
03271 strstr(line, "---- SURFACE MAPPING GEOMETRY") ||
03272 strstr(line, "MINIMUM ENERGY CROSSING POINT SEARCH") ||
03273 (data->runtype==MOLFILE_RUNTYPE_MEX && strstr(line, "NSERCH=")==line)) {
03274 printf("gamessplugin) %s", line);
03275
03276 if (data->num_frames > 0) {
03277 data->filepos_array = (long*)realloc(data->filepos_array,
03278 (data->num_frames+1)*sizeof(long));
03279 }
03280 data->filepos_array[data->num_frames] = ftell(data->file);
03281 if (data->runtype==MOLFILE_RUNTYPE_SURFACE) {
03282 int ret = goto_keyline(data->file,
03283 "ATOM ATOMIC", "HAS ENERGY VALUE",
03284 "---- SURFACE MAPPING GEOMETRY ----", NULL);
03285 if (ret>0 && ret<3 &&
03286 (have_keyline(data->file, "...... END OF ONE-ELECTRON INTEGRALS ......",
03287 "---- SURFACE MAPPING GEOMETRY ----") ||
03288 have_keyline(data->file, "... DONE WITH POTENTIAL SURFACE SCAN",
03289 "---- SURFACE MAPPING GEOMETRY ----"))) {
03290 data->num_frames++;
03291 }
03292 }
03293 else if (pass_keyline(data->file, "COORDINATES OF",
03294 "BEGINNING GEOMETRY SEARCH POINT NSERCH=")==FOUND)
03295 {
03296
03297
03298 if (have_keyline(data->file, "INTERNUCLEAR DISTANCES",
03299 "1 ELECTRON INTEGRALS") ||
03300 have_keyline(data->file, "1 ELECTRON INTEGRALS",
03301 "BEGINNING GEOMETRY SEARCH POINT NSERCH=")) {
03302 data->num_frames++;
03303 }
03304 }
03305 }
03306 else if (strstr(line, "***** EQUILIBRIUM GEOMETRY LOCATED") ||
03307 strstr(line, "... DONE WITH POTENTIAL SURFACE SCAN")) {
03308 printf("gamessplugin) ==== End of trajectory (%d frames) ====\n",
03309 data->num_frames);
03310 data->status = MOLFILE_QMSTATUS_OPT_CONV;
03311 break;
03312 }
03313 else if (strstr(line, "***** FAILURE TO LOCATE STATIONARY POINT,")) {
03314 printf("gamessplugin) %s\n", line);
03315 if (strstr(strchr(line, ','), "SCF HAS NOT CONVERGED")) {
03316 data->status = MOLFILE_QMSTATUS_SCF_NOT_CONV;
03317 break;
03318 }
03319 else if (strstr(strchr(line, ','), "TOO MANY STEPS TAKEN")) {
03320 data->status = MOLFILE_QMSTATUS_OPT_NOT_CONV;
03321 break;
03322 }
03323 }
03324 }
03325
03326 data->end_of_traj = ftell(data->file);
03327 fseek(data->file, filepos, SEEK_SET);
03328
03329 if (data->status == MOLFILE_QMSTATUS_UNKNOWN) {
03330
03331
03332
03333 data->status = MOLFILE_QMSTATUS_FILE_TRUNCATED;
03334 }
03335
03336
03337
03338 data->qm_timestep = (qm_timestep_t *)calloc(data->num_frames,
03339 sizeof(qm_timestep_t));
03340 memset(data->qm_timestep, 0, data->num_frames*sizeof(qm_timestep_t));
03341
03342
03343 if (data->status == MOLFILE_QMSTATUS_SCF_NOT_CONV ||
03344 data->status == MOLFILE_QMSTATUS_FILE_TRUNCATED) {
03345 return FALSE;
03346 }
03347
03348 return TRUE;
03349 }
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367 static int get_scfdata(qmdata_t *data, qm_timestep_t *ts) {
03368 char buffer[BUFSIZ];
03369 char word[3][BUFSIZ];
03370 long filepos;
03371 int i, epos = -1;
03372 int numread, numiter=0, dum, dum2;
03373 char *line;
03374 float dumf;
03375 filepos = ftell(data->file);
03376
03377 for (i=0; i<3; i++) word[i][0] = '\0';
03378
03379 if (!goto_keyline(data->file, "ITER EX", "ITER TOTAL",
03380 "ITER TOTAL", NULL)) {
03381 fseek(data->file, filepos, SEEK_SET);
03382 ts->num_scfiter = 0;
03383 return FALSE;
03384 }
03385
03386
03387 GET_LINE(buffer, data->file);
03388 numread = sscanf(buffer, "%*s %s %s %s",
03389 &word[0][0], &word[1][0], &word[2][0]);
03390 for (i=0; i<numread; i++) {
03391 if (!strcmp(&word[i][0], "TOTAL")) epos = i+1;
03392 }
03393
03394 if (epos<0) {
03395 fseek(data->file, filepos, SEEK_SET);
03396 ts->num_scfiter = 0;
03397 return FALSE;
03398 }
03399
03400
03401
03402 filepos = ftell(data->file);
03403
03404
03405 do {
03406 GET_LINE(buffer, data->file);
03407 line = trimleft(buffer);
03408 numread = sscanf(line,"%d %d %*d %*f", &dum, &dum2);
03409 if (numread==2) numiter++;
03410 } while (strlen(line)>2);
03411
03412 printf("gamessplugin) %d SCF iterations\n", numiter);
03413
03414
03415 fseek(data->file, filepos, SEEK_SET);
03416
03417
03418
03419 ts->scfenergies = (double *)calloc(numiter,sizeof(double));
03420
03421 i=0;
03422 do {
03423 GET_LINE(buffer, data->file);
03424 line = trimleft(buffer);
03425 numread = sscanf(line,"%d %f %*i %*f", &dum, &dumf);
03426 if (numread==2) {
03427 switch (epos) {
03428 case 1:
03429 sscanf(buffer,"%*d %lf", ts->scfenergies+i);
03430 break;
03431 case 2:
03432 sscanf(buffer,"%*d %*d %lf", ts->scfenergies+i);
03433 break;
03434 case 3:
03435 sscanf(buffer,"%*d %*d %*d %lf", ts->scfenergies+i);
03436 break;
03437 }
03438 i++;
03439 }
03440 } while (strlen(line)>2);
03441
03442 #if 0
03443 for (i=0; i<numiter; i++) {
03444 printf("scfenergies[%d] = %f\n", i, ts->scfenergies[i]);
03445 }
03446 #endif
03447
03448 ts->num_scfiter = numiter;
03449
03450 return TRUE;
03451 }
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462 static int check_add_wavefunctions(qmdata_t *data,
03463 qm_timestep_t *ts) {
03464 qm_wavefunction_t *wavef;
03465 int i, n=1;
03466
03467 if (data->scftype==MOLFILE_SCFTYPE_UHF ||
03468 data->scftype==MOLFILE_SCFTYPE_GVB ||
03469 data->scftype==MOLFILE_SCFTYPE_MCSCF) {
03470
03471
03472 n = 2;
03473 }
03474
03475 for (i=0; i<n; i++) {
03476
03477 wavef = add_wavefunction(ts);
03478
03479
03480 if (get_wavefunction(data, ts, wavef) == FALSE) {
03481
03482 del_wavefunction(ts);
03483 #ifdef DEBUGGING
03484 printf("gamessplugin) No canonical wavefunction present for timestep %d\n", data->num_frames_read);
03485 #endif
03486 break;
03487
03488 } else {
03489 char action[32];
03490 char spinstr[32];
03491 strcpy(spinstr, "");
03492 if (data->scftype==MOLFILE_SCFTYPE_UHF) {
03493 if (wavef->spin==SPIN_BETA) {
03494 strcat(spinstr, "spin beta, ");
03495 } else {
03496 strcat(spinstr, "spin alpha, ");
03497 }
03498 }
03499
03500
03501 if (ts->scfenergies) {
03502 wavef->energy = ts->scfenergies[ts->num_scfiter-1];
03503 } else {
03504 wavef->energy = 0.f;
03505 }
03506
03507
03508 wavef->mult = data->multiplicity;
03509
03510
03511
03512
03513 strcpy(action, "added");
03514
03515
03516
03517 if (ts->numwave>1 && wavef->type==MOLFILE_WAVE_CANON) {
03518 int i, found =-1;
03519 for (i=0; i<ts->numwave-1; i++) {
03520 if (ts->wave[i].type==wavef->type &&
03521 ts->wave[i].spin==wavef->spin &&
03522 ts->wave[i].exci==wavef->exci &&
03523 !strncmp(ts->wave[i].info, wavef->info, MOLFILE_BUFSIZ)) {
03524 found = i;
03525 break;
03526 }
03527 }
03528 if (found>=0) {
03529
03530
03531 if (wavef->num_orbitals >
03532 ts->wave[found].num_orbitals) {
03533
03534 replace_wavefunction(ts, found);
03535 sprintf(action, "%d updated", found);
03536 } else {
03537
03538 del_wavefunction(ts);
03539 sprintf(action, "matching %d ignored", found);
03540 }
03541 wavef = &ts->wave[ts->numwave-1];
03542 }
03543 }
03544
03545 printf("gamessplugin) Wavefunction %s (%s):\n", action, wavef->info);
03546 printf("gamessplugin) %d orbitals, %sexcitation %d, multiplicity %d\n",
03547 wavef->num_orbitals, spinstr, wavef->exci, wavef->mult);
03548 }
03549 }
03550
03551 return i;
03552 }
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562 static int get_wavefunction(qmdata_t *data, qm_timestep_t *ts,
03563 qm_wavefunction_t *wf)
03564 {
03565 float *orb_enocc;
03566 float *wave_coeff;
03567 char buffer[BUFSIZ];
03568 char word[6][BUFSIZ];
03569 int num_orbitals = 0;
03570 int i = 0, num_values = 0;
03571 long filepos;
03572 char *line;
03573 int have_orbenocc = 0;
03574 int n[5];
03575
03576 buffer[0] = '\0';
03577 for (i=0; i<6; i++) word[i][0] = '\0';
03578
03579 if (wf == NULL) {
03580 PRINTERR;
03581 return FALSE;
03582 }
03583
03584 wf->has_occup = FALSE;
03585 wf->has_orben = FALSE;
03586 wf->type = MOLFILE_WAVE_UNKNOWN;
03587 wf->spin = SPIN_ALPHA;
03588 wf->exci = 0;
03589 strncpy(wf->info, "unknown", MOLFILE_BUFSIZ);
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609
03610
03611
03612
03613
03614
03615
03616
03617
03618
03619
03620
03621 filepos = ftell(data->file);
03622
03623 do {
03624 GET_LINE(buffer, data->file);
03625
03626 line = trimleft(trimright(buffer));
03627
03628 if (!strcmp(line, "----- ALPHA SET -----")) {
03629 wf->type = MOLFILE_WAVE_CANON;
03630 strncpy(wf->info, "canonical", MOLFILE_BUFSIZ);
03631 pass_keyline(data->file, "EIGENVECTORS", NULL);
03632 }
03633 else if (!strcmp(line, "----- BETA SET -----")) {
03634 wf->type = MOLFILE_WAVE_CANON;
03635 wf->spin = SPIN_BETA;
03636 strncpy(wf->info, "canonical", MOLFILE_BUFSIZ);
03637 pass_keyline(data->file, "EIGENVECTORS", NULL);
03638 }
03639 else if (!strcmp(line, "****** BETA ORBITAL LOCALIZATION *****")) {
03640 wf->spin = SPIN_BETA;
03641 }
03642 else if (!strcmp(line, "EIGENVECTORS")) {
03643 wf->type = MOLFILE_WAVE_CANON;
03644 strncpy(wf->info, "canonical", MOLFILE_BUFSIZ);
03645 }
03646 else if (!strcmp(line, "MOLECULAR ORBITALS")) {
03647 wf->type = MOLFILE_WAVE_CANON;
03648 strncpy(wf->info, "canonical", MOLFILE_BUFSIZ);
03649 }
03650 else if (!strcmp(line, "THE BOYS LOCALIZED ORBITALS ARE")) {
03651 wf->type = MOLFILE_WAVE_BOYS;
03652 strncpy(wf->info, "Boys localized", MOLFILE_BUFSIZ);
03653 }
03654 else if (!strcmp(line, "THE PIPEK-MEZEY POPULATION LOCALIZED ORBITALS ARE")) {
03655 wf->type = MOLFILE_WAVE_PIPEK;
03656 strncpy(wf->info, "Pipek-Mezey localized", MOLFILE_BUFSIZ);
03657 }
03658 else if (!strcmp(line, "EDMISTON-RUEDENBERG ENERGY LOCALIZED ORBITALS")) {
03659 wf->type = MOLFILE_WAVE_RUEDEN;
03660 strncpy(wf->info, "Ruedenberg localized", MOLFILE_BUFSIZ);
03661 }
03662 else if (!strcmp(line, "GI ORBITALS")) {
03663 wf->type = MOLFILE_WAVE_GEMINAL;
03664 strncpy(wf->info, "GVB geminal pairs", MOLFILE_BUFSIZ);
03665 }
03666 else if (!strcmp(line, "MCSCF NATURAL ORBITALS")) {
03667 wf->type = MOLFILE_WAVE_MCSCFNAT;
03668 strncpy(wf->info, "MCSCF natural orbitals", MOLFILE_BUFSIZ);
03669 }
03670 else if (!strcmp(line, "MCSCF OPTIMIZED ORBITALS")) {
03671 wf->type = MOLFILE_WAVE_MCSCFOPT;
03672 strncpy(wf->info, "MCSCF optimized orbitals", MOLFILE_BUFSIZ);
03673 }
03674 else if (!strcmp(line, "NATURAL ORBITALS IN ATOMIC ORBITAL BASIS")) {
03675 wf->type = MOLFILE_WAVE_CINATUR;
03676 strncpy(wf->info, "CI natural orbitals", MOLFILE_BUFSIZ);
03677 }
03678 else if (!strcmp(line, "CIS NATURAL ORBITALS")) {
03679 wf->type = MOLFILE_WAVE_CINATUR;
03680 strncpy(wf->info, "CIS natural orbitals", MOLFILE_BUFSIZ);
03681 }
03682
03683 else if (!strcmp(line, "-MCHF- NATURAL ORBITALS")) {
03684 wf->type = MOLFILE_WAVE_MCSCFNAT;
03685 strncpy(wf->info, "MCSCF natural orbitals", MOLFILE_BUFSIZ);
03686 }
03687 else if (!strcmp(line, "-MCHF- OPTIMIZED ORBITALS")) {
03688 wf->type = MOLFILE_WAVE_MCSCFOPT;
03689 strncpy(wf->info, "MCSCF optimized orbitals", MOLFILE_BUFSIZ);
03690 }
03691 else if (!strcmp(line, "ZERO-ORDER QDPT NATURAL ORBITALS")){
03692
03693 }
03694
03695 } while(wf->type==MOLFILE_WAVE_UNKNOWN &&
03696 strcmp(line, "ENERGY COMPONENTS") &&
03697 strcmp(line, "***** EQUILIBRIUM GEOMETRY LOCATED *****") &&
03698 strcmp(line, "**** THE GEOMETRY SEARCH IS NOT CONVERGED! ****"));
03699
03700
03701
03702
03703 if (wf->type==MOLFILE_WAVE_UNKNOWN) {
03704 #ifdef DEBUGGING
03705 printf("gamessplugin) get_wavefunction(): No wavefunction found!\n");
03706 #endif
03707 fseek(data->file, filepos, SEEK_SET);
03708 return FALSE;
03709 }
03710
03711
03712
03713
03714 wave_coeff = (float *)calloc(data->wavef_size*data->wavef_size,
03715 sizeof(float));
03716
03717
03718 if (wave_coeff == NULL) {
03719 PRINTERR;
03720 return FALSE;
03721 }
03722
03723
03724 orb_enocc = (float *)calloc(data->wavef_size, sizeof(float));
03725
03726
03727 if (orb_enocc == NULL) {
03728 free(orb_enocc);
03729 PRINTERR;
03730 return FALSE;
03731 }
03732
03733
03734
03735 wf->wave_coeffs = wave_coeff;
03736
03737
03738
03739 if (wf->type == MOLFILE_WAVE_CINATUR ||
03740 wf->type == MOLFILE_WAVE_MCSCFNAT) {
03741 wf->orb_occupancies = orb_enocc;
03742 wf->has_occup = TRUE;
03743 } else {
03744 wf->orb_energies = orb_enocc;
03745 wf->has_orben = TRUE;
03746 }
03747
03748
03749 eatline(data->file, 1);
03750
03751
03752 while (1) {
03753 int nr, over=0;
03754 float coeff[5], enocc[5];
03755
03756 if (wf->type == MOLFILE_WAVE_GEMINAL) {
03757
03758 pass_keyline(data->file, "PAIR ", NULL);
03759 }
03760
03761 eatwhitelines(data->file);
03762 filepos = ftell(data->file);
03763
03764
03765 GET_LINE(buffer, data->file);
03766 num_values = sscanf(buffer, "%d %d %d %d %d",
03767 &n[0], &n[1], &n[2], &n[3], &n[4]);
03768
03769
03770
03771 if (!num_values) {
03772 fseek(data->file, filepos, SEEK_SET);
03773 break;
03774 }
03775
03776 eatwhitelines(data->file);
03777
03778
03779 filepos = ftell(data->file);
03780 GET_LINE(buffer, data->file);
03781 have_orbenocc = sscanf(buffer,"%f %f %f %f %f", &enocc[0],
03782 &enocc[1], &enocc[2], &enocc[3], &enocc[4]);
03783
03784
03785 nr = sscanf(buffer, " 1 %*s 1 %*s %f %f %f %f %f",
03786 &coeff[0], &coeff[1], &coeff[2], &coeff[3], &coeff[4]);
03787 if (nr==num_values) have_orbenocc = 0;
03788
03789 if (have_orbenocc) {
03790
03791
03792 for(i=0; i<num_values; i++) {
03793 orb_enocc[i] = enocc[i];
03794 }
03795
03796
03797
03798
03799 if (wf->type == MOLFILE_WAVE_MCSCFNAT &&
03800 orb_enocc == wf->orb_occupancies &&
03801 enocc[0] <= 0.f) {
03802 wf->orb_occupancies = NULL;
03803 wf->has_occup = FALSE;
03804 wf->orb_energies = orb_enocc;
03805 wf->has_orben = TRUE;
03806 }
03807
03808
03809 orb_enocc = orb_enocc+5;
03810 }
03811 else {
03812
03813 fseek(data->file, filepos, SEEK_SET);
03814 }
03815
03816 num_orbitals += num_values;
03817
03818
03819 filepos = ftell(data->file);
03820 while (fgets(buffer, sizeof(buffer), data->file)) {
03821 trimleft(buffer);
03822 if (strstr(line, "ENERGY COMPONENTS") ||
03823 strstr(line, "---") ||
03824 strstr(line, "...")) {
03825 over = 1; break;
03826 }
03827
03828 nr = sscanf(buffer, " 1 %*s 1 %*s %f %f %f %f %f",
03829 &coeff[0], &coeff[1], &coeff[2], &coeff[3], &coeff[4]);
03830 if (nr==num_values) break;
03831 filepos = ftell(data->file);
03832 }
03833 fseek(data->file, filepos, SEEK_SET);
03834
03835 if (over) break;
03836
03837
03838
03839
03840 if (!read_coeff_block(data->file, data->wavef_size,
03841 wave_coeff, data->angular_momentum)) {
03842 printf("gamessplugin) Wavefunction coefficient block truncated or ill formatted!\n");
03843 data->status = MOLFILE_QMSTATUS_FILE_TRUNCATED;
03844 return FALSE;
03845 }
03846
03847
03848
03849 if (wf->type == MOLFILE_WAVE_GEMINAL) {
03850 wave_coeff = wave_coeff + 2*data->wavef_size;
03851 } else {
03852 wave_coeff = wave_coeff + 5*data->wavef_size;
03853 }
03854 }
03855
03856
03857 if (!num_orbitals) {
03858 printf("gamessplugin) No orbitals in wavefunction!\n");
03859 return FALSE;
03860 }
03861
03862
03863 if (data->wavef_size!=num_orbitals) {
03864
03865 if (wf->has_occup) {
03866 wf->orb_occupancies = (float *)realloc(wf->orb_occupancies,
03867 num_orbitals*sizeof(float));
03868 }
03869 if (wf->has_orben) {
03870 wf->orb_energies = (float *)realloc(wf->orb_energies,
03871 num_orbitals*sizeof(float));
03872 }
03873
03874 wf->wave_coeffs = (float *)realloc(wf->wave_coeffs, data->wavef_size*
03875 num_orbitals*sizeof(float));
03876 }
03877
03878
03879
03880
03881
03882
03883 if (wf->type == MOLFILE_WAVE_MCSCFNAT &&
03884 wf->has_orben == TRUE ) {
03885 wf->orb_occupancies = (float *)calloc(num_orbitals, sizeof(float));
03886
03887 for (i=0; i<data->mcscf_num_core; i++) {
03888 wf->orb_occupancies[i] = 2.f;
03889 }
03890
03891 for (i=data->mcscf_num_core; i<num_orbitals; i++) {
03892 wf->orb_occupancies[i] = wf->orb_energies[i];
03893 wf->orb_energies[i] = 0.f;
03894 }
03895
03896 wf->has_occup = TRUE;
03897 }
03898
03899
03900
03901 wf->num_orbitals = num_orbitals;
03902
03903 return TRUE;
03904 }
03905
03906
03907
03908
03909
03910
03911
03912
03913 static int read_coeff_block(FILE *file, int wavef_size,
03914 float *wave_coeff, int *angular_momentum) {
03915 int i, j;
03916 int truncated = 0;
03917 char buffer[BUFSIZ];
03918
03919
03920
03921 for (i=0; i<wavef_size; i++) {
03922 char type[BUFSIZ];
03923 float coeff[5];
03924 int num_values = 0;
03925
03926 GET_LINE(buffer, file);
03927
03928
03929
03930 num_values = sscanf(buffer,"%*5i%*4s%*2i%4s %f %f %f %f %f",
03931 type, &coeff[0], &coeff[1], &coeff[2],
03932 &coeff[3], &coeff[4]);
03933
03934 if (num_values==0) {
03935
03936 truncated = 1;
03937 break;
03938 }
03939
03940 angular_momentum_expon(&angular_momentum[3*i], type);
03941
03942
03943
03944
03945 for (j=0 ; j<num_values-1; j++) {
03946 wave_coeff[j*wavef_size+i] = coeff[j];
03947 }
03948 }
03949
03950 if (truncated) return 0;
03951
03952 return 1;
03953 }
03954
03955
03956
03957
03958 static int get_population(qmdata_t *data, qm_timestep_t *ts) {
03959 int i;
03960 char buffer[BUFSIZ];
03961 long filepos;
03962 ts->have_mulliken = FALSE;
03963 ts->have_lowdin = FALSE;
03964 filepos = ftell(data->file);
03965
03966 if (pass_keyline(data->file,
03967 "TOTAL MULLIKEN AND LOWDIN ATOMIC POPULATIONS",
03968 "NSERCH=") != FOUND) {
03969 fseek(data->file, filepos, SEEK_SET);
03970 return FALSE;
03971 }
03972
03973
03974 ts->mulliken_charges =
03975 (double *)calloc(data->numatoms, sizeof(double));
03976
03977 if (!ts->mulliken_charges) {
03978 PRINTERR;
03979 return FALSE;
03980 }
03981
03982 ts->lowdin_charges =
03983 (double *)calloc(data->numatoms, sizeof(double));
03984
03985 if (!ts->lowdin_charges) {
03986 free(ts->mulliken_charges);
03987 ts->mulliken_charges = NULL;
03988 PRINTERR;
03989 return FALSE;
03990 }
03991
03992 eatline(data->file, 1);
03993
03994 for (i=0; i<data->numatoms; i++) {
03995 int n;
03996 float mullpop, mullcharge, lowpop, lowcharge;
03997 GET_LINE(buffer, data->file);
03998 n = sscanf(buffer,"%*i %*s %f %f %f %f",
03999 &mullpop, &mullcharge, &lowpop, &lowcharge);
04000 if (n!=4) {
04001 free(ts->mulliken_charges);
04002 free(ts->lowdin_charges);
04003 ts->mulliken_charges = NULL;
04004 ts->lowdin_charges = NULL;
04005 return FALSE;
04006 }
04007 ts->mulliken_charges[i] = mullcharge;
04008 ts->lowdin_charges[i] = lowcharge;
04009 }
04010
04011 if (i!=data->numatoms) {
04012 free(ts->mulliken_charges);
04013 free(ts->lowdin_charges);
04014 ts->mulliken_charges = NULL;
04015 ts->lowdin_charges = NULL;
04016 return FALSE;
04017 }
04018
04019 ts->have_mulliken = TRUE;
04020 ts->have_lowdin = TRUE;
04021 return TRUE;
04022 }
04023
04024
04025
04026
04027
04028
04029
04030 static int get_esp_charges(qmdata_t *data) {
04031 int i;
04032 char buffer[BUFSIZ];
04033 long filepos;
04034
04035 qm_timestep_t *ts = &data->qm_timestep[data->num_frames-1];
04036
04037 ts->have_esp = FALSE;
04038 filepos = ftell(data->file);
04039
04040 if (pass_keyline(data->file,
04041 "ATOM CHARGE E.S.D.",
04042 "...... END OF PROPERTY EVALUATION ") != FOUND) {
04043 fseek(data->file, filepos, SEEK_SET);
04044 return FALSE;
04045 }
04046
04047
04048 ts->esp_charges =
04049 (double *)calloc(data->numatoms, sizeof(double));
04050
04051 if (ts->esp_charges == NULL) {
04052 PRINTERR;
04053 return FALSE;
04054 }
04055
04056 eatline(data->file, 1);
04057
04058 for (i=0; i<data->numatoms; i++) {
04059 int n;
04060 double charge;
04061 GET_LINE(buffer, data->file);
04062 n = sscanf(buffer,"%*s %lf ", &charge);
04063 if (n!=1) return FALSE;
04064 ts->esp_charges[i] = charge;
04065 }
04066
04067 if (i!=data->numatoms) {
04068
04069 return FALSE;
04070 }
04071
04072 ts->have_esp = TRUE;
04073 return TRUE;
04074 }
04075
04076
04077
04078 static int get_gradient(qmdata_t *data, qm_timestep_t *ts) {
04079 int numgrad=0;
04080 int numread;
04081 char buffer[BUFSIZ];
04082 long filepos;
04083
04084 buffer[0] = '\0';
04085
04086
04087 filepos = ftell(data->file);
04088
04089
04090 if (goto_keyline(data->file, "GRADIENT (HARTREE",
04091 "***** EQUILIBRIUM GEOMETRY LOCATED",
04092 " BEGINNING GEOMETRY SEARCH", NULL) != FOUND) {
04093 fseek(data->file, filepos, SEEK_SET);
04094 return FALSE;
04095 }
04096
04097 eatline(data->file, 4);
04098
04099 ts->gradient = (float *)calloc(3*data->numatoms, sizeof(float));
04100
04101 if (ts->gradient == NULL) {
04102 PRINTERR;
04103 fseek(data->file, filepos, SEEK_SET);
04104 return FALSE;
04105 }
04106
04107
04108 do {
04109 int i;
04110 float dx, dy, dz;
04111 GET_LINE(buffer, data->file);
04112 numread = sscanf(buffer, "%d %*s %*f %f %f %f", &i, &dx, &dy, &dz);
04113 if (numread==4) {
04114 ts->gradient[3*(i-1) ] = dx;
04115 ts->gradient[3*(i-1)+1] = dy;
04116 ts->gradient[3*(i-1)+2] = dz;
04117 numgrad++;
04118 }
04119 } while(numread==4);
04120
04121 if (numgrad!=data->numatoms) {
04122 printf("gamessplugin) Found %d gradients for %d atoms!\n",
04123 numgrad, data->numatoms);
04124 fseek(data->file, filepos, SEEK_SET);
04125 return FALSE;
04126 }
04127
04128 return TRUE;
04129 }
04130
04131
04132
04133
04134 static int get_final_gradient(qmdata_t *data, qm_timestep_t *ts) {
04135 int numgrad=0;
04136 int numread;
04137 char buffer[BUFSIZ];
04138 long filepos;
04139
04140
04141 filepos = ftell(data->file);
04142
04143 if (pass_keyline(data->file,
04144 "ATOM E'X", NULL) != FOUND) {
04145 fseek(data->file, filepos, SEEK_SET);
04146 return FALSE;
04147 }
04148
04149 ts->gradient = (float *)calloc(3*data->numatoms, sizeof(float));
04150
04151 if (ts->gradient == NULL) {
04152 PRINTERR;
04153 fseek(data->file, filepos, SEEK_SET);
04154 return FALSE;
04155 }
04156
04157
04158 do {
04159 int i;
04160 float dx, dy, dz;
04161 GET_LINE(buffer, data->file);
04162 numread = sscanf(buffer, "%d %*s %f %f %f", &i, &dx, &dy, &dz);
04163 if (numread==4) {
04164 ts->gradient[3*(i-1) ] = dx;
04165 ts->gradient[3*(i-1)+1] = dy;
04166 ts->gradient[3*(i-1)+2] = dz;
04167 numgrad++;
04168 }
04169 } while(numread==4);
04170
04171
04172 fseek(data->file, filepos, SEEK_SET);
04173
04174 if (numgrad!=data->numatoms) {
04175 printf("gamessplugin) Number of gradients != number of atoms!\n");
04176 return FALSE;
04177 }
04178
04179 return TRUE;
04180 }
04181
04182
04183
04184
04185
04186
04187
04188 static int get_normal_modes(qmdata_t *data) {
04189 char buffer[BUFSIZ];
04190 int i = 0, k = 0, j = 0;
04191 double entry[6];
04192 char *token;
04193
04194 if (!pass_keyline(data->file, "NORMAL COORDINATE ANALYSIS", NULL)) {
04195 return FALSE;
04196 }
04197
04198
04199 memset(entry, 0, sizeof(entry));
04200
04201
04202
04203 data->wavenumbers =
04204 (float *)calloc(data->numatoms*3,sizeof(float));
04205 if (data->wavenumbers==NULL) {
04206 PRINTERR;
04207 return FALSE;
04208 }
04209
04210 data->intensities =
04211 (float *)calloc(data->numatoms*3,sizeof(float));
04212 if (data->intensities==NULL) {
04213 PRINTERR;
04214 return FALSE;
04215 }
04216
04217 data->imag_modes =
04218 (int *)calloc(data->numatoms*3,sizeof(int));
04219 if (data->imag_modes==NULL) {
04220 PRINTERR;
04221 return FALSE;
04222 }
04223
04224 data->normal_modes =
04225 (float *)calloc((data->numatoms*3)*(data->numatoms*3),
04226 sizeof(float));
04227 if (data->normal_modes==NULL) {
04228 PRINTERR;
04229 return FALSE;
04230 }
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241
04242
04243 for (i=0; i<ceil(data->numatoms*3/5.f); i++) {
04244 int numread = 0;
04245
04246 if (!goto_keyline(data->file, "FREQUENCY:", NULL)) {
04247 break;
04248 }
04249 GET_LINE(buffer, data->file);
04250
04251
04252
04253
04254
04255
04256
04257 token = strtok(buffer, " \t\r\n");
04258
04259
04260 while ((token = strtok(NULL, " \t\r\n")) != NULL) {
04261
04262
04263 if (*token=='I') {
04264 data->imag_modes[data->nimag] = numread-1;
04265 data->nimag++;
04266 } else {
04267
04268
04269
04270 if (numread<5) {
04271 data->wavenumbers[i*5+numread] = atof(token);
04272 numread++;
04273 }
04274 }
04275 }
04276
04277 eatline(data->file, 1);
04278
04279
04280 GET_LINE(buffer, data->file);
04281 numread = sscanf(buffer,"%*s %*s %lf %lf %lf %lf %lf", &entry[0],
04282 &entry[1], &entry[2], &entry[3], &entry[4]);
04283
04284 for (k=0; k<numread; k++) {
04285 data->intensities[i*5+k] = entry[k];
04286 }
04287
04288 eatline(data->file, 1);
04289
04290
04291 for (k=0; k<data->numatoms; k++) {
04292
04293 GET_LINE(buffer, data->file);
04294 numread = sscanf(buffer,"%*s %*s %*s %lf %lf %lf %lf %lf",
04295 &entry[0], &entry[1], &entry[2], &entry[3], &entry[4]);
04296
04297 for (j=0; j<numread; j++) {
04298 data->normal_modes[3*k + (i*5+j)*3*data->numatoms] =
04299 entry[j];
04300 }
04301
04302
04303 GET_LINE(buffer, data->file);
04304 numread = sscanf(buffer,"%*s %lf %lf %lf %lf %lf", &entry[0],
04305 &entry[1],&entry[2], &entry[3],&entry[4]);
04306
04307 for (j=0; j<numread; j++) {
04308 data->normal_modes[(3*k+1) + (i*5+j)*3*data->numatoms] =
04309 entry[j];
04310 }
04311
04312
04313 GET_LINE(buffer, data->file);
04314 numread = sscanf(buffer,"%*s %lf %lf %lf %lf %lf", &entry[0],
04315 &entry[1], &entry[2], &entry[3],&entry[4]);
04316
04317 for (j=0; j<numread; j++) {
04318 data->normal_modes[(3*k+2) + (i*5+j)*3*data->numatoms] =
04319 entry[j];
04320 }
04321 }
04322 }
04323
04324
04325
04326 data->imag_modes =
04327 (int *)realloc(data->imag_modes, data->nimag*sizeof(int));
04328
04329
04330
04331 data->have_normal_modes = TRUE;
04332 printf("gamessplugin) Successfully scanned normal modes (%d imag.)\n", data->nimag);
04333
04334 return TRUE;
04335 }
04336
04337
04338
04339
04340
04341
04342
04343
04344
04345 static int get_cart_hessian(qmdata_t *data)
04346 {
04347 char buffer[BUFSIZ];
04348 int i,j,k;
04349 float entry[6];
04350
04351 buffer[0] = '\0';
04352 memset(entry, 0, sizeof(entry));
04353
04354
04355
04356
04357
04358 rewind(data->file);
04359
04360 if (pass_keyline(data->file,
04361 "CARTESIAN FORCE CONSTANT MATRIX",
04362 NULL) != FOUND) {
04363 return FALSE;
04364 }
04365
04366
04367 eatline(data->file, 5);
04368
04369
04370
04371
04372
04373
04374 data->carthessian =
04375 (double *)calloc((data->numatoms*3)*(data->numatoms*3),
04376 sizeof(double));
04377
04378
04379
04380 if (data->carthessian == NULL) {
04381 PRINTERR;
04382 return FALSE;
04383 }
04384
04385
04386
04387
04388
04389
04390 for (i=0; i<(int)ceil(data->numatoms/2.f); i++) {
04391 for (j=0; j<(data->numatoms*3)-(i*6); j++) {
04392 GET_LINE(buffer, data->file);
04393
04394 if (j%3==0) {
04395 sscanf(buffer,"%*s %*s %*c %f %f %f %f %f %f",
04396 &entry[0],&entry[1],
04397 &entry[2],&entry[3],&entry[4],&entry[5]);
04398 }
04399 else {
04400 sscanf(buffer,"%*1s %f %f %f %f %f %f",
04401 &entry[0],&entry[1],&entry[2],&entry[3],&entry[4],
04402 &entry[5]);
04403 }
04404
04405
04406
04407
04408 for (k=0; k<=(j<5 ? j : 5); k++) {
04409 data->carthessian[(j+i*6)*3*data->numatoms + (k+i*6)] =
04410 entry[k];
04411 }
04412 }
04413
04414
04415 eatline(data->file, 4);
04416 }
04417
04418 printf("gamessplugin) Scanned Hessian in CARTESIAN coordinates\n");
04419
04420 data->have_cart_hessian = TRUE;
04421
04422 return TRUE;
04423 }
04424
04425
04426
04427
04428
04429
04430
04431
04432
04433 static int get_int_coords(qmdata_t *data) {
04434
04435 char word[BUFSIZ];
04436 char buffer[BUFSIZ];
04437 long filepos, beginning;
04438 int first, second, third, fourth;
04439 double value;
04440 int n, i = 0, j = 0, k = 0, l = 0;
04441
04442
04443 beginning = ftell(data->file);
04444
04445 if (pass_keyline(data->file, "INTERNAL COORDINATES",
04446 "1 ELECTRON INTEGRALS") != FOUND) {
04447 printf("gamessplugin) No internal coordinates found.\n");
04448 fseek(data->file, beginning, SEEK_SET);
04449 return FALSE;
04450 }
04451
04452
04453 eatline(data->file, 5);
04454
04455
04456 filepos = ftell(data->file);
04457
04458
04459 GET_LINE(buffer, data->file);
04460 n = sscanf(buffer,"%*s %s", word);
04461
04462
04463 while (n!=-1) {
04464
04465 data->nintcoords++;
04466
04467
04468 if (!strcmp(word,"STRETCH")) {
04469 data->nbonds++;
04470 }
04471 else if (!strcmp(word,"BEND")) {
04472 data->nangles++;
04473 }
04474 else if (!strcmp(word,"TORSION")) {
04475 data->ndiheds++;
04476 }
04477 else if (!strcmp(word,"PLA.BEND")) {
04478 data->nimprops++;
04479 }
04480
04481
04482 GET_LINE(buffer, data->file);
04483 n = sscanf(buffer,"%*s %s", word);
04484 }
04485
04486
04487
04488 fseek(data->file, filepos, SEEK_SET);
04489
04490
04491
04492
04493 data->bonds = (int *)calloc(2*data->nbonds,sizeof(int));
04494 data->angles = (int *)calloc(3*data->nangles,sizeof(int));
04495 data->dihedrals = (int *)calloc(4*data->ndiheds,sizeof(int));
04496 data->impropers = (int *)calloc(4*data->nimprops,sizeof(int));
04497 data->internal_coordinates = (double *)calloc(data->nintcoords,
04498 sizeof(double));
04499
04500
04501
04502 if ( (data->bonds == NULL) ||
04503 (data->angles == NULL) ||
04504 (data->dihedrals == NULL) ||
04505 (data->internal_coordinates == NULL))
04506 {
04507 PRINTERR;
04508 return FALSE;
04509 }
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519 for (i=0; i<data->nbonds; i++) {
04520 GET_LINE(buffer, data->file);
04521 sscanf(buffer,"%*s %*s %d %d %lf", &first, &second, &value);
04522
04523 *(data->bonds+2*i) = first;
04524 *(data->bonds+2*i+1) = second;
04525 *(data->internal_coordinates+i) = value;
04526 }
04527
04528
04529 for (j=0; j<data->nangles; j++) {
04530 GET_LINE(buffer, data->file);
04531 sscanf(buffer,"%*s %*s %d %d %d %lf",
04532 &first, &second, &third, &value);
04533
04534 *(data->angles+3*j) = first;
04535 *(data->angles+3*j+1) = second;
04536 *(data->angles+3*j+2) = third;
04537 *(data->internal_coordinates+i+j) = value;
04538 }
04539
04540
04541 for (k=0; k<data->ndiheds; k++) {
04542 GET_LINE(buffer, data->file);
04543 sscanf(buffer,"%*s %*s %d %d %d %d %lf",
04544 &first, &second, &third, &fourth, &value);
04545
04546 *(data->dihedrals+4*k) = first;
04547 *(data->dihedrals+4*k+1) = second;
04548 *(data->dihedrals+4*k+2) = third;
04549 *(data->dihedrals+4*k+3) = fourth;
04550 *(data->internal_coordinates+i+j+k) = value;
04551 }
04552
04553
04554 for (l=0; l<data->nimprops; l++) {
04555 GET_LINE(buffer, data->file);
04556 sscanf(buffer,"%*s %*s %d %d %d %d %lf",
04557 &first, &second, &third, &fourth, &value);
04558
04559 *(data->impropers+4*l) = first;
04560 *(data->impropers+4*l+1) = second;
04561 *(data->impropers+4*l+2) = third;
04562 *(data->impropers+4*l+3) = fourth;
04563 *(data->internal_coordinates+i+j+k+l) = value;
04564 }
04565
04566
04567
04568
04569 fseek(data->file, beginning, SEEK_SET);
04570
04571 printf("gamessplugin) Scanned %d INTERNAL coordinates \n",
04572 data->nintcoords);
04573 printf("gamessplugin) %d BONDS \n",data->nbonds);
04574 printf("gamessplugin) %d ANGLES \n",data->nangles);
04575 printf("gamessplugin) %d DIHEDRALS \n",data->ndiheds);
04576 printf("gamessplugin) %d IMPROPERS \n",data->nimprops);
04577
04578 data->have_internals = TRUE;
04579 return TRUE;
04580 }
04581
04582
04583
04584
04585
04586
04587
04588
04589 static int get_int_hessian(qmdata_t *data) {
04590 char buffer[BUFSIZ];
04591 double hess[5];
04592 int i = 0, j = 0, k = 0, l = 0;
04593
04594 memset(hess, 0, sizeof(hess));
04595
04596 if (pass_keyline(data->file,
04597 "HESSIAN MATRIX IN INTERNAL COORDINATES",
04598 "ENERGY GRADIENT") != FOUND) {
04599 return FALSE;
04600 }
04601 if (pass_keyline(data->file,
04602 "UNITS ARE HARTREE/",
04603 "ENERGY GRADIENT") != FOUND) {
04604 return FALSE;
04605 }
04606
04607 eatline(data->file, 3);
04608
04609
04610 data->inthessian =
04611 (double *)calloc((data->nintcoords)*(data->nintcoords),
04612 sizeof(double));
04613
04614
04615
04616 if (data->inthessian == NULL) {
04617 PRINTERR;
04618 return FALSE;
04619 }
04620
04621
04622
04623
04624
04625
04626 for (i=0; i<(int)ceil(data->nintcoords/5.f); i++) {
04627 for (j=0; j<data->nintcoords; j++) {
04628 int numread = 0;
04629
04630 GET_LINE(buffer, data->file);
04631 numread = sscanf(buffer,"%*d %lf %lf %lf %lf %lf", &hess[0],
04632 &hess[1], &hess[2], &hess[3], &hess[4]);
04633
04634
04635 for (k=0; k<numread; k++) {
04636 data->inthessian[j*data->nintcoords + i*5+k] = hess[k];
04637 }
04638 }
04639
04640
04641
04642 eatline(data->file, 2);
04643
04644 GET_LINE(buffer, data->file);
04645 }
04646
04647 #if 0
04648
04649
04650 remaining_blocks = data->nintcoords%5;
04651
04652 if (remaining_blocks!=0) {
04653 for (j=0; j<data->nintcoords; j++) {
04654 GET_LINE(buffer, data->file);
04655 sscanf(buffer,"%*d %lf %lf %lf %lf %lf", &hess[0],
04656 &hess[1], &hess[2], &hess[3], &hess[4]);
04657
04658 for (k=0; k<remaining_blocks; k++) {
04659 *(data->inthessian+(j*data->nintcoords)+(i*5)+k) = hess[k];
04660 }
04661 }
04662 }
04663 #endif
04664
04665 printf("gamessplugin) Scanned Hessian in INTERNAL coordinates\n");
04666
04667
04668
04669
04670
04671
04672
04673
04674 data->bond_force_const =
04675 (double *)calloc(data->nbonds, sizeof(double));
04676
04677 if (data->bond_force_const==NULL) {
04678 PRINTERR;
04679 return FALSE;
04680 }
04681
04682
04683 data->angle_force_const =
04684 (double *)calloc(data->nangles, sizeof(double));
04685
04686 if (data->angle_force_const==NULL) {
04687 PRINTERR;
04688 return FALSE;
04689 }
04690
04691
04692 data->dihedral_force_const =
04693 (double *)calloc(data->ndiheds, sizeof(double));
04694
04695 if (data->dihedral_force_const==NULL) {
04696 PRINTERR;
04697 return FALSE;
04698 }
04699
04700
04701 data->improper_force_const =
04702 (double *)calloc(data->nimprops, sizeof(double));
04703
04704 if (data->improper_force_const==NULL) {
04705 PRINTERR;
04706 return FALSE;
04707 }
04708
04709
04710 for (i=0; i<data->nbonds; i++) {
04711 data->bond_force_const[i] =
04712 data->inthessian[(i*data->nintcoords)+i] *
04713 HARTREE_TO_KCAL / BOHR_TO_ANGS / BOHR_TO_ANGS;
04714
04715 printf("%3d (BOND) %2d - %2d : %f\n", i,
04716 data->bonds[2*i], data->bonds[2*i+1],
04717 data->bond_force_const[i]);
04718 }
04719
04720
04721 for (j=i; j<i+(data->nangles); j++) {
04722 data->angle_force_const[j-i] =
04723 data->inthessian[j*data->nintcoords + j] * HARTREE_TO_KCAL;
04724
04725 printf("%3d (ANGLE) %2d - %2d - %2d : %f\n", j,
04726 data->angles[3*(j-i)], data->angles[3*(j-i)+1],
04727 data->angles[3*(j-i)+2],
04728 data->angle_force_const[j-i]);
04729 }
04730
04731
04732 for (k=j; k<j+(data->ndiheds); k++) {
04733 data->dihedral_force_const[k-j] =
04734 data->inthessian[k*data->nintcoords + k] * HARTREE_TO_KCAL;
04735
04736 printf("%3d (DIHEDRAL) %2d - %2d - %2d - %2d : %f \n", k,
04737 data->dihedrals[4*(k-j) ], data->dihedrals[4*(k-j)+1],
04738 data->dihedrals[4*(k-j)+2], data->dihedrals[4*(k-j)+3],
04739 data->dihedral_force_const[k-j]);
04740 }
04741
04742
04743 for (l=k; l<k+(data->nimprops); l++) {
04744 data->improper_force_const[l-k] =
04745 data->inthessian[l*data->nintcoords + l] * HARTREE_TO_KCAL;
04746
04747 printf("%3d (IMPROPERS) %2d - %2d - %2d - %2d : %f \n", l,
04748 data->impropers[4*(l-k) ], data->impropers[4*(l-k)+1],
04749 data->impropers[4*(l-k)+2], data->impropers[4*(l-k)+3],
04750 data->improper_force_const[l-k]);
04751 }
04752
04753 data->have_int_hessian = TRUE;
04754 return TRUE;
04755 }
04756
04757
04758 #if 0
04759
04760
04761
04762
04763
04764
04765
04766
04767 static int animate_normal_mode(qmdata_t *data, int mode)
04768 {
04769 mode_data *animated_mode = data->animated_mode;
04770 float *normal_modes = data->normal_modes;
04771 float scale = animated_mode->mode_scaling;
04772 int i = 0, k = 0;
04773 int l = 0, m = 0;
04774 int natoms = data->numatoms;
04775 int num_frames = animated_mode->mode_num_frames;
04776
04777
04778 for ( k = 0; k < num_frames+1; ++k)
04779 {
04780 for ( i = 0; i < natoms; ++i)
04781 {
04782 *(animated_mode->mode_frames+(k*natoms*3)+(3*i)) =
04783 (data->atoms+i)->x * (1+( k*scale *
04784 (*(normal_modes+(mode*natoms*3)+(3*i)))));
04785
04786 *(animated_mode->mode_frames+(k*natoms*3)+(3*i+1)) =
04787 (data->atoms+i)->y * (1+( k*scale *
04788 (*(normal_modes+(mode*natoms*3)+(3*i+1)))));
04789
04790 *(animated_mode->mode_frames+(k*natoms*3)+(3*i+2)) =
04791 (data->atoms+i)->z * (1+( k*scale *
04792 (*(normal_modes+(mode*natoms*3)+(3*i+2)))));
04793 }
04794 }
04795
04796
04797
04798 for ( l = 0; l < 2*num_frames+1; ++l)
04799 {
04800 for ( i = 0; i < natoms; ++i)
04801 {
04802 *(animated_mode->mode_frames+((l+k)*natoms*3)+(3*i)) =
04803 (data->atoms+i)->x * (1+((int)(num_frames-l)*scale *
04804 (*(normal_modes+(mode*natoms*3)+(3*i)))));
04805
04806 *(animated_mode->mode_frames+((l+k)*natoms*3)+(3*i+1)) =
04807 (data->atoms+i)->y * (1+((int)(num_frames-l)*scale *
04808 (*(normal_modes+(mode*natoms*3)+(3*i+1)))));
04809
04810 *(animated_mode->mode_frames+((l+k)*natoms*3)+(3*i+2)) =
04811 (data->atoms+i)->z * (1+((int)(num_frames-l)*scale *
04812 (*(normal_modes+(mode*natoms*3)+(3*i+2)))));
04813 }
04814 }
04815
04816
04817
04818 for ( m = 0; m < num_frames+1; ++m)
04819 {
04820 for ( i = 0; i < natoms; ++i)
04821 {
04822 *(animated_mode->mode_frames+((l+k+m)*natoms*3)+(3*i)) =
04823 (data->atoms+i)->x * (1+((int)(m-num_frames)*scale *
04824 (*(normal_modes+(mode*natoms*3)+(3*i)))));
04825
04826 *(animated_mode->mode_frames+((l+k+m)*natoms*3)+(3*i+1)) =
04827 (data->atoms+i)->y * (1+((int)(m-num_frames)*scale *
04828 (*(normal_modes+(mode*natoms*3)+(3*i+1)))));
04829
04830 *(animated_mode->mode_frames+((l+k+m)*natoms*3)+(3*i+2)) =
04831 (data->atoms+i)->z * (1+((int)(m-num_frames)*scale *
04832 (*(normal_modes+(mode*natoms*3)+(3*i+2)))));
04833 }
04834 }
04835
04836 printf("gamessplugin) Successfully animated mode %d \n", mode);
04837
04838 return TRUE;
04839 }
04840 #endif
04841
04842
04843
04844
04845
04846
04847
04848
04849 static molfile_plugin_t plugin;
04850
04851 VMDPLUGIN_API int VMDPLUGIN_init(void) {
04852 memset(&plugin, 0, sizeof(molfile_plugin_t));
04853 plugin.abiversion = vmdplugin_ABIVERSION;
04854 plugin.type = MOLFILE_PLUGIN_TYPE;
04855 plugin.name = "gamess";
04856 plugin.prettyname = "GAMESS";
04857 plugin.author = "Jan Saam, Markus Dittrich, Johan Strumpfer";
04858 plugin.majorv = 1;
04859 plugin.minorv = 2;
04860 plugin.is_reentrant = VMDPLUGIN_THREADUNSAFE;
04861 plugin.filename_extension = "log";
04862 plugin.open_file_read = open_gamess_read;
04863 plugin.read_structure = read_gamess_structure;
04864 plugin.close_file_read = close_gamess_read;
04865
04866 plugin.read_qm_metadata = read_gamess_metadata;
04867 plugin.read_qm_rundata = read_gamess_rundata;
04868
04869 #if vmdplugin_ABIVERSION > 11
04870 plugin.read_timestep_metadata = read_timestep_metadata;
04871 plugin.read_qm_timestep_metadata = read_qm_timestep_metadata;
04872 plugin.read_timestep = read_timestep;
04873 #endif
04874
04875 return VMDPLUGIN_SUCCESS;
04876 }
04877
04878 VMDPLUGIN_API int VMDPLUGIN_register(void *v, vmdplugin_register_cb cb) {
04879 (*cb)(v, (vmdplugin_t *)&plugin);
04880 return VMDPLUGIN_SUCCESS;
04881 }
04882
04883 VMDPLUGIN_API int VMDPLUGIN_fini(void) {
04884 return VMDPLUGIN_SUCCESS;
04885 }