maxMinTOD.f90

A Simple M3 example in Fortran of TOD processing which derives the maximum and minumum value from all of the timestreams in a Run Config.

00001 !first try, Columbia, Nov. 18th
00002 !Nicolas Ponthieu
00003 
00004 program minmaxtod
00005   
00006   use m3_typesf
00007   use m3_f
00008   implicit none
00009 
00010   type(m3_f77_runconfig) :: runconfig
00011   type(m3_f77_dataset) :: dataset
00012   type(m3_f77_interval) :: intervalnode !intervallist
00013 
00014   character(len=200) :: runconfig_file
00015 
00016   integer :: m3err, m3err1, m3err2, n_intervals, i_int, ios
00017   INTEGER(KIND=int8) ::firstsample, lastsample, n_samples, i
00018 
00019   !! m3err = 1 means "fine"
00020 
00021   real(kind=double), allocatable, dimension(:) :: tod
00022   real(kind=double) :: min, max
00023 
00024   !--------------------------------------------------------------------------
00025   max = -100000
00026   min =  100000
00027 
00028   runconfig_file = "madmap_test_littleendian_small.xml"
00029   
00030 
00031   !! Reading the runconfig_file
00032   m3err = m3_f77_runconfig_read( runconfig, runconfig_file, m3_springtide_run_type)
00033   
00034   !Get the first dataset (= detector)
00035   m3err = m3_f77_runconfig_getdatasetroot( runconfig, dataset)
00036 
00037   !!Loop over the data sets (descripted in the xml file)
00038   do while (m3err == 1)
00039      
00040      !get 1st interval in the list
00041      m3err2 = m3_f77_dataset_getcoveredintervalroot( dataset, intervalnode)
00042      
00043      do while (m3err2==1)
00044         
00045         !get this interval
00046         m3err2 = m3_f77_interval_getinterval( intervalnode, firstsample, lastsample )
00047         n_samples = lastsample - firstsample + 1
00048 
00049         !allocate memory
00050         allocate( tod(0:n_samples-1), stat=ios)
00051         if (ios /=0) then
00052            print*, "allocation error"
00053            stop
00054         endif
00055         
00056         !read the data in that interval
00057         m3err2 = m3_f77_dataset_gettod( dataset, firstsample, lastsample, tod )
00058         
00059         do i=0, n_samples-1
00060            if (tod(i) < min) min = tod(i)
00061            if (tod(i) > max) max = tod(i)
00062         enddo
00063         
00064         deallocate( tod)
00065         
00066         m3err2 = m3_f77_interval_getnextnodeinlist( intervalnode )
00067      enddo
00068 
00069      !to go the next dataset in the list
00070      m3err = m3_f77_dataset_getnextnodeinlist( dataset)
00071   enddo
00072 
00073   print*, "min = ", min
00074   print*, "max = ", max
00075 
00076 end program minmaxtod

Generated on Mon Nov 24 10:05:11 2008 for M3 by  doxygen 1.5.3-20071008