📄 get_global_param.c
字号:
if(strcasecmp("FALSE",flgstr)==0) options.COMPUTE_TREELINE=FALSE; else { options.COMPUTE_TREELINE = TRUE; options.AboveTreelineVeg = atoi( flgstr ); } } /************************************ Get Forcing Data File Information **********************************/ else if(strcasecmp("FORCING1",optstr)==0) { sscanf(cmdstr,"%*s %s",names->forcing[0]); file_num = 0; field=0; } else if(strcasecmp("FORCING2",optstr)==0) { sscanf(cmdstr,"%*s %s",names->forcing[1]); file_num = 1; field=0; } else if(strcasecmp("N_TYPES",optstr)==0) { sscanf(cmdstr,"%*s %i",¶m_set.N_TYPES[file_num]); } else if(strcasecmp("FORCE_TYPE",optstr)==0) { get_force_type(cmdstr,file_num,&field); } else if(strcasecmp("FORCE_DT",optstr)==0) { sscanf(cmdstr,"%*s %i ", ¶m_set.FORCE_DT[file_num]); } else if (strcasecmp("FORCE_ENDIAN",optstr)==0) { sscanf(cmdstr, "%*s %s", flgstr); if (strcasecmp(flgstr, "LITTLE") == 0) param_set.FORCE_ENDIAN[file_num] = LITTLE; else if (strcasecmp(flgstr, "BIG") == 0) param_set.FORCE_ENDIAN[file_num] = BIG; else nrerror("FORCE_ENDIAN must be either BIG or LITTLE."); } else if (strcasecmp("FORCE_FORMAT",optstr)==0) { sscanf(cmdstr, "%*s %s", flgstr); if (strcasecmp(flgstr, "BINARY") == 0) param_set.FORCE_FORMAT[file_num] = BINARY; else if (strcasecmp(flgstr, "ASCII") == 0) param_set.FORCE_FORMAT[file_num] = ASCII; else nrerror("FORCE_FORMAT must be either ASCII or BINARY."); } /************************************ Get Information for Parameter Files ************************************/ else if(strcasecmp("SOIL",optstr)==0) { sscanf(cmdstr,"%*s %s",names->soil); } else if(strcasecmp("SOIL_DIR",optstr)==0) { sscanf(cmdstr,"%*s %s",names->soil_dir); } else if(strcasecmp("VEGPARAM",optstr)==0) { sscanf(cmdstr,"%*s %s",names->veg); } else if(strcasecmp("VEGLIB",optstr)==0) { sscanf(cmdstr,"%*s %s",names->veglib); } else if(strcasecmp("GLOBAL_LAI",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) options.GLOBAL_LAI=TRUE; else options.GLOBAL_LAI = FALSE; } else if(strcasecmp("RESULT_DIR",optstr)==0) { sscanf(cmdstr,"%*s %s",names->result_dir); } /****************************** Get Model Debugging Options ****************************/#if LINK_DEBUG else if(strcasecmp("PRT_FLUX",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_FLUX=TRUE; else debug.PRT_FLUX = FALSE; } else if(strcasecmp("PRT_BALANCE",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_BALANCE=TRUE; else debug.PRT_BALANCE = FALSE; } else if(strcasecmp("PRT_SOIL",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_SOIL=TRUE; else debug.PRT_SOIL = FALSE; } else if(strcasecmp("PRT_VEGE",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_VEGE=TRUE; else debug.PRT_VEGE = FALSE; } else if(strcasecmp("PRT_GLOBAL",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_GLOBAL=TRUE; else debug.PRT_GLOBAL = FALSE; } else if(strcasecmp("PRT_ATMOS",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_ATMOS=TRUE; else debug.PRT_ATMOS = FALSE; } else if(strcasecmp("PRT_SNOW",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_SNOW=TRUE; else debug.PRT_SNOW = FALSE; } else if(strcasecmp("PRT_MOIST",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_MOIST=TRUE; else debug.PRT_MOIST = FALSE; } else if(strcasecmp("PRT_TEMP",optstr)==0) { sscanf(cmdstr,"%*s %s",flgstr); if(strcasecmp("TRUE",flgstr)==0) debug.PRT_TEMP=TRUE; else debug.PRT_TEMP = FALSE; } else if(strcasecmp("DEBUG_DIR",optstr)==0) { sscanf(cmdstr,"%*s %s",debug.debug_dir); }#endif /*********************************** Unrecognized Global Parameter Flag ***********************************/ else { fprintf(stderr,"WARNING: Unrecognized option in the global parameter file:\n\t%s is unknown - check your spelling\n", optstr); } } fgets(cmdstr,MAXSTRING,gp); } /****************************************** Check for undefined required parameters ******************************************/ for(i=0;i<2;i++) { if ( i == 0 || (i == 1 && param_set.N_TYPES[i] != MISSING) ) { if (param_set.N_TYPES[i] == MISSING) { sprintf(ErrStr,"Need to specify the number forcing variables types in forcing file %i.", i); nrerror(ErrStr); } if (param_set.FORCE_FORMAT[i] == MISSING) { sprintf(ErrStr,"Need to specify the INPUT_FORMAT (ASCII or BINARY) for forcing file %i.",i); nrerror(ErrStr); } if (param_set.FORCE_INDEX[i][param_set.N_TYPES[i]-1] == MISSING) { sprintf(ErrStr,"Did not define enough forcing variables in forcing file %i.",i); nrerror(ErrStr); } if(param_set.FORCE_DT[i] == MISSING ) { sprintf(ErrStr,"Must define time steps (FORCE_DT <dt>) in control file for focing file %i.",file_num); nrerror(ErrStr); } } } if(param_set.N_TYPES[1] != MISSING && global.forceyear[1] == MISSING) { global.forceyear[1] = global.forceyear[0]; global.forcemonth[1] = global.forcemonth[0]; global.forceday[1] = global.forceday[0]; global.forcehour[1] = global.forcehour[0]; global.forceskip[1] = 0; } if(options.ROOT_ZONES<0) nrerror("ROOT_ZONES must be defined to a positive integer greater than 0, in the global control file."); if(options.Nlayer > MAX_LAYERS) { sprintf(ErrStr,"Global file wants more soil moisture layers (%i) than are defined by MAX_LAYERS (%i). Edit user_def.h and recompile.",options.Nlayer,MAX_LAYERS); nrerror(ErrStr); } if(options.Nnode > MAX_NODES) { sprintf(ErrStr,"Global file wants more soil thermal nodes (%i) than are defined by MAX_NODES (%i). Edit user_def.h and recompile.",options.Nnode,MAX_NODES); nrerror(ErrStr); } if((options.FULL_ENERGY || options.FROZEN_SOIL) && options.Nnode<3) { sprintf(ErrStr,"You must define at least 3 soil thermal nodes to run the model in FULL_ENERGY or FROZEN_SOIL modes. Currently Nnodes is set to %i.",options.Nnode); nrerror(ErrStr); } if(!options.QUICK_FLUX && options.Nnode<4) { sprintf(ErrStr,"You must define at least 4 soil thermal nodes to run the model with the finite difference ground heat flux solution. Currently Nnodes is set to %i.",options.Nnode); nrerror(ErrStr); } if((options.FULL_ENERGY || options.FROZEN_SOIL) && options.Nlayer<3) { sprintf(ErrStr,"You must define at least 3 soil moisture layers to run the model in FULL_ENERGY or FROZEN_SOIL modes. Currently Nlaeyrs is set to %i.",options.Nlayer); nrerror(ErrStr); } if(options.SNOW_BAND > MAX_BANDS) { sprintf(ErrStr,"Global file wants more snow bands (%i) than are defined by MAX_BANDS (%i). Edit user_def.h and recompile.",options.SNOW_BAND,MAX_BANDS); nrerror(ErrStr); }#if SAVE_STATE if ( strcmp( names->init_state, global.statename ) == 0 ) { sprintf(ErrStr,"The save state file (%s) has the same name as the initialize state file (%s). The initialize state file will be destroyed when the save state file is opened.", global.statename, names->init_state); nrerror(ErrStr); }#endif /* set NR and NF */ if (global.dt < 24 && global.dt != options.SNOW_STEP) nrerror("If the model step is smaller than daily, the snow model should run\nat the same time step as the rest of the model."); NF = global.dt/options.SNOW_STEP; if (global.dt % options.SNOW_STEP != 0 || options.SNOW_STEP > global.dt) nrerror("SNOW_STEP should be smaller than TIME_STEP and divide TIME_STEP evenly "); if (NF == 1) NR = 0; else NR = NF; /********************************* Output major options to stderr *********************************/#if VERBOSE display_current_settings(DISP_ALL,names,&global);#else display_current_settings(DISP_VERSION,names,&global);#endif#if VERBOSE fprintf(stderr,"Time Step = %i hour(s)\n",global.dt); fprintf(stderr,"Simulation start date = %02i/%02i/%04i\n", global.startday, global.startmonth, global.startyear); if ( global.nrecs > 0 ) fprintf(stderr,"Number of Records = %i\n\n",global.nrecs); else fprintf(stderr,"Simulation end date = %02i/%02i/%04i\n\n", global.endday, global.endmonth, global.endyear); fprintf(stderr,"Full Energy...................(%i)\n",options.FULL_ENERGY); fprintf(stderr,"Use Distributed Precipitation.(%i)\n",options.DIST_PRCP); if(options.DIST_PRCP) fprintf(stderr,"..Using Precipitation Exponent of %f\n",options.PREC_EXPT); if ( options.GRND_FLUX ) { fprintf(stderr,"Ground heat flux will be estimated "); if ( options.QUICK_FLUX ) fprintf(stderr,"using Liang, Wood and Lettenmaier (1999).\n"); else fprintf(stderr,"using Cherkauer and Lettenmaier (1999).\n"); } else fprintf(stderr,"Ground heat flux not computed (no energy balance).\n"); fprintf(stderr,"Use Frozen Soil Model.........(%i)\n",options.FROZEN_SOIL); if ( QUICK_FS ) fprintf(stderr,".... Using linearized UFWC curve with %i temperatures.\n", QUICK_FS_TEMPS); fprintf(stderr,"Run Snow Model Using a Time Step of %i hours\n", options.SNOW_STEP); fprintf(stderr,"Compress Output Files.........(%i)\n",options.COMPRESS); fprintf(stderr,"Correct Precipitation.........(%i)\n",options.CORRPREC); fprintf(stderr,"\n"); fprintf(stderr,"Using %i Snow Bands\n",options.SNOW_BAND); fprintf(stderr,"Using %i Root Zones\n",options.ROOT_ZONES);#if SAVE_STATE if ( global.stateyear != MISSING ) fprintf(stderr,"Model state will be saved on = %02i/%02i/%04i\n\n", global.stateday, global.statemonth, global.stateyear);#endif if ( OPTIMIZE ) fprintf(stderr,"Model is using optimized output (runoff and baseflow only).\n"); else if ( LDAS_OUTPUT ) fprintf(stderr,"Model output is in LDAS binary short int format.\n"); else if ( options.BINARY_OUTPUT ) fprintf(stderr,"Model output is in standard BINARY format.\n"); else fprintf(stderr,"Model output is in standard ASCII format.\n"); if ( LINK_DEBUG ) fprintf(stderr,"Debugging code has been included in the executable.\n"); else fprintf(stderr,"Debugging code has not been compiled.\n");#endif return global;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -