~ubuntu-branches/ubuntu/trusty/gdis/trusty

« back to all changes in this revision

Viewing changes to file_dmol.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2009-04-06 17:12:18 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090406171218-uizoe126jrq09ytt
Tags: 0.90-1
* New upstream release 0.90.
* Acknowledge NMU (closes: #492994). Thanks to Neil Williams.

* makefile.debian: Upstream doesn't provide a Makefile to edit - so created
  our own.
* debian/compat: Added and set to be 5.
* debian/control: Added Homepage, Vcs* and DM-Upload-Allowed fields.
  (Maintainer): Set to the debichem team with approval by Noèl.
  (Uploaders): Added myself.
  (Build-Depends): Increased debhelper version to 5. Removed glutg3-dev.
  Added dpatch.
  (Standards-Version): Bumped to 3.8.1.
  (Description): Removed homepage. Fixed a typo.
* debian/copyright: Updated, completed and adjusted.
* debian/dirs: Dropped useless file.
* debian/docs: Renamed to debian/gdis.docs.
* debian/menu: Renamed to debian/gdis.menu.
  (section): Fixed accordingly to policy.
* debian/gdis.1: Just some formatting changes.
* debian/gdis.desktop: Added file (with small fixes) provided by Phill Bull
  (LP: #111353).
* debian/gdis.install: Added.
* debian/rules: Cleaned. Installation is now done by dh_install. Make sure,
  the CVS directory is not copied. Added dh_desktop call.
* debian/source.lintian-overrides: makefile.debian is created for Debian but
  lives outside debian/.
* debian/watch: Added.
* debian/README.build: Dropped.
* debian/README.source: Added to be compliant to the policy v3.8.
* debian/patches/Debian_make.dpatch: Added.
  - gdis.h (ELEM_FILE): Moved fix for gdis.elemts path (#399132) to this
    patch.
* debian/patches/00list: Added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
/****************/
93
93
/* file reading */
94
94
/****************/
95
 
gint read_dmol(gchar *filename, struct model_pak *model)
 
95
gint read_dmol_frame(FILE *fp, struct model_pak *model)
96
96
{
97
97
gint i, num_tokens;
98
 
gchar **buff;
99
 
gpointer scan;
 
98
gchar *line, **buff;
100
99
struct core_pak *core;
101
100
 
102
 
g_assert(model != NULL);
103
 
 
104
 
scan = scan_new(filename);
105
 
if (!scan)
106
 
  return(1);
107
 
 
108
 
while (!scan_complete(scan))
 
101
g_assert(fp != NULL);
 
102
 
 
103
line = file_read_line(fp);
 
104
 
 
105
while (line)
109
106
  {
110
 
  buff = scan_get_tokens(scan, &num_tokens);
111
 
  if (!buff)
112
 
    break;
113
 
 
114
107
/* read cell vectors */
115
 
  if (g_strncasecmp(*buff, "$cell", 5) == 0)
 
108
  if (g_ascii_strncasecmp(line, "$cell", 5) == 0 && model)
116
109
    {
117
110
    for (i=0 ; i<3 ; i++)
118
111
      {
119
 
      g_strfreev(buff);
120
 
      buff = scan_get_tokens(scan, &num_tokens);
 
112
      g_free(line);
 
113
      line = file_read_line(fp);
 
114
      buff = tokenize(line, &num_tokens);
121
115
      if (num_tokens > 2)
122
116
        {
123
117
        model->latmat[i] = AU2ANG*str_to_float(*(buff));
124
118
        model->latmat[i+3] = AU2ANG*str_to_float(*(buff+1));
125
119
        model->latmat[i+6] = AU2ANG*str_to_float(*(buff+2));
126
120
        }
 
121
      g_strfreev(buff);
127
122
      }
128
123
    model->periodic = 3;
129
124
    model->construct_pbc = TRUE;
130
125
    }
131
126
 
132
127
/* read coordinates */
133
 
  if (g_strncasecmp(*buff, "$coord", 5) == 0)
 
128
  if (g_ascii_strncasecmp(line, "$coord", 5) == 0 && model)
134
129
    {
135
 
    g_strfreev(buff);
136
 
    buff = scan_get_tokens(scan, &num_tokens);
 
130
    g_free(line);
 
131
    line = file_read_line(fp);
 
132
    buff = tokenize(line, &num_tokens);
137
133
    while (num_tokens > 3)
138
134
      {
139
135
      if (elem_symbol_test(*buff))
144
140
        core->x[1] = AU2ANG*str_to_float(*(buff+2));
145
141
        core->x[2] = AU2ANG*str_to_float(*(buff+3));
146
142
        }
 
143
      g_free(line);
 
144
      line = file_read_line(fp);
147
145
      g_strfreev(buff);
148
 
      buff = scan_get_tokens(scan, &num_tokens);
 
146
      buff = tokenize(line, &num_tokens);
149
147
      }
 
148
    g_strfreev(buff);
150
149
    model->fractional = FALSE;
151
150
    }
152
151
 
153
 
  g_strfreev(buff);
154
 
  }
155
 
 
156
 
/* done reading */
157
 
scan_free(scan);
 
152
/* terminate frame read */
 
153
  if (g_ascii_strncasecmp(line, "$end", 4) == 0)
 
154
    return(0);
 
155
 
 
156
  g_free(line);
 
157
  line = file_read_line(fp);
 
158
  }
 
159
 
 
160
return(1);
 
161
}
 
162
 
 
163
/****************/
 
164
/* file reading */
 
165
/****************/
 
166
#define DEBUG_READ_XYZ 0
 
167
gint read_dmol(gchar *filename, struct model_pak *model)
 
168
{
 
169
gint flag;
 
170
FILE *fp;
 
171
 
 
172
/* checks */
 
173
g_return_val_if_fail(model != NULL, 1);
 
174
g_return_val_if_fail(filename != NULL, 2);
 
175
 
 
176
fp = fopen(filename,"rt");
 
177
if (!fp)
 
178
  return(3);
 
179
 
 
180
/* loop while there's data */
 
181
flag=0;
 
182
model->num_frames = 0;
 
183
 
 
184
read_dmol_frame(fp, model);
 
185
 
 
186
for (;;)
 
187
  {
 
188
  add_frame_offset(fp, model);
 
189
 
 
190
  if (read_dmol_frame(fp, NULL))
 
191
    break;
 
192
 
 
193
  model->num_frames++;
 
194
  }
 
195
 
 
196
/* get rid of frame list if only one frame */
 
197
if (model->num_frames == 1)
 
198
  {
 
199
  free_list(model->frame_list);
 
200
  model->frame_list = NULL;
 
201
  }
158
202
 
159
203
/* model setup */
160
204
strcpy(model->filename, filename);
161
205
g_free(model->basename);
162
 
model->basename = strdup_basename(filename);
 
206
model->basename = parse_strip(filename);
163
207
model_prep(model);
164
208
 
165
209
return(0);