int gen_args ( char * dirname , int sw ) { FILE * fp ; char fname[NAMELEN] ; char * fn = "_args.inc" ; char * p ; int linelen ; char outstr[64*4096] ; if ( dirname == NULL ) return(1) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s%s%s",dirname, (sw==ACTUAL||sw==ACTUAL_NEW)?"actual":"dummy",(sw==ACTUAL_NEW||sw==DUMMY_NEW)?"_new":"",fn) ; } else { sprintf(fname,"%s%s%s", (sw==ACTUAL||sw==ACTUAL_NEW)?"actual":"dummy",(sw==ACTUAL_NEW||sw==DUMMY_NEW)?"_new":"",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; linelen = 0 ; strcpy(outstr,",") ; gen_args1 ( fp , outstr, (sw==ACTUAL||sw==ACTUAL_NEW)?"grid%":"", &Domain , &linelen , sw , 0 ) ; /* remove trailing comma */ if ((p=rindex(outstr,','))!=NULL) *p = '\0' ; fputs(outstr,fp);fputs(" &\n",fp) ; close_the_file( fp ) ; return(0) ; }
int scalar_derefs ( char * dirname ) { FILE * fp ; char fname[NAMELEN] ; char * fn = "scalar_derefs.inc" ; char * p ; int linelen ; char outstr[64*4096] ; if ( dirname == NULL ) return(1) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; fprintf(fp,"! BEGIN SCALAR DEREFS\n") ; linelen = 0 ; if ( sw_limit_args ) { fprintf(fp,"#undef CPY\n") ; fprintf(fp,"#undef CPYC\n") ; fprintf(fp,"#ifdef COPY_OUT\n") ; scalar_derefs1 ( fp , &Domain, DIR_COPY_OUT ) ; fprintf(fp,"#else\n") ; scalar_derefs1 ( fp , &Domain, DIR_COPY_IN ) ; fprintf(fp,"#endif\n") ; } fprintf(fp,"! END SCALAR DEREFS\n") ; close_the_file( fp ) ; return(0) ; }
/* This one is special; it gets called before the registry actually runs and produces a file that defines a lot of per-stream variables, mostly rconfig but also the oid state variables for each stream. This file is then included by the registry.io_boilerplate file when the registry actually runs. As with the other mods above, this allows a variable, compile-time number of io streams. Note that this one is self contained and dirname is hard-coded. */ int gen_io_boilerplate () { FILE * fp ; char * dirname = "Registry" ; char fname[NAMELEN] ; char * fn ; char * aux , *streamtype , streamno[5] ; char * howset = "namelist,time_control" ; char * maxd = "max_domains" ; int i, j ; fn = "io_boilerplate_temporary.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; fprintf(fp,"rconfig logical override_restart_timers namelist,time_control 1 .false.\n") ; for ( j = 0 ; j < 2 ; j++ ) { /* j=0 is hist, j=1 is input */ streamtype = (j==0)?"hist":"input" ; for ( i = 1 ; i < MAX_HISTORY ; i++ ) { fprintf(fp,"state integer aux%s%d_oid - - - - - \"\" \"\" \"\"\n",streamtype,i) ; fprintf(fp,"rconfig character aux%s%d_inname %s %s \"aux%s%d_d<domain>_<date>\"\n",streamtype,i,howset,"1",streamtype,i) ; fprintf(fp,"rconfig character aux%s%d_outname %s %s \"aux%s%d_d<domain>_<date>\"\n",streamtype,i,howset,"1",streamtype,i) ; fprintf(fp,"rconfig integer aux%s%d_interval_y %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_interval_d %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_interval_h %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_interval_m %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_interval_s %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_interval %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin_y %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin_d %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin_h %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin_m %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin_s %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_begin %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end_y %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end_d %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end_h %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end_m %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end_s %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer aux%s%d_end %s %s 0\n",streamtype,i,howset,maxd) ; fprintf(fp,"rconfig integer io_form_aux%s%d %s %s 0\n",streamtype,i,howset,"1") ; fprintf(fp,"rconfig integer frames_per_aux%s%d %s %s 999999\n",streamtype,i,howset,maxd) ; } } close_the_file( fp ) ; }
int add_warning ( char * fname ) { FILE * fp ; char tempfile[NAMELEN] ; char tempfile1[NAMELEN] ; char commline[4096] ; sprintf(tempfile,"regtmp1%d",getpid()) ; sprintf(tempfile1,"regtmp2%d",getpid()) ; if (( fp = fopen( tempfile, "w" )) == NULL ) return(1) ; print_warning(fp,tempfile) ; close_the_file(fp) ; sprintf(commline,"%s %s %s > %s ; %s %s %s ; %s %s ", CATCOMM,tempfile,fname,tempfile1, MVCOMM,tempfile1,fname, RMCOMM,tempfile) ; return(system(commline)) ; }
int gen_scalar_indices ( char * dirname ) { FILE * fp, *fp5[7] ; char fname[NAMELEN], fname5[NAMELEN] ; char * fn = "scalar_indices.inc" ; char * fn2 = "scalar_tables.inc" ; char * fn3 = "scalar_tables_init.inc" ; char * fn4 = "scalar_indices_init.inc" ; int i ; char fn5[7][NAMELEN] ; strcpy( fn5[0], "in_use_for_config_ac.inc" ) ; /* hashing to make the run time function being generated faster */ strcpy( fn5[1], "in_use_for_config_df.inc" ) ; strcpy( fn5[2], "in_use_for_config_gk.inc" ) ; strcpy( fn5[3], "in_use_for_config_ln.inc" ) ; strcpy( fn5[4], "in_use_for_config_os.inc" ) ; strcpy( fn5[5], "in_use_for_config_tw.inc" ) ; strcpy( fn5[6], "in_use_for_config_xz.inc" ) ; strcpy( fname, fn ) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; for ( i = 0 ; i < 7 ; i++ ) { strcpy( fname5, fn5[i] ) ; if ( strlen(dirname) > 0 ) { sprintf(fname5,"%s/%s",dirname,fn5[i]) ; } if ((fp5[i] = fopen( fname5 , "w" )) == NULL ) return(1) ; print_warning(fp5[i],fname5) ; } gen_scalar_indices1 ( fp, fp5 ) ; close_the_file( fp ) ; for ( i = 0 ; i < 7 ; i++ ) { close_the_file( fp5[i] ) ; } strcpy( fname, fn2 ) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn2) ; } if ((fp = fopen( fname , "w" )) == NULL ) { fprintf(stderr,"returning\n") ; return(1) ; } print_warning(fp,fname) ; gen_scalar_tables ( fp ) ; close_the_file( fp ) ; strcpy( fname, fn3 ) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn3) ; } if ((fp = fopen( fname , "w" )) == NULL ) { fprintf(stderr,"returning\n") ; return(1) ; } print_warning(fp,fname) ; gen_scalar_tables_init ( fp ) ; close_the_file( fp ) ; strcpy( fname, fn4 ) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn4) ; } if ((fp = fopen( fname , "w" )) == NULL ) { fprintf(stderr,"returning\n") ; return(1) ; } print_warning(fp,fname) ; gen_scalar_indices_init ( fp ) ; close_the_file( fp ) ; return(0) ; }
int gen_streams( char * dirname ) { FILE * fp ; char fname[NAMELEN] ; char * fn ; if ( dirname == NULL ) return(1) ; fn = "module_io_domain_defs.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_io_domain_defs( fp ) ; close_the_file( fp ) ; fn = "set_timekeeping_defs.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_set_timekeeping_defs( fp ) ; close_the_file( fp ) ; fn = "set_timekeeping_alarms.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_set_timekeeping_alarms( fp ) ; close_the_file( fp ) ; fn = "io_form_for_dataset.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_io_form_for_dataset( fp ) ; close_the_file( fp ) ; fn = "io_form_for_stream.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_io_form_for_stream( fp ) ; close_the_file( fp ) ; fn = "switches_and_alarms.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_switches_and_alarms( fp ) ; close_the_file( fp ) ; fn = "check_auxstream_alarms.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_check_auxstream_alarms( fp ) ; close_the_file( fp ) ; fn = "fine_stream_input.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_fine_stream_input( fp ) ; close_the_file( fp ) ; fn = "med_auxinput_in.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_auxinput_in( fp ) ; close_the_file( fp ) ; fn = "med_hist_out_opens.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_hist_out_opens( fp ) ; close_the_file( fp ) ; fn = "med_hist_out_closes.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_hist_out_closes( fp ) ; close_the_file( fp ) ; fn = "med_auxinput_in_closes.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_auxinput_in_closes( fp ) ; close_the_file( fp ) ; fn = "med_last_solve_io.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_last_solve_io( fp ) ; close_the_file( fp ) ; fn = "med_open_esmf_calls.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_open_esmf_calls( fp ) ; close_the_file( fp ) ; fn = "med_find_esmf_coupling.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_med_find_esmf_coupling( fp ) ; close_the_file( fp ) ; fn = "shutdown_closes.inc" ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; gen_shutdown_closes( fp ) ; close_the_file( fp ) ; return(0) ; }