directory Subroutine

public subroutine directory()

Uses

subroutine defines vars to hold paths to various folders

Arguments

None

Source Code

        subroutine directory()
        !!  subroutine defines vars to hold paths to various folders     
  
            use constants, only : homedir, fileplace, resdir

            character(len=256) :: cwd
            logical :: dataExists, jmeanExists, depositExists, detectorsExists, phasorExists

            !get current working directory
            call get_environment_variable('PWD', cwd)
  
            ! get 'home' dir from cwd
            homedir = trim(cwd)
            ! get data dir
            fileplace = trim(homedir)//'/data/'
            !check if data directory and subdirectories exists. if not create it
#ifdef __GFORTRAN__
            inquire(file=trim(fileplace)//"/.", exist=dataExists)
            inquire(file=trim(fileplace)//"/jmean/.", exist=jmeanExists)
            inquire(file=trim(fileplace)//"/deposit/.", exist=depositExists)
            inquire(file=trim(fileplace)//"/detectors/.", exist=detectorsExists)
            inquire(file=trim(fileplace)//"/phasor/.", exist=phasorExists)
#elif __INTEL_COMPILER
            inquire(directory=trim(fileplace), exist=dataExists)
            inquire(directory=trim(fileplace)//"/jmean", exist=jmeanExists)
            inquire(directory=trim(fileplace)//"/deposit", exist=depositExists)
            inquire(directory=trim(fileplace)//"/detectors", exist=detectorsExists)
            inquire(directory=trim(fileplace)//"/phasor", exist=phasorExists)
#else 
    dataExists=.true.
    jmeanExists=.true.
    depositExists=.true.
    detectorsExists=.true.
    phasorExists=.true.
    ! error stop "Compiler not supported!"
#endif
            if(.not. dataExists)then
                call create_directory("", dataExists, "", .false.)
                call create_directory("jmean/", jmeanExists, "data/", .false.)
                call create_directory("deposit/", depositExists, "data/", .false.)
                call create_directory("detectors/", detectorsExists, "data/", .false.)
                call create_directory("phasor/", phasorExists, "data/", .false.)
            else
                call create_directory("jmean/", jmeanExists, "data/", .true.)
                call create_directory("deposit/", depositExists, "data/", .true.)
                call create_directory("detectors/", detectorsExists, "data/", .true.)
                call create_directory("phasor/", phasorExists, "data/", .true.)
            end if

            ! get res dir
            resdir = trim(homedir)//'/res/'

        end subroutine directory