// File: /workspace/github_c_makefile_star2_O1/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/read_write_params.c
// Function: read_params_new
int read_params_new(char *parf, struct compl_levels* cat_comp, struct boundaries* reg, 
  struct catalog* cat, struct smoothp* smp, char *outfnm) 
/*--------------------------------------------------------------------------*/
{
  FILE *fpparam;
  int cnt;
//  char buff[BUFFLEN];
  char parseaux[256], gauss_plaw[10];
  
// open file
  if( (fpparam = fopen(parf, "r"))==NULL) {
    fprintf(stderr,"Parameter file not found, %s\n", parf);
    return 0;
  }
  fprintf(stderr,"Reading from parameter file, %s - new formatting style.\n", parf);

// read parameters
  Parse_Text(fpparam, "Min_Lat",'f', &(reg->minlat) );
  Parse_Text(fpparam, "Max_Lat",'f', &(reg->maxlat) );
  Parse_Text(fpparam, "Min_Lon",'f', &(reg->minlon) );
  Parse_Text(fpparam, "Max_Lon",'f', &(reg->maxlon) );
  Parse_Text(fpparam, "Inc_Lat",'f', &(reg->dlat) );
  Parse_Text(fpparam, "Inc_Lon",'f', &(reg->dlon) );
  Parse_Text(fpparam, "Correct_Area_for_Latitude",'i', &(cat_comp->correctAreaForLat) );
  Parse_Text(fpparam, "Variable_Completeness",'i', &(cat_comp->variableCompleteness) );
  if ( (cat_comp->variableCompleteness) == 1 ) {
    Parse_Text(fpparam, "Completeness_File",'s', &(cat_comp->completenessFile) );
  }
  Parse_Text(fpparam, "Catalog_Gaps",'i', &(cat_comp->catalogGaps) );
  if ( (cat_comp->catalogGaps) == 1 ) {
    Parse_Text(fpparam, "Catalog_Gaps_File",'s', &(cat_comp->catalogGapsFile) );
    Parse_Text(fpparam, "Polygons_for_Gaps_Path", 's', &(cat_comp->catalogGapsPolygonPath));
    load_poly_data(cat_comp);
  }
  Parse_Text(fpparam, "N_Completeness_Levels",'i', &(cat_comp->nlevels) );
  for (cnt=0; cnt<cat_comp->nlevels; cnt++) {
    sprintf(parseaux,"Completeness_Level_yr_%d", cnt+1);
    Parse_Text(fpparam,parseaux,'i', &(cat_comp->yr_comp[cnt]) );
    sprintf(parseaux,"Completeness_Level_M_%d", cnt+1);
    Parse_Text(fpparam,parseaux,'f', &(cat_comp->mag_comp[cnt]) );
  }
  Parse_Text(fpparam, "End_yr_Catalog",'i', &(cat->end_yr) );
  Parse_Text(fpparam, "Catalog_Name",'s', &(cat->catnm) );
  Parse_Text(fpparam, "Output_Name",'s', outfnm);
  Parse_Text(fpparam, "Min_Magnitude",'f', &(cat->minMag) );
  Parse_Text(fpparam, "b_Value",'f', &(cat->bval) );
  Parse_Text(fpparam, "dMag_value",'f', &(cat->dMag) );
// logical values
  Parse_Text(fpparam, "logical_Effective_Num_Eqs",'i', &(smp->use_neff) );
  Parse_Text(fpparam, "logical_Cumulative_rates",'i', &(smp->cumul_rates) );
  Parse_Text(fpparam, "logical_Apply_smoothing",'i', &(smp->apply_sm) );
  if ( (smp->apply_sm) == 1 ) {
    Parse_Text(fpparam, "logical_Adjust_completeness",'i', &(smp->adj_compl) );
    Parse_Text(fpparam, "Gauss_PowerLaw_Kernel",'s', gauss_plaw);
    if ( STREQ(gauss_plaw,"gauss") ) {
      smp->gauss_kern=1;
    }
    else if ( STREQ(gauss_plaw,"powerLaw") ) {
      smp->gauss_kern=0;
    }
    else {
      fprintf(stderr,"No kernel option for %s. User must enter gauss or powerLaw for kernel-type.\n", gauss_plaw);
      exit(1);
    }
    Parse_Text(fpparam, "logical_Adaptive_smoothing",'i', &(smp->adapt_sm) );
    if ( (smp->adapt_sm) ) {
      Parse_Text(fpparam, "Adaptive_Neighbor_Number",'i', &(smp->nnum) );
      Parse_Text(fpparam, "Sigma_Min",'f', &(smp->sigmin) );
      Parse_Text(fpparam, "Sigma_Max",'f', &(smp->sigmax) );
      Parse_Text(fpparam, "logical_Avg_Neighbor",'i', &(smp->nnum2_log) );
      if (smp->nnum2_log) {
        Parse_Text(fpparam, "Adaptive_Neighbor_Number_2",'i', &(smp->nnum2) );
      }
    }
    else {
      Parse_Text(fpparam, "Sigma_Fix",'f', &(smp->sigfix) );
    }
  }
  fclose(fpparam);

// get numbers of points in x-, y-directions
  reg->nsx=(int)( (reg->maxlon-reg->minlon)/reg->dlon +1);
  reg->nsy=(int)( (reg->maxlat-reg->minlat)/reg->dlat +1 );
  reg->nsrc=reg->nsx*reg->nsy;

  return 1;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r9, 0x28(%rsp)
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x46ec(%rip), %rsi      # 0x68b7
callq 0x1160
movq %rax, %r15
movq 0x7e1e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r15, %r15
jne 0x21fa
leaq 0x43c6(%rip), %rsi      # 0x65af
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x2667
leaq 0x4496(%rip), %rsi      # 0x6697
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
leaq 0x14(%r14), %rcx
leaq 0x44ba(%rip), %rsi      # 0x66d0
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x18(%r14), %rcx
leaq 0x44aa(%rip), %rsi      # 0x66d8
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0xc(%r14), %rcx
leaq 0x449a(%rip), %rsi      # 0x66e0
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x10(%r14), %rcx
leaq 0x448a(%rip), %rsi      # 0x66e8
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x20(%r14), %rcx
leaq 0x447a(%rip), %rsi      # 0x66f0
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x1c(%r14), %rcx
leaq 0x446a(%rip), %rsi      # 0x66f8
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x8(%rbp), %rcx
leaq 0x445a(%rip), %rsi      # 0x6700
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
leaq 0x4460(%rip), %rsi      # 0x671a
movq %r15, %rdi
movl $0x69, %edx
movq %rbp, %rcx
callq 0x5744
cmpl $0x1, (%rbp)
jne 0x22e8
leaq 0x68(%rbp), %rcx
leaq 0x4455(%rip), %rsi      # 0x6730
movq %r15, %rdi
movl $0x73, %edx
callq 0x5744
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r14, 0x20(%rsp)
leaq 0x4(%rbp), %rcx
leaq 0x4440(%rip), %rsi      # 0x6742
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
cmpl $0x1, 0x4(%rbp)
jne 0x2353
leaq 0x130(%rbp), %rcx
leaq 0x442c(%rip), %rsi      # 0x674f
movq %r15, %rdi
movl $0x73, %edx
callq 0x5744
leaq 0x1f8(%rbp), %rcx
leaq 0x4423(%rip), %rsi      # 0x6761
movq %r15, %rdi
movl $0x73, %edx
callq 0x5744
movq %rbp, %rdi
callq 0x1e9c
leaq 0xc(%rbp), %r13
leaq 0x441a(%rip), %rsi      # 0x6778
movq %r15, %rdi
movl $0x69, %edx
movq %r13, %rcx
callq 0x5744
cmpl $0x0, 0xc(%rbp)
jle 0x23e2
addq $0x3c, %rbp
leaq 0x30(%rsp), %r12
leaq 0x4423(%rip), %rbx      # 0x67a7
xorl %r14d, %r14d
incq %r14
movq %r12, %rdi
leaq 0x43fa(%rip), %rsi      # 0x678e
movl %r14d, %edx
xorl %eax, %eax
callq 0x1180
leaq -0x28(%rbp), %rcx
movq %r15, %rdi
movq %r12, %rsi
movl $0x69, %edx
callq 0x5744
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1180
movq %r15, %rdi
movq %r12, %rsi
movl $0x66, %edx
movq %rbp, %rcx
callq 0x5744
movslq (%r13), %rax
addq $0x4, %rbp
cmpq %rax, %r14
jl 0x2387
leaq 0x43d6(%rip), %rsi      # 0x67bf
movq %r15, %rdi
movl $0x69, %edx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x5744
leaq 0x10(%rbx), %rcx
leaq 0x43c5(%rip), %rsi      # 0x67ce
movq %r15, %rdi
movl $0x73, %edx
callq 0x5744
leaq 0x43be(%rip), %rsi      # 0x67db
movq %r15, %rdi
movl $0x73, %edx
movq 0x28(%rsp), %rcx
callq 0x5744
leaq 0x4(%rbx), %rcx
leaq 0x43ad(%rip), %rsi      # 0x67e7
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0xc(%rbx), %rcx
leaq 0x43a3(%rip), %rsi      # 0x67f5
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
addq $0x8, %rbx
leaq 0x4393(%rip), %rsi      # 0x67fd
movq %r15, %rdi
movl $0x66, %edx
movq %rbx, %rcx
callq 0x5744
movq 0x18(%rsp), %r12
leaq 0x14(%r12), %rcx
leaq 0x437d(%rip), %rsi      # 0x6808
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
leaq 0x4383(%rip), %rsi      # 0x6822
movq %r15, %rdi
movl $0x69, %edx
movq %r12, %rcx
callq 0x5744
leaq 0x8(%r12), %rcx
leaq 0x4380(%rip), %rsi      # 0x683b
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
cmpl $0x1, 0x8(%r12)
movq 0x20(%rsp), %r14
jne 0x2610
leaq 0x4(%r12), %rcx
leaq 0x436e(%rip), %rsi      # 0x6853
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
leaq 0x4376(%rip), %rsi      # 0x686f
leaq 0x6(%rsp), %rbx
movq %r15, %rdi
movl $0x73, %edx
movq %rbx, %rcx
callq 0x5744
movl $0x73756167, %eax       # imm = 0x73756167
xorl (%rbx), %eax
movzwl 0x4(%rbx), %ecx
xorl $0x73, %ecx
orl %eax, %ecx
je 0x2545
movabsq $0x77614c7265776f70, %rcx # imm = 0x77614C7265776F70
xorq 0x6(%rsp), %rcx
movzbl 0xe(%rsp), %edx
xorl %eax, %eax
orq %rcx, %rdx
je 0x254a
leaq 0x6(%rsp), %rdi
callq 0x13e0
movl $0x1, %eax
movl %eax, 0x20(%r12)
leaq 0xc(%r12), %rcx
leaq 0x432a(%rip), %rsi      # 0x6885
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
cmpl $0x0, 0xc(%r12)
je 0x25f5
leaq 0x18(%r12), %rcx
leaq 0x4320(%rip), %rsi      # 0x68a0
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
leaq 0x24(%r12), %rcx
leaq 0x4320(%rip), %rsi      # 0x68b9
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x28(%r12), %rcx
leaq 0x4311(%rip), %rsi      # 0x68c3
movq %r15, %rdi
movl $0x66, %edx
callq 0x5744
leaq 0x10(%r12), %rcx
leaq 0x4302(%rip), %rsi      # 0x68cd
movq %r15, %rdi
movl $0x69, %edx
callq 0x5744
cmpl $0x0, 0x10(%r12)
je 0x2610
addq $0x1c, %r12
leaq 0x42f7(%rip), %rsi      # 0x68e2
movq %r15, %rdi
movl $0x69, %edx
jmp 0x2608
addq $0x2c, %r12
leaq 0x42fd(%rip), %rsi      # 0x68fd
movq %r15, %rdi
movl $0x66, %edx
movq %r12, %rcx
callq 0x5744
movq %r15, %rdi
callq 0x1080
movss 0x10(%r14), %xmm0
subss 0xc(%r14), %xmm0
movss 0x18(%r14), %xmm1
divss 0x1c(%r14), %xmm0
movss 0x3ce0(%rip), %xmm2     # 0x6318
addss %xmm2, %xmm0
cvttss2si %xmm0, %eax
movl %eax, (%r14)
subss 0x14(%r14), %xmm1
divss 0x20(%r14), %xmm1
addss %xmm2, %xmm1
cvttss2si %xmm1, %ecx
movl %ecx, 0x4(%r14)
imull %eax, %ecx
movl %ecx, 0x8(%r14)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq