! GeGetRuncard.f90 ! ! Read the runcards from file ! ! Axel Drees, Uni Heidelberg, September 1997 ! subroutine GeGetRuncard use genesis_m use runcard_m implicit none integer :: ierr integer, parameter :: lun = 37 character(len=80) :: rfile = 'runcard' character(len=80) :: resource,value ! ! Open resource file: ! In case of I/O errors we stop here, since the lack ! of resource file data is fatal for the run. ! print "(' use runcard file: 'a)" ,rfile open(lun, file=rfile, action='read', iostat=ierr) if (ierr /= 0) call GeErrorMessage("GeGetRuncard", & "can't open resource file "// & "'"//trim(rfile)//"'", & rc=ierr, fatal=.true.) do while (GeGetLine(lun, resource, value) == 0) if (index(resource,'nevents') /= 0) read(value,*) nevents if (index(resource,'nch') /= 0) read(value,*) nch if (index(resource,'bpar') /= 0) read(value,*) bpar if (index(resource,'theta_lower') /= 0) read(value,*) theta_lower if (index(resource,'theta_upper') /= 0) read(value,*) theta_upper if (index(resource,'pt_min') /= 0) read(value,*) pt_min if (index(resource,'write_hb') /= 0) read(value,*) write_hb if (index(resource,'write_data') /= 0) read(value,*) write_data if (index(resource,'hbfile') /= 0) read(value,'(a)') hbfile if (index(resource,'outfile') /= 0) read(value,'(a)') outfile if (index(resource,'resfile') /= 0) read(value,'(a)') resfile enddo close (lun) contains ! ! Returns resource and value string left adjusted. ! Strips inline comments starting with '!'. ! GeGetLine ensures that both strings have a length ! different from zero. No other consistency check ! is done. GeGetLine returns /= 0 if EOF is reached. ! recursive integer function GeGetLine(lun, resource, value) result(getL) implicit none integer :: lun, inline integer, parameter :: maxline = 80 character(len=*) :: resource, value character(len=maxline) :: line read(lun,'(a)',iostat=getL) line ! get complete line if (getL == 0) then inline = index(line,'!') ! remove inline comments if (inline /= 0) line(inline:maxline) = '' resource = line(1:index(line,':')-1) ! split line value = line(index(line,':')+1:maxline) resource = adjustl(resource) ! adjust left value = adjustl(value) if (len(trim(resource)) == 0 .or. len(trim(value)) == 0) & getL = GeGetLine(lun, resource, value) endif end function GeGetLine end subroutine GeGetRuncard