Skip to content

Commit

Permalink
Move parameter defaults into a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
keskitalo committed Sep 24, 2019
1 parent 9fdbbae commit 26b6500
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 67 deletions.
233 changes: 166 additions & 67 deletions src/commonparam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,38 @@ MODULE commonparam
real(dp), allocatable :: plateaus(:)
END TYPE detector_data

real(dp) :: fsample = 1 ! Sampling frequency
character(len=30) :: unit_tod = 'unknown'
real(dp) :: fsample ! Sampling frequency
character(len=30) :: unit_tod

! OpenMP
integer :: nthreads_max=1, nthreads=1, id_thread=0
integer :: nthreads_max, nthreads, id_thread
integer, external :: omp_get_num_procs, omp_get_max_threads, &
omp_get_thread_num, omp_get_num_threads

logical :: flag_by_horn=.false., force_pol=.false.
logical :: concatenate_messages = .true., allreduce = .false.
logical :: reassign_submaps = .true.
logical :: noise_weights_from_psd = .false. ! integrate noise weights internally
logical :: flag_by_horn, force_pol
logical :: concatenate_messages, allreduce, reassign_submaps
logical :: noise_weights_from_psd ! integrate noise weights internally
! Assume well-behaved noise spectrum without low pass filtering
logical :: radiometers = .true.
integer(i8b) :: psd_downsample=10
integer (i8b) :: psdlen=1e6
logical :: radiometers
integer(i8b) :: psd_downsample, psdlen
! Enable sub ring map making
integer(i2b) :: nsubchunk=0
integer(i2b) :: isubchunk=0
real(dp) :: fnoise_max=1000 ! When measuring noise variance, use this limit
integer(i2b) :: nsubchunk, isubchunk
real(dp) :: fnoise_max
character(len=SLEN) :: file_profile = ''
character(len=SLEN) :: file_intermediate_profile = ''
logical :: checknan=.false. ! Can cost time
real(dp) :: diagfilter=0
logical :: sync_output=.true., skip_existing=.false.
logical :: write_cut=.false.
logical :: tod_is_clean = .false.
logical :: binary_output=.false., concatenate_binary=.false.
logical :: checknan
real(dp) :: diagfilter
logical :: sync_output, skip_existing
logical :: write_cut
logical :: tod_is_clean
logical :: binary_output, concatenate_binary
! Used for concatenate_binary when storing multiple MC maps
integer :: record_number=1
integer :: record_number
! Number of independent groups of processes writing binary maps
integer(i4b) :: nwrite_binary = 10
integer(i4b) :: nwrite_binary
integer(i4b), parameter :: basis_poly=1, basis_fourier=2, basis_cheby=3, &
basis_legendre=4
integer(i4b) :: basis_func=basis_legendre, basis_order=0
integer(i4b) :: basis_func, basis_order
type :: basis_function_type
integer(i8b) :: nsamp
logical :: copy
Expand Down Expand Up @@ -100,71 +97,68 @@ MODULE commonparam
integer(i4b) :: nsurvey
logical(byte), allocatable :: surveyflags(:)

logical :: bin_subsets = .false.
logical :: mcmode = .false., cached = .false.
logical :: bin_subsets
logical :: mcmode, cached

real(dp) :: good_baseline_fraction=0 ! default accepts all baselines
real(dp) :: good_baseline_fraction
! monte Carlo mode
integer(idp) :: mc_increment=1e7, mc_loops=1, mc_id=0, rng_base=0
logical :: incomplete_matrices = .false.
integer(idp) :: mc_increment, mc_loops, mc_id, rng_base
logical :: incomplete_matrices

integer :: ID = 0
integer :: ntasks = 1
integer :: ID
integer :: ntasks

character(len=*), parameter :: version = '3.7'
character(len=*), parameter :: idf = '(i4,": ",a,1x,i0,2x,i0)'

! Input parameters
integer :: info=2
integer :: info

integer :: nside_map=512, nside_cross=-1, nside_submap=16
integer :: nside_map, nside_cross, nside_submap

real(dp) :: time_unit=-5.d0
real(dp) :: mission_time=0.0
integer :: nofiles=-1
real(dp) :: time_unit
real(dp) :: mission_time
integer :: nofiles

integer :: pixmode_map=2, pixmode_cross=2
real(dp) :: pixlim_map=1e-6, pixlim_cross=1e-3
logical :: allow_decoupling = .false.
integer :: pixmode_map, pixmode_cross
real(dp) :: pixlim_map, pixlim_cross
logical :: allow_decoupling

real(dp) :: dnshort=-1
integer :: nlong=-1, nshort=-1
logical :: kfirst=.true., kfilter=.false.
logical :: unaligned_fft=.false.
real(dp) :: dnshort
integer :: nlong, nshort
logical :: kfirst, kfilter
logical :: unaligned_fft

real(dp) :: cglimit=1.d-12
integer :: iter_min=3, iter_max=1000
integer :: precond_width_min=10, precond_width_max=100
logical :: use_fprecond=.false., use_cgprecond=.false.
real(dp) :: cglimit
integer :: iter_min, iter_max
integer :: precond_width_min, precond_width_max
logical :: use_fprecond, use_cgprecond

integer :: mode_detweight=0
integer :: mode_detweight

logical :: rm_monopole=.false., temperature_only=.false.
logical :: rm_monopole, temperature_only

! Input files
character(len=SLEN) :: file_param='', &
file_inmask='', file_spectrum='', file_gap=''
character(len=SLEN) :: file_param, file_inmask, file_spectrum, file_gap

