/*---------------------------------------------------------------------- jcio.c : Rutinas para la gestion de ficheros en CORSIKA 5.20 Author J.C.Gonzalez Las posibilidades que contempla son: - Creacion de un fichero de inicio de run: run###### - Creacion de un fichero de fin de run: end###### - Creacion de fichero separados para cada cascada, tanto para particulas como para Cherenkov. Ademas, para la salida Cherenkov se genera en ficheros separados en caso de que se reutilice la cascada. Los fichero son por tanto: cer######.# y dat######, donde el indice del fichero cer va de 0 a 9. - La grabacion se realiza en C, por lo que no existen marcas de inicio ni final de bloque en los ficheros. Modified by C.Bigongiari 2000 Dec 19. No more RUN###### and END###### files created. Three files, CER######, DAT###### and STA###### files, per run instead of three files per shower. Now ###### is the RUN NUMBER not the shower number !!! ----------------------------------------------------------------------*/ #include #include #define MAXBUF 273 /*- 39*7 -*/ #define NSUBBL 21 #define NPLONG 1041 static int nshow = 0; static float timefirst = 0.; static float timelast = 0.; FILE *cetape; FILE *patape; FILE *sttape; /* CBC FILE *runtape; FILE *endtape; CBC*/ char tpl[100]; char certpl[100]; char dattpl[100]; /* CBC char statpl[100]; */ char cerfile[100]; char datfile[100]; /* CBC char stafile[100]; char runfile[100]; char endfile[100]; CBC */ /*-------------------------------------------------- jcinitio: Define file names --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jcinitio_ (char *path, int *runnum) #else /* JC_NO_UNDERSCORES */ void jcinitio (char *path, int *runnum) #endif /* JC_UNDERSCORES */ { register int i = 0; while (*(path + (++i)) != ' '); strncpy (tpl, path, i); if (*(path + i - 1) != '/') strcat (tpl, "/"); strcpy (certpl, tpl); strcat (certpl, "cer%06d"); strcpy (dattpl, tpl); strcat (dattpl, "dat%06d"); /* CBC strcpy (statpl, tpl); strcat (statpl, "sta%06d"); */ /* CBC sprintf (runfile, "%srun%06d", tpl, *runnum); sprintf (endfile, "%send%06d", tpl, *runnum); CBC */ sprintf (cerfile, certpl, *runnum); /* Added by CB */ sprintf (datfile, dattpl, *runnum); /* Added by CB */ } /*-------------------------------------------------- jcdatsave: graba un bloque al fichero de particulas --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jcdatsave_ (float *outbuf) #else /* JC_NO_UNDERSCORES */ void jcdatsave (float *outbuf) #endif /* JC_UNDERSCORES */ { /* puts("JCIO:: saving particle buffer..."); */ fwrite (outbuf, sizeof (float) * MAXBUF * NSUBBL, 1, patape); } /*-------------------------------------------------- jccersave: graba un bloque al fichero de particulas --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jccersave_ (float *outbuf) #else /* JC_NO_UNDERSCORES */ void jccersave (float *outbuf) #endif /* JC_UNDERSCORES */ { /* puts("JCIO:: saving cerenkov buffer..."); */ fwrite (outbuf, sizeof (float) * MAXBUF * NSUBBL, 1, cetape); } /*-------------------------------------------------- jcstartrun: abre el fichero run###### y graba el contenido NOW open CER and DAT files --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jcstartrun_ (void) #else /* JC_NO_UNDERSCORES */ void jcstartrun (void) #endif /* JC_UNDERSCORES */ { /* CBC if ((runtape = fopen (runfile, "wb")) == NULL) { printf ("JCIO:: Cannot open RUN file %s. Exiting.\n", runfile); exit (1); } CBC */ /* puts("JCIO:: saving runheader buffer..."); */ /* CBC fwrite (runh, sizeof (float) * MAXBUF, 1, runtape); CBC */ /* Following lines up to CBC added by CB */ if ((cetape = fopen (cerfile, "wb")) == NULL) { printf ("JCIO:: Cannot open CER file %s. Exiting.\n", cerfile); exit (1); } if ((patape = fopen (datfile, "wb")) == NULL) { printf ("JCIO:: Cannot open DAT file %s. Exiting.\n", datfile); exit (1); } /* CBC */ } /* WHAT FOLLOWS IS NO MORE USED !!!!!! CB */ /*-------------------------------------------------- jcstartshower: Function added by CB Sets timefirst and timelast variables to their initial value at the beginnng of new shower --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jcstartshower_ (float *evth) #else /* JC_NO_UNDERSCORES */ void jcstartshower (float *evth) #endif /* JC_UNDERSCORES */ { timefirst = 9.0e10; timelast = -9.0e10; } /*-------------------------------------------------- jctime: va echando cuentas del tiempo de los fotones --------------------------------------------------*/ #ifdef JC_UNDERSCORES void jctime_ (float *cartim) #else /* JC_NO_UNDERSCORES */ void jctime (float *cartim) #endif /* JC_UNDERSCORES */ { if (*cartim>timelast) timelast = *cartim; if (*cartim