// File: /workspace/github_c_makefile_star2_O3/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 0x4700(%rip), %rsi      # 0x68cb
callq 0x1160
movq %rax, %r15
movq 0x7e1e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r15, %r15
jne 0x21fa
leaq 0x43da(%rip), %rsi      # 0x65c3
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x266b
leaq 0x44aa(%rip), %rsi      # 0x66ab
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
leaq 0x14(%r14), %rcx
leaq 0x44ce(%rip), %rsi      # 0x66e4
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x18(%r14), %rcx
leaq 0x44be(%rip), %rsi      # 0x66ec
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0xc(%r14), %rcx
leaq 0x44ae(%rip), %rsi      # 0x66f4
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x10(%r14), %rcx
leaq 0x449e(%rip), %rsi      # 0x66fc
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x20(%r14), %rcx
leaq 0x448e(%rip), %rsi      # 0x6704
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x1c(%r14), %rcx
leaq 0x447e(%rip), %rsi      # 0x670c
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x8(%rbp), %rcx
leaq 0x446e(%rip), %rsi      # 0x6714
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
leaq 0x4474(%rip), %rsi      # 0x672e
movq %r15, %rdi
movl $0x69, %edx
movq %rbp, %rcx
callq 0x5770
cmpl $0x1, (%rbp)
jne 0x22e8
leaq 0x68(%rbp), %rcx
leaq 0x4469(%rip), %rsi      # 0x6744
movq %r15, %rdi
movl $0x73, %edx
callq 0x5770
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r14, 0x20(%rsp)
leaq 0x4(%rbp), %rcx
leaq 0x4454(%rip), %rsi      # 0x6756
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
cmpl $0x1, 0x4(%rbp)
jne 0x2353
leaq 0x130(%rbp), %rcx
leaq 0x4440(%rip), %rsi      # 0x6763
movq %r15, %rdi
movl $0x73, %edx
callq 0x5770
leaq 0x1f8(%rbp), %rcx
leaq 0x4437(%rip), %rsi      # 0x6775
movq %r15, %rdi
movl $0x73, %edx
callq 0x5770
movq %rbp, %rdi
callq 0x1e9c
leaq 0xc(%rbp), %r13
leaq 0x442e(%rip), %rsi      # 0x678c
movq %r15, %rdi
movl $0x69, %edx
movq %r13, %rcx
callq 0x5770
cmpl $0x0, 0xc(%rbp)
jle 0x23e2
addq $0x3c, %rbp
leaq 0x30(%rsp), %r12
leaq 0x4437(%rip), %rbx      # 0x67bb
xorl %r14d, %r14d
incq %r14
movq %r12, %rdi
leaq 0x440e(%rip), %rsi      # 0x67a2
movl %r14d, %edx
xorl %eax, %eax
callq 0x1180
leaq -0x28(%rbp), %rcx
movq %r15, %rdi
movq %r12, %rsi
movl $0x69, %edx
callq 0x5770
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 0x5770
movslq (%r13), %rax
addq $0x4, %rbp
cmpq %rax, %r14
jl 0x2387
leaq 0x43ea(%rip), %rsi      # 0x67d3
movq %r15, %rdi
movl $0x69, %edx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x5770
leaq 0x10(%rbx), %rcx
leaq 0x43d9(%rip), %rsi      # 0x67e2
movq %r15, %rdi
movl $0x73, %edx
callq 0x5770
leaq 0x43d2(%rip), %rsi      # 0x67ef
movq %r15, %rdi
movl $0x73, %edx
movq 0x28(%rsp), %rcx
callq 0x5770
leaq 0x4(%rbx), %rcx
leaq 0x43c1(%rip), %rsi      # 0x67fb
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0xc(%rbx), %rcx
leaq 0x43b7(%rip), %rsi      # 0x6809
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
addq $0x8, %rbx
leaq 0x43a7(%rip), %rsi      # 0x6811
movq %r15, %rdi
movl $0x66, %edx
movq %rbx, %rcx
callq 0x5770
movq 0x18(%rsp), %r12
leaq 0x14(%r12), %rcx
leaq 0x4391(%rip), %rsi      # 0x681c
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
leaq 0x4397(%rip), %rsi      # 0x6836
movq %r15, %rdi
movl $0x69, %edx
movq %r12, %rcx
callq 0x5770
leaq 0x8(%r12), %rcx
leaq 0x4394(%rip), %rsi      # 0x684f
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
cmpl $0x1, 0x8(%r12)
movq 0x20(%rsp), %r14
jne 0x2610
leaq 0x4(%r12), %rcx
leaq 0x4382(%rip), %rsi      # 0x6867
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
leaq 0x438a(%rip), %rsi      # 0x6883
leaq 0x6(%rsp), %rbx
movq %r15, %rdi
movl $0x73, %edx
movq %rbx, %rcx
callq 0x5770
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 0x433e(%rip), %rsi      # 0x6899
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
cmpl $0x0, 0xc(%r12)
je 0x25f5
leaq 0x18(%r12), %rcx
leaq 0x4334(%rip), %rsi      # 0x68b4
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
leaq 0x24(%r12), %rcx
leaq 0x4334(%rip), %rsi      # 0x68cd
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x28(%r12), %rcx
leaq 0x4325(%rip), %rsi      # 0x68d7
movq %r15, %rdi
movl $0x66, %edx
callq 0x5770
leaq 0x10(%r12), %rcx
leaq 0x4316(%rip), %rsi      # 0x68e1
movq %r15, %rdi
movl $0x69, %edx
callq 0x5770
cmpl $0x0, 0x10(%r12)
je 0x2610
addq $0x1c, %r12
leaq 0x430b(%rip), %rsi      # 0x68f6
movq %r15, %rdi
movl $0x69, %edx
jmp 0x2608
addq $0x2c, %r12
leaq 0x4311(%rip), %rsi      # 0x6911
movq %r15, %rdi
movl $0x66, %edx
movq %r12, %rcx
callq 0x5770
movq %r15, %rdi
callq 0x1080
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm1
movss 0x14(%r14), %xmm2
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movss 0x18(%r14), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subps %xmm0, %xmm1
movsd 0x1c(%r14), %xmm0
divps %xmm0, %xmm1
addps 0x3cd7(%rip), %xmm1     # 0x6320
cvttps2dq %xmm1, %xmm0
movq %xmm0, (%r14)
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
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