! Output files
character(len=SLEN) :: file_root='madam'
character(len=SLEN) :: file_map='', file_hit='', file_base=''
character(len=SLEN) :: file_matrix='', file_mask='', file_binmap=''
character(len=SLEN) :: file_wcov='', file_leakmatrix=''
character(len=SLEN) :: file_gap_out='', file_mc='', path_output=''
character(len=SLEN) :: file_root, file_map, file_hit, file_base, &
file_matrix, file_mask, file_binmap, file_wcov, file_leakmatrix, &
file_gap_out, file_mc, path_output

logical :: write_tod=.false.
logical :: write_tod

! LFI specific keywords
character(len=80) :: instrument = ''
character(len=80) :: instrument

! NCVM specific parameters
logical :: kwrite_covmat=.false.
character(len=SLEN) :: file_covmat = ''
logical :: kwrite_covmat
character(len=SLEN) :: file_covmat

type(detector_data), allocatable, target :: detectors(:)

! Derived directly from input parameters
integer :: nmap=0, ncc=0, nside_max, nodetectors=-1
integer :: nmap, ncc, nside_max, nodetectors

! Pixels
integer :: nopix_map, nopix_cross
Expand All @@ -186,7 +180,7 @@ MODULE commonparam
real(i8b), allocatable :: baselines_short_time(:)

! Number of pointing periods and their duration as a number of samples
integer(i4b) :: ninterval = -1, ninterval_tot = -1
integer(i4b) :: ninterval, ninterval_tot
integer(i8b), allocatable :: intervals(:)
integer(i4b), allocatable :: interval_id(:)

Expand All @@ -196,14 +190,119 @@ MODULE commonparam
integer(i4b), allocatable :: id_submap(:)
integer(i4b) :: id_next, id_prev

logical :: do_map=.true., do_binmap=.false., do_hits=.false.
logical :: do_mask=.false., do_matrix=.false., do_wcov=.false.
logical :: do_base=.false., do_leakmatrix=.false.
logical :: do_wnmap=.false.
logical :: use_inmask

integer :: noiter = 0
logical :: do_map, do_binmap, do_hits, do_mask, do_matrix, do_wcov, do_base, &
do_leakmatrix, do_wnmap, use_inmask
integer :: noiter

!--------------------------------------------------------------------------

contains

subroutine set_parameter_defaults()
! Set or restore commonparam values to defaults
fsample = 1
unit_tod = "unknown"
nthreads_max = 1
nthreads = 1
id_thread = 1
flag_by_horn = .false.
force_pol = .false.
concatenate_messages = .true.
allreduce = .false.
reassign_submaps = .true.
noise_weights_from_psd = .false.
radiometers = .true.
psd_downsample = 10
psdlen = 1e6
nsubchunk = 0
isubchunk = 0
fnoise_max = 1000 ! When measuring noise variance, use this limit
checknan = .false. ! Can cost time
diagfilter = 0
sync_output = .true.
skip_existing = .false.
write_cut = .false.
tod_is_clean = .false.
binary_output = .false.
concatenate_binary = .false.
record_number = 1
nwrite_binary = 10
basis_func = basis_legendre
basis_order = 0
bin_subsets = .false.
mcmode = .false.
cached = .false.
good_baseline_fraction = 0 ! default accepts all baselines
mc_increment = 1e7
mc_loops = 1
mc_id = 0
rng_base = 0
incomplete_matrices = .false.
ID = 0
ntasks = 1
info = 2
nside_map = 512
nside_cross = -1
nside_submap = 16
time_unit = -5
mission_time = 0
nofiles = -1
pixmode_map = 2
pixmode_cross = 2
pixlim_map = 1e-6
pixlim_cross = 1e-3
allow_decoupling = .false.
dnshort = -1
nlong = -1
nshort = -1
kfirst = .true.
kfilter = .false.
unaligned_fft = .false.
cglimit = 1e-12
iter_min = 3
iter_max = 1000
precond_width_min = 10
precond_width_max = 100
use_fprecond = .false.
use_cgprecond = .false.
mode_detweight = 0
rm_monopole = .false.
temperature_only = .false.
file_param = ""
file_inmask = ""
file_spectrum = ""
file_gap = ""
file_root = "madam"
file_map = ""
file_hit = ""
file_base = ""
file_matrix = ""
file_mask = ""
file_binmap = ""
file_wcov = ""
file_leakmatrix = ""
file_gap_out = ""
file_mc = ""
path_output = ""
write_tod = .false.
instrument = ""
kwrite_covmat = .false.
file_covmat = ""
nmap = 0
ncc = 0
nodetectors = -1
ninterval = -1
ninterval_tot = -1
do_map = .true.
do_binmap = .false.
do_hits = .false.
do_mask = .false.
do_matrix = .false.
do_wcov = .false.
do_base = .false.
do_leakmatrix = .false.
do_wnmap = .false.
noiter = 0
end subroutine set_parameter_defaults

END MODULE commonparam
2 changes: 2 additions & 0 deletions src/smadam.F90
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ subroutine destripe(comm, parstring, ndet, detstring, detweights, &
integer(i2b) :: subchunkcounter
integer(i8b) :: pixmin, pixmax

call set_parameter_defaults()

! set up MPI

call init_mpi(comm, ntasks, id)
Expand Down

1 comment on commit 26b6500

@ickc
Copy link
Contributor

@ickc ickc commented on 26b6500 Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keskitalo, I found that after the change in this commit, it has segmentation fault when TOAST is calling it, at the stage it is "Constructing preconditioner". I'm using the Intel compilers:

$> ifort --version
ifort (IFORT) 19.0.4.243 20190416
Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.

I don't exactly sure this commit causes the problem however, as there's also another error when running TOAST tests using libmadam commits before this one: Madam fatal error: temperature_only=T but pointing weights are polarized, using TOAST 2.3.1.

Please sign in to comment.