read_namelist_inputs Subroutine

public subroutine read_namelist_inputs()

Arguments

None

Calls

proc~~read_namelist_inputs~~CallsGraph proc~read_namelist_inputs read_namelist_inputs proc~default_scalar_advection default_scalar_advection proc~read_namelist_inputs->proc~default_scalar_advection

Called by

proc~~read_namelist_inputs~~CalledByGraph proc~read_namelist_inputs read_namelist_inputs proc~initrunparams initrunparams proc~initrunparams->proc~read_namelist_inputs program~udales uDALES program~udales->proc~initrunparams

Source Code

   subroutine read_namelist_inputs

      !-----------------------------------------------------------------|
      !                                                                 |
      !     Reads all general options from namoptions                   |
      !                                                                 |
      !      Jasper Tomas                 31/03/2014                    |
      !      Chiel van Heerwaarden        15/06/2007                    |
      !      Thijs Heus                   15/06/2007                    |
      !-----------------------------------------------------------------|

      implicit none
      integer :: ierr

      if (myid == 0) then
         if (command_argument_count() >= 1) then
            call get_command_argument(1, fname_options)
         end if
         !write (*, *) fname_options

         open (ifnamopt, file=fname_options, status='old', iostat=ierr)
         if (ierr /= 0) then
            write(0, *) 'ERROR: Namoptions does not exist'
            write(0, *) 'iostat error: ', ierr
            stop 1
         end if

         read (ifnamopt, RUN, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions RUN'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, RUN)
         rewind (ifnamopt)

         read (ifnamopt, DOMAIN, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions DOMAIN'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, DOMAIN)
         rewind (ifnamopt)

         read (ifnamopt, PHYSICS, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions PHYSICS'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, PHYSICS)
         rewind (ifnamopt)

         read (ifnamopt, DYNAMICS, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions DYNAMICS'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, DYNAMICS)
         rewind (ifnamopt)

         read (ifnamopt, BC, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions BC'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, BC)
         rewind (ifnamopt)

         read (ifnamopt, INLET, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions INLET'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, INLET)
         rewind (ifnamopt)

         read (ifnamopt, DRIVER, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'Problem in namoptions DRIVER'
            write(0, *) 'iostat error: ', ierr
            stop 'ERROR: Problem in namoptions DRIVER'
         endif
         !write (6, DRIVER)
         rewind (ifnamopt)

         read (ifnamopt, WALLS, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions WALLS'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, WALLS)
         rewind (ifnamopt)

         read (ifnamopt, ENERGYBALANCE, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions EB'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, ENERGYBALANCE)
         rewind (ifnamopt)

         read (ifnamopt, SCALARS, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions SCALARS'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, SCALARS)
         rewind (ifnamopt)

         read (ifnamopt, CHEMISTRY, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions CHEMISTRY'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         !write (6, CHEMISTRY)
         rewind (ifnamopt)

         read (ifnamopt, TREES, iostat=ierr)
         if (ierr > 0) then
            print *, 'ERROR: Problem in namoptions TREES'
            print *, 'iostat error: ', ierr
            stop 1
         endif
         !write (6, TREES)
         rewind (ifnamopt)

         read (ifnamopt, PURIFS, iostat=ierr)
         if (ierr > 0) then
            print *, 'ERROR: Problem in namoptions PURIFS'
            print *, 'iostat error: ', ierr
            stop 1
         endif
         !write (6, PURIFS)
         rewind (ifnamopt)

         read (ifnamopt, HEATPUMP, iostat=ierr)
         if (ierr > 0) then
            print *, 'ERROR: Problem in namoptions HEATPUMP'
            print *, 'iostat error: ', ierr
            stop 1
         endif
         !write (6, HEATPUMP)
         rewind (ifnamopt)

         read (ifnamopt, OUTPUT, iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions OUTPUT'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         if (.not. ieee_is_finite(receptor_height) .or. receptor_height <= 0.) then
            write(0, *) 'ERROR: OUTPUT.receptor_height must be finite and greater than zero.'
            stop 1
         endif
         if (nreceptor_heights < 0 .or. nreceptor_heights > size(receptor_heights)) then
            write(0, *) 'ERROR: OUTPUT.nreceptor_heights is outside the supported range.'
            stop 1
         endif
         if (nreceptor_heights > 0) then
            if (any(.not. ieee_is_finite(receptor_heights(1:nreceptor_heights))) .or. &
                any(receptor_heights(1:nreceptor_heights) <= 0.)) then
               write(0, *) 'ERROR: OUTPUT.receptor_heights must be finite and positive.'
               stop 1
            endif
            if (abs(receptor_heights(1)-receptor_height) > &
                100.*epsilon(1.)*max(1.,abs(receptor_height))) then
               write(0, *) 'ERROR: First receptor_heights entry must equal receptor_height.'
               stop 1
            endif
            if (any(receptor_heights(2:nreceptor_heights) <= receptor_heights(1:nreceptor_heights-1))) then
               write(0, *) 'ERROR: OUTPUT.receptor_heights must be strictly increasing.'
               stop 1
            endif
         endif
         !write (6, OUTPUT)
         rewind (ifnamopt)

         read (ifnamopt,NAMSUBGRID,iostat=ierr)
         if (ierr > 0) then
            write(0, *) 'ERROR: Problem in namoptions NAMSUBGRID'
            write(0, *) 'iostat error: ', ierr
            stop 1
         endif
         rewind (ifnamopt)
         !write(6 ,NAMSUBGRID)
 
         if (lrandomize) then
            if (.not. lles) then
               write(0, *) 'Cannot use lrandomize=.true. with lles=.false.'
               stop 1
            end if
            if (irandom == 0) then
               write(0, *) 'Please define RUN.irandom when lrandomize=.true.'
               stop 1
            end if
         end if

         call default_scalar_advection

         close(ifnamopt)
      end if
   end subroutine read_namelist_inputs