1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * If you want to redistribute modifications, please consider that
22 * scientific software is very special. Version control is crucial -
23 * bugs must be traceable. We will be happy to consider code for
24 * inclusion in the official distribution, but derived work must not
25 * be called official GROMACS. Details are found in the README & COPYING
26 * files - if they are missing, get the official version at www.gromacs.org.
28 * To help us fund GROMACS development, we humbly ask that you cite
29 * the papers on the package - you can find them in the top README file.
31 * For more info, check our website at http://www.gromacs.org
34 * GROningen Mixture of Alchemy and Childrens' Stories
42 #include "gmx_fatal.h"
49 /* The source code in this file should be thread-safe.
50 Please keep it that way. */
52 /* This number should be increased whenever the file format changes! */
53 static const int enx_version = 5;
55 const char *enx_block_id_name[] = {
56 "Averaged orientation restraints",
57 "Instantaneous orientation restraints",
58 "Orientation restraint order tensor(s)",
59 "Distance restraints",
66 /* Stuff for reading pre 4.1 energy files */
68 gmx_bool bOldFileOpen; /* Is this an open old file? */
69 gmx_bool bReadFirstStep; /* Did we read the first step? */
70 int first_step; /* First step in the energy file */
71 int step_prev; /* Previous step */
72 int nsum_prev; /* Previous step sum length */
73 t_energy *ener_prev; /* Previous energy sums */
84 static void enxsubblock_init(t_enxsubblock *sb)
88 sb->type=xdr_datatype_double;
90 sb->type=xdr_datatype_float;
106 static void enxsubblock_free(t_enxsubblock *sb)
142 for(i=0;i<sb->sval_alloc;i++)
155 /* allocate the appropriate amount of memory for the given type and nr */
156 static void enxsubblock_alloc(t_enxsubblock *sb)
158 /* allocate the appropriate amount of memory */
161 case xdr_datatype_float:
162 if (sb->nr > sb->fval_alloc)
164 srenew(sb->fval, sb->nr);
165 sb->fval_alloc=sb->nr;
168 case xdr_datatype_double:
169 if (sb->nr > sb->dval_alloc)
171 srenew(sb->dval, sb->nr);
172 sb->dval_alloc=sb->nr;
175 case xdr_datatype_int:
176 if (sb->nr > sb->ival_alloc)
178 srenew(sb->ival, sb->nr);
179 sb->ival_alloc=sb->nr;
182 case xdr_datatype_large_int:
183 if (sb->nr > sb->lval_alloc)
185 srenew(sb->lval, sb->nr);
186 sb->lval_alloc=sb->nr;
189 case xdr_datatype_char:
190 if (sb->nr > sb->cval_alloc)
192 srenew(sb->cval, sb->nr);
193 sb->cval_alloc=sb->nr;
196 case xdr_datatype_string:
197 if (sb->nr > sb->sval_alloc)
201 srenew(sb->sval, sb->nr);
202 for(i=sb->sval_alloc;i<sb->nr;i++)
206 sb->sval_alloc=sb->nr;
210 gmx_incons("Unknown block type: this file is corrupted or from the future");
214 static void enxblock_init(t_enxblock *eb)
222 static void enxblock_free(t_enxblock *eb)
224 if (eb->nsub_alloc>0)
227 for(i=0;i<eb->nsub_alloc;i++)
229 enxsubblock_free(&(eb->sub[i]));
237 void init_enxframe(t_enxframe *fr)
253 void free_enxframe(t_enxframe *fr)
261 for(b=0; b<fr->nblock_alloc; b++)
263 enxblock_free(&(fr->block[b]));
268 void add_blocks_enxframe(t_enxframe *fr, int n)
271 if (n > fr->nblock_alloc)
275 srenew(fr->block, n);
276 for(b=fr->nblock_alloc;b<fr->nblock;b++)
278 enxblock_init(&(fr->block[b]));
284 t_enxblock *find_block_id_enxframe(t_enxframe *ef, int id, t_enxblock *prev)
291 starti=(prev - ef->block) + 1;
293 for(i=starti; i<ef->nblock; i++)
295 if (ef->block[i].id == id)
296 return &(ef->block[i]);
301 void add_subblocks_enxblock(t_enxblock *eb, int n)
304 if (eb->nsub > eb->nsub_alloc)
309 for(b=eb->nsub_alloc; b<n; b++)
311 enxsubblock_init(&(eb->sub[b]));
317 static void enx_warning(const char *msg)
319 if (getenv("GMX_ENX_NO_FATAL") != NULL)
325 gmx_fatal(FARGS,"%s\n%s",
327 "If you want to use the correct frames before the corrupted frame and avoid this fatal error set the env.var. GMX_ENX_NO_FATAL");
331 static void edr_strings(XDR *xdr,gmx_bool bRead,int file_version,
332 int n,gmx_enxnm_t **nms)
357 if(!xdr_string(xdr,&(nm->name),STRLEN))
359 gmx_file("Cannot write energy names to file; maybe you are out of disk space?");
361 if (file_version >= 2)
363 if(!xdr_string(xdr,&(nm->unit),STRLEN))
365 gmx_file("Cannot write energy names to file; maybe you are out of disk space?");
370 nm->unit = strdup("kJ/mol");
375 void do_enxnms(ener_file_t ef,int *nre,gmx_enxnm_t **nms)
379 gmx_bool bRead = gmx_fio_getread(ef->fio);
383 gmx_fio_checktype(ef->fio);
385 xdr = gmx_fio_getxdr(ef->fio);
387 if (!xdr_int(xdr,&magic))
391 gmx_file("Cannot write energy names to file; maybe you are out of disk space?");
398 /* Assume this is an old edr format */
401 ef->eo.bOldFileOpen = TRUE;
402 ef->eo.bReadFirstStep = FALSE;
403 srenew(ef->eo.ener_prev,*nre);
407 ef->eo.bOldFileOpen=FALSE;
411 gmx_fatal(FARGS,"Energy names magic number mismatch, this is not a GROMACS edr file");
413 file_version = enx_version;
414 xdr_int(xdr,&file_version);
415 if (file_version > enx_version)
417 gmx_fatal(FARGS,"reading tpx file (%s) version %d with version %d program",gmx_fio_getname(ef->fio),file_version,enx_version);
421 if (file_version != enx_version)
423 fprintf(stderr,"Note: enx file_version %d, software version %d\n",
424 file_version,enx_version);
427 edr_strings(xdr,bRead,file_version,*nre,nms);
430 static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr,
431 int nre_test,gmx_bool *bWrongPrecision,gmx_bool *bOK)
434 real first_real_to_check;
435 int b,i,zero=0,dum=0;
436 gmx_bool bRead = gmx_fio_getread(ef->fio);
441 xdr_datatype dtreal=xdr_datatype_float;
443 xdr_datatype dtreal=xdr_datatype_double;
448 *bWrongPrecision = FALSE;
452 /* The original energy frame started with a real,
453 * so we have to use a real for compatibility.
454 * This is VERY DIRTY code, since do_eheader can be called
455 * with the wrong precision set and then we could read r > -1e10,
456 * while actually the intention was r < -1e10.
457 * When nre_test >= 0, do_eheader should therefore terminate
458 * before the number of i/o calls starts depending on what has been read
459 * (which is the case for for instance the block sizes for variable
460 * number of blocks, where this number is read before).
462 first_real_to_check = -2e10;
463 if (!gmx_fio_do_real(ef->fio, first_real_to_check))
467 if (first_real_to_check > -1e10)
469 /* Assume we are reading an old format */
471 fr->t = first_real_to_check;
472 if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE;
477 if (!gmx_fio_do_int(ef->fio, magic)) *bOK = FALSE;
478 if (magic != -7777777)
480 enx_warning("Energy header magic number mismatch, this is not a GROMACS edr file");
484 *file_version = enx_version;
485 if (!gmx_fio_do_int(ef->fio, *file_version)) *bOK = FALSE;
486 if (*bOK && *file_version > enx_version)
488 gmx_fatal(FARGS,"reading tpx file (%s) version %d with version %d program",gmx_fio_getname(ef->fio),file_version,enx_version);
490 if (!gmx_fio_do_double(ef->fio, fr->t)) *bOK = FALSE;
491 if (!gmx_fio_do_gmx_large_int(ef->fio, fr->step)) *bOK = FALSE;
492 if (!bRead && fr->nsum == 1) {
493 /* Do not store sums of length 1,
494 * since this does not add information.
496 if (!gmx_fio_do_int(ef->fio, zero)) *bOK = FALSE;
498 if (!gmx_fio_do_int(ef->fio, fr->nsum)) *bOK = FALSE;
500 if (*file_version >= 3)
502 if (!gmx_fio_do_gmx_large_int(ef->fio, fr->nsteps)) *bOK = FALSE;
506 fr->nsteps = max(1,fr->nsum);
508 if (*file_version >= 5)
510 if (!gmx_fio_do_double(ef->fio, fr->dt)) *bOK = FALSE;
517 if (!gmx_fio_do_int(ef->fio, fr->nre)) *bOK = FALSE;
518 if (*file_version < 4)
520 if (!gmx_fio_do_int(ef->fio, ndisre)) *bOK = FALSE;
524 /* now reserved for possible future use */
525 if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE;
528 if (!gmx_fio_do_int(ef->fio, fr->nblock)) *bOK = FALSE;
529 if (fr->nblock < 0) *bOK=FALSE;
533 if (*file_version >= 4)
535 enx_warning("Distance restraint blocks in old style in new style file");
543 /* Frames could have nre=0, so we can not rely only on the fr->nre check */
544 if (bRead && nre_test >= 0 &&
545 ((fr->nre > 0 && fr->nre != nre_test) ||
546 fr->nre < 0 || ndisre < 0 || fr->nblock < 0))
548 *bWrongPrecision = TRUE;
552 /* we now know what these should be, or we've already bailed out because
553 of wrong precision */
554 if ( *file_version==1 && (fr->t < 0 || fr->t > 1e20 || fr->step < 0 ) )
556 enx_warning("edr file with negative step number or unreasonable time (and without version number).");
564 add_blocks_enxframe(fr, fr->nblock);
570 /* sub[0] is the instantaneous data, sub[1] is time averaged */
571 add_subblocks_enxblock(&(fr->block[0]), 2);
572 fr->block[0].id=enxDISRE;
573 fr->block[0].sub[0].nr=ndisre;
574 fr->block[0].sub[1].nr=ndisre;
575 fr->block[0].sub[0].type=dtreal;
576 fr->block[0].sub[1].type=dtreal;
580 /* read block header info */
581 for(b=startb; b<fr->nblock; b++)
585 /* blocks in old version files always have 1 subblock that
586 consists of reals. */
591 add_subblocks_enxblock(&(fr->block[b]), 1);
595 if (fr->block[b].nsub != 1)
597 gmx_incons("Writing an old version .edr file with too many subblocks");
599 if (fr->block[b].sub[0].type != dtreal)
601 gmx_incons("Writing an old version .edr file the wrong subblock type");
604 nrint = fr->block[b].sub[0].nr;
606 if (!gmx_fio_do_int(ef->fio, nrint))
610 fr->block[b].id = b - startb;
611 fr->block[b].sub[0].nr = nrint;
612 fr->block[b].sub[0].type = dtreal;
617 /* in the new version files, the block header only contains
618 the ID and the number of subblocks */
619 int nsub=fr->block[b].nsub;
620 *bOK = *bOK && gmx_fio_do_int(ef->fio, fr->block[b].id);
621 *bOK = *bOK && gmx_fio_do_int(ef->fio, nsub);
623 fr->block[b].nsub=nsub;
625 add_subblocks_enxblock(&(fr->block[b]), nsub);
627 /* read/write type & size for each subblock */
630 t_enxsubblock *sub=&(fr->block[b].sub[i]); /* shortcut */
631 int typenr=sub->type;
633 *bOK=*bOK && gmx_fio_do_int(ef->fio, typenr);
634 *bOK=*bOK && gmx_fio_do_int(ef->fio, sub->nr);
636 sub->type = (xdr_datatype)typenr;
640 if (!gmx_fio_do_int(ef->fio, fr->e_size)) *bOK = FALSE;
642 /* now reserved for possible future use */
643 if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE;
645 /* Do a dummy int to keep the format compatible with the old code */
646 if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE;
648 if (*bOK && *file_version == 1 && nre_test < 0)
651 if (fp >= ener_old_nalloc)
653 gmx_incons("Problem with reading old format energy files");
657 if (!ef->eo.bReadFirstStep)
659 ef->eo.bReadFirstStep = TRUE;
660 ef->eo.first_step = fr->step;
661 ef->eo.step_prev = fr->step;
662 ef->eo.nsum_prev = 0;
665 fr->nsum = fr->step - ef->eo.first_step + 1;
666 fr->nsteps = fr->step - ef->eo.step_prev;
673 void free_enxnms(int n,gmx_enxnm_t *nms)
686 void close_enx(ener_file_t ef)
688 if(gmx_fio_close(ef->fio) != 0)
690 gmx_file("Cannot close energy file; it might be corrupt, or maybe you are out of disk space?");
694 static gmx_bool empty_file(const char *fn)
701 fp = gmx_fio_fopen(fn,"r");
702 ret = fread(&dum,sizeof(dum),1,fp);
710 ener_file_t open_enx(const char *fn,const char *mode)
713 gmx_enxnm_t *nms=NULL;
716 gmx_bool bWrongPrecision,bOK=TRUE;
717 struct ener_file *ef;
722 ef->fio=gmx_fio_open(fn,mode);
723 gmx_fio_checktype(ef->fio);
724 gmx_fio_setprecision(ef->fio,FALSE);
725 do_enxnms(ef,&nre,&nms);
727 do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK);
730 gmx_file("Cannot read energy file header. Corrupt file?");
733 /* Now check whether this file is in single precision */
734 if (!bWrongPrecision &&
735 ((fr->e_size && (fr->nre == nre) &&
736 (nre*4*(long int)sizeof(float) == fr->e_size)) ) )
738 fprintf(stderr,"Opened %s as single precision energy file\n",fn);
739 free_enxnms(nre,nms);
743 gmx_fio_rewind(ef->fio);
744 gmx_fio_checktype(ef->fio);
745 gmx_fio_setprecision(ef->fio,TRUE);
746 do_enxnms(ef,&nre,&nms);
747 do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK);
750 gmx_file("Cannot write energy file header; maybe you are out of disk space?");
753 if (((fr->e_size && (fr->nre == nre) &&
754 (nre*4*(long int)sizeof(double) == fr->e_size)) ))
755 fprintf(stderr,"Opened %s as double precision energy file\n",
759 gmx_fatal(FARGS,"File %s is empty",fn);
761 gmx_fatal(FARGS,"Energy file %s not recognized, maybe different CPU?",
764 free_enxnms(nre,nms);
768 gmx_fio_rewind(ef->fio);
771 ef->fio = gmx_fio_open(fn,mode);
778 t_fileio *enx_file_pointer(const ener_file_t ef)
783 static void convert_full_sums(ener_old_t *ener_old,t_enxframe *fr)
787 double esum_all,eav_all;
793 for(i=0; i<fr->nre; i++)
795 if (fr->ener[i].e != 0) ne++;
796 if (fr->ener[i].esum != 0) ns++;
798 if (ne > 0 && ns == 0)
800 /* We do not have all energy sums */
805 /* Convert old full simulation sums to sums between energy frames */
806 nstep_all = fr->step - ener_old->first_step + 1;
807 if (fr->nsum > 1 && fr->nsum == nstep_all && ener_old->nsum_prev > 0)
809 /* Set the new sum length: the frame step difference */
810 fr->nsum = fr->step - ener_old->step_prev;
811 for(i=0; i<fr->nre; i++)
813 esum_all = fr->ener[i].esum;
814 eav_all = fr->ener[i].eav;
815 fr->ener[i].esum = esum_all - ener_old->ener_prev[i].esum;
816 fr->ener[i].eav = eav_all - ener_old->ener_prev[i].eav
817 - dsqr(ener_old->ener_prev[i].esum/(nstep_all - fr->nsum)
818 - esum_all/nstep_all)*
819 (nstep_all - fr->nsum)*nstep_all/(double)fr->nsum;
820 ener_old->ener_prev[i].esum = esum_all;
821 ener_old->ener_prev[i].eav = eav_all;
823 ener_old->nsum_prev = nstep_all;
825 else if (fr->nsum > 0)
827 if (fr->nsum != nstep_all)
829 fprintf(stderr,"\nWARNING: something is wrong with the energy sums, will not use exact averages\n");
830 ener_old->nsum_prev = 0;
834 ener_old->nsum_prev = nstep_all;
836 /* Copy all sums to ener_prev */
837 for(i=0; i<fr->nre; i++)
839 ener_old->ener_prev[i].esum = fr->ener[i].esum;
840 ener_old->ener_prev[i].eav = fr->ener[i].eav;
844 ener_old->step_prev = fr->step;
847 gmx_bool do_enx(ener_file_t ef,t_enxframe *fr)
851 gmx_bool bRead,bOK,bOK1,bSane;
857 bRead = gmx_fio_getread(ef->fio);
860 fr->e_size = fr->nre*sizeof(fr->ener[0].e)*4;
861 /*d_size = fr->ndisre*(sizeof(real)*2);*/
863 gmx_fio_checktype(ef->fio);
865 if (!do_eheader(ef,&file_version,fr,-1,NULL,&bOK))
869 fprintf(stderr,"\rLast energy frame read %d time %8.3f ",
870 ef->framenr-1,ef->frametime);
874 "\nWARNING: Incomplete energy frame: nr %d time %8.3f\n",
880 gmx_file("Cannot write energy file header; maybe you are out of disk space?");
886 if ((ef->framenr < 20 || ef->framenr % 10 == 0) &&
887 (ef->framenr < 200 || ef->framenr % 100 == 0) &&
888 (ef->framenr < 2000 || ef->framenr % 1000 == 0))
890 fprintf(stderr,"\rReading energy frame %6d time %8.3f ",
894 ef->frametime = fr->t;
896 /* Check sanity of this header */
897 bSane = fr->nre > 0 ;
898 for(b=0; b<fr->nblock; b++)
900 bSane = bSane || (fr->block[b].nsub > 0);
902 if (!((fr->step >= 0) && bSane))
904 fprintf(stderr,"\nWARNING: there may be something wrong with energy file %s\n",
905 gmx_fio_getname(ef->fio));
906 fprintf(stderr,"Found: step=%s, nre=%d, nblock=%d, time=%g.\n"
907 "Trying to skip frame expect a crash though\n",
908 gmx_step_str(fr->step,buf),fr->nre,fr->nblock,fr->t);
910 if (bRead && fr->nre > fr->e_alloc)
912 srenew(fr->ener,fr->nre);
913 for(i=fr->e_alloc; (i<fr->nre); i++)
917 fr->ener[i].esum = 0;
919 fr->e_alloc = fr->nre;
922 for(i=0; i<fr->nre; i++)
924 bOK = bOK && gmx_fio_do_real(ef->fio, fr->ener[i].e);
926 /* Do not store sums of length 1,
927 * since this does not add information.
929 if (file_version == 1 ||
930 (bRead && fr->nsum > 0) || fr->nsum > 1)
932 tmp1 = fr->ener[i].eav;
933 bOK = bOK && gmx_fio_do_real(ef->fio, tmp1);
935 fr->ener[i].eav = tmp1;
937 /* This is to save only in single precision (unless compiled in DP) */
938 tmp2 = fr->ener[i].esum;
939 bOK = bOK && gmx_fio_do_real(ef->fio, tmp2);
941 fr->ener[i].esum = tmp2;
943 if (file_version == 1)
945 /* Old, unused real */
947 bOK = bOK && gmx_fio_do_real(ef->fio, rdum);
952 /* Here we can not check for file_version==1, since one could have
953 * continued an old format simulation with a new one with mdrun -append.
955 if (bRead && ef->eo.bOldFileOpen)
957 /* Convert old full simulation sums to sums between energy frames */
958 convert_full_sums(&(ef->eo),fr);
960 /* read the blocks */
961 for(b=0; b<fr->nblock; b++)
963 /* now read the subblocks. */
964 int nsub=fr->block[b].nsub; /* shortcut */
969 t_enxsubblock *sub=&(fr->block[b].sub[i]); /* shortcut */
973 enxsubblock_alloc(sub);
976 /* read/write data */
980 case xdr_datatype_float:
981 bOK1=gmx_fio_ndo_float(ef->fio, sub->fval, sub->nr);
983 case xdr_datatype_double:
984 bOK1=gmx_fio_ndo_double(ef->fio, sub->dval, sub->nr);
986 case xdr_datatype_int:
987 bOK1=gmx_fio_ndo_int(ef->fio, sub->ival, sub->nr);
989 case xdr_datatype_large_int:
990 bOK1=gmx_fio_ndo_gmx_large_int(ef->fio, sub->lval, sub->nr);
992 case xdr_datatype_char:
993 bOK1=gmx_fio_ndo_uchar(ef->fio, sub->cval, sub->nr);
995 case xdr_datatype_string:
996 bOK1=gmx_fio_ndo_string(ef->fio, sub->sval, sub->nr);
999 gmx_incons("Reading unknown block data type: this file is corrupted or from the future");
1007 if( gmx_fio_flush(ef->fio) != 0)
1009 gmx_file("Cannot write energy file; maybe you are out of disk space?");
1017 fprintf(stderr,"\nLast energy frame read %d",
1019 fprintf(stderr,"\nWARNING: Incomplete energy frame: nr %d time %8.3f\n",
1024 gmx_fatal(FARGS,"could not write energies");
1032 static real find_energy(const char *name, int nre, gmx_enxnm_t *enm,
1037 for(i=0; i<nre; i++)
1039 if (strcmp(enm[i].name,name) == 0)
1041 return fr->ener[i].e;
1045 gmx_fatal(FARGS,"Could not find energy term named '%s'",name);
1051 void get_enx_state(const char *fn, real t, gmx_groups_t *groups, t_inputrec *ir,
1054 /* Should match the names in mdebin.c */
1055 static const char *boxvel_nm[] = {
1056 "Box-Vel-XX", "Box-Vel-YY", "Box-Vel-ZZ",
1057 "Box-Vel-YX", "Box-Vel-ZX", "Box-Vel-ZY"
1060 static const char *pcouplmu_nm[] = {
1061 "Pcoupl-Mu-XX", "Pcoupl-Mu-YY", "Pcoupl-Mu-ZZ",
1062 "Pcoupl-Mu-YX", "Pcoupl-Mu-ZX", "Pcoupl-Mu-ZY"
1064 static const char *baro_nm[] = {
1069 int ind0[] = { XX,YY,ZZ,YY,ZZ,ZZ };
1070 int ind1[] = { XX,YY,ZZ,XX,XX,YY };
1071 int nre,nfr,i,j,ni,npcoupl;
1074 gmx_enxnm_t *enm=NULL;
1078 in = open_enx(fn,"r");
1079 do_enxnms(in,&nre,&enm);
1082 while ((nfr==0 || fr->t != t) && do_enx(in,fr)) {
1086 fprintf(stderr,"\n");
1088 if (nfr == 0 || fr->t != t)
1089 gmx_fatal(FARGS,"Could not find frame with time %f in '%s'",t,fn);
1091 npcoupl = TRICLINIC(ir->compress) ? 6 : 3;
1092 if (ir->epc == epcPARRINELLORAHMAN) {
1093 clear_mat(state->boxv);
1094 for(i=0; i<npcoupl; i++) {
1095 state->boxv[ind0[i]][ind1[i]] =
1096 find_energy(boxvel_nm[i],nre,enm,fr);
1098 fprintf(stderr,"\nREAD %d BOX VELOCITIES FROM %s\n\n",npcoupl,fn);
1101 if (ir->etc == etcNOSEHOOVER)
1107 for(i=0; i<state->ngtc; i++) {
1108 ni = groups->grps[egcTC].nm_ind[i];
1109 bufi = *(groups->grpname[ni]);
1110 for(j=0; (j<state->nhchainlength); j++)
1112 if (IR_NVT_TROTTER(ir))
1114 sprintf(cns,"-%d",j);
1116 sprintf(buf,"Xi%s-%s",cns,bufi);
1117 state->nosehoover_xi[i] = find_energy(buf,nre,enm,fr);
1118 sprintf(buf,"vXi%s-%s",cns,bufi);
1119 state->nosehoover_vxi[i] = find_energy(buf,nre,enm,fr);
1123 fprintf(stderr,"\nREAD %d NOSE-HOOVER Xi chains FROM %s\n\n",state->ngtc,fn);
1125 if (IR_NPT_TROTTER(ir) || IR_NPH_TROTTER(ir))
1127 for(i=0; i<state->nnhpres; i++) {
1128 bufi = baro_nm[0]; /* All barostat DOF's together for now */
1129 for(j=0; (j<state->nhchainlength); j++)
1131 sprintf(buf,"Xi-%d-%s",j,bufi);
1132 state->nhpres_xi[i] = find_energy(buf,nre,enm,fr);
1133 sprintf(buf,"vXi-%d-%s",j,bufi);
1134 state->nhpres_vxi[i] = find_energy(buf,nre,enm,fr);
1137 fprintf(stderr,"\nREAD %d NOSE-HOOVER BAROSTAT Xi chains FROM %s\n\n",state->nnhpres,fn);
1141 free_enxnms(nre,enm);