⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 output_state.cc

📁 c++编写的并行拉马克遗传算法的程序。实现分析对接程序
💻 CC
字号:
/* output_state.cc */#ifdef sgi    #include <stdio.h>    #include <fcntl.h>    #include <unistd.h>    #include <sys/stat.h>    #include <sys/types.h>    #include "structs.h"    #include "output_state.h"#else    extern "C"    {	#include <stdio.h>	#include <fcntl.h>	#include <unistd.h>	#include <sys/stat.h>	#include <sys/types.h>	#include "structs.h"        #include "output_state.h"    }#endif/* LOCK_SH 1       shared lock *//* LOCK_EX 2       exclusive lock *//* LOCK_NB 4       don't block when locking *//* LOCK_UN 8       unlock */#define PERMS 0666        /* hexadecimal permissions for watch-file *//*----------------------------------------------------------------------------*/void output_state( FILE *fp,		   State S,                   int ntor,                   int istep,                   float energy,                   float eint,                   char lastmove,                   Boole B_watch,                   char FN_watch[MAX_CHARS],                   char atomstuff[MAX_ATOMS][MAX_CHARS],                   int natom,                   float crd[MAX_ATOMS][SPACE])/*----------------------------------------------------------------------------*/{    int i;	/*int lockf_status;*/	int FD_watch;    FILE *FP_watch;    fprintf(fp, "state %d %c %f %f  %lf %lf %lf  %lf %lf %lf %lf\n",        istep, lastmove, energy, eint, S.T.x, S.T.y, S.T.z,        S.Q.nx, S.Q.ny, S.Q.nz, Deg( S.Q.ang ) );    for (i=0; i<ntor; i++) {        fprintf(fp, "%f\n", Deg( S.tor[i]) );    }/* >>>> NOW USES lockf !!!! <<<< */    if (B_watch) {        if ((FD_watch = creat( FN_watch, PERMS )) != -1) {;            /* creates new file, or re-write old one */            if ((FP_watch = fdopen( FD_watch, "w")) != NULL ) {                /*lockf_status = lockf( FD_watch, F_LOCK, 0 ); */                (void) lockf( FD_watch, F_LOCK, 0 );                 for (i = 0;  i < natom;  i++) {		    fprintf( FP_watch, "%30s%8.3f%8.3f%8.3f\n",		    atomstuff[i], crd[i][X], crd[i][Y], crd[i][Z]);                }                fclose( FP_watch ); /*lockf_status=lockf(FD_watch,F_ULOCK,0);*/            }        }    }    return;}/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -