! Select dated diretories subroutine get_all_dated_directories (n, dir) use sim_utils implicit none character*300 dir_file character*300 dir(300) character*20 dir_min, dir_max character*20 dated_dir character*200 cwd character*200 string, new_string character*2 cnum character*100 file_string logical itexists, first/.true./ integer reason, n integer, save :: lun, lun2 integer number_files integer ngood_file integer min_date/0/,max_date/20300000/, min_time/0/, max_time/999999/, date, time integer nargs dir(1)=' ' nargs = command_argument_count() if (nargs == 1)then call cesr_getarg(1,dir(1)) ! the data is all in a single directory input directory name on command line ! print *, 'len(trim(dir(1)))= ',len(trim(dir(1))) number_files=1 print '(i10,1x,a19)', number_files,dir(1) else if( nargs == 2)then call cesr_getarg(1,dir_min) call cesr_getarg(2,dir_max) read(dir_min(1:8),*)min_date read(dir_min(10:15),*)min_time read(dir_max(1:8),*)max_date read(dir_max(10:15),*)max_time endif call getcwd(cwd) !if all directories are to be combined, input nothing on command line string='ls > out.dat' call execute_command_line(string) lun=lunget() open(unit=lun,file='out.dat', status='old') n=0 do while(.true.) read(lun, '(a)', IOSTAT = reason)new_string if(reason < 0)exit if( (index(new_string,'2020')==0) .and. (index(new_string,'2019')==0) .and. (index(new_string,'2021')==0) .and. (index(new_string,'2022')== 0) .and. & index(new_string,'2023')==0 .or. len(trim(new_string))/=15)cycle dated_dir = trim(new_string) read(dated_dir(1:8),*)date read(dated_dir(10:15),*)time if(datemax_date)cycle if(time>max_time)cycle n=n+1 dir(n)=trim(new_string) print '(i10,1x,a19)',n, dir(n) number_files = n end do close(lun) endif return end subroutine get_all_dated_directories