bianchi2_lut_gen.f90
Go to the documentation of this file.
1 !----------------------------------------------------------------------------
2 ! bianchi2_lut_gen -- BIANCHI2 writting LUT program
3 !
19 !----------------------------------------------------------------------------
20 
22 
23  use s2_types_mod
25 
26  implicit none
27 
28  type(bianchi2_lut) :: lut
29  integer :: lmax, ntheta
30  character(len=S2_STRING_LEN) :: filename_lut
31 
32  !Get the arguments.
33  call parse_options
34 
35  ! Initialize the lut.
36  lut = bianchi2_lut_init(lmax,ntheta)
37 
38  ! Write the lut into a file.
39  call bianchi2_lut_write(lut,filename_lut)
40  write(*,'(a)') 'LUT written in '//trim(filename_lut)
41 
42 
43  contains
44 
45  !------------------------------------------------------------------------
46  ! Parse options
47  !
51  !------------------------------------------------------------------------
52 
53  subroutine parse_options
54 
55  use extension, only: getargument, narguments
56 
57  implicit none
58 
59  integer :: n, i
60  character(len=S2_STRING_LEN) :: arg
61  character(len=S2_STRING_LEN) :: opt
62 
63  n = narguments()
64 
65  do i = 1,n,2
66 
67  call getargument(i,opt)
68 
69  if (i == n .and. trim(opt) /= '-help') then
70  write(*,'(a,a,a)') 'Option ', trim(opt), ' has no argument'
71  stop
72  end if
73 
74  if(trim(opt) /= '-help') call getargument(i+1,arg)
75 
76  ! Read each argument in turn
77  select case (trim(opt))
78 
79  case ('-help')
80  write(*,'(a)') 'Usage: bianchi2_lut_gen [-lmax lmax]'
81  write(*,'(a)') ' [-Ntheta Ntheta]'
82  write(*,'(a)') ' [-out filename_LUT]'
83  stop
84 
85  case ('-lmax')
86  read(arg,*) lmax
87 
88  case ('-Ntheta')
89  read(arg,*) ntheta
90 
91  case ('-out')
92  filename_lut = trim(arg)
93 
94  case default
95  print '("Unknown option ",a," ignored")', trim(opt)
96 
97  end select
98  end do
99 
100  end subroutine parse_options
101 
102 
103 end program bianchi2_lut_gen