readdriverfile Subroutine

public subroutine readdriverfile()

Uses

  • proc~~readdriverfile~~UsesGraph proc~readdriverfile readdriverfile module~modfields modfields proc~readdriverfile->module~modfields module~modglobal modglobal proc~readdriverfile->module~modglobal module~modinletdata modinletdata proc~readdriverfile->module~modinletdata module~modmpi modmpi proc~readdriverfile->module~modmpi decomp_2d decomp_2d module~modfields->decomp_2d mpi mpi module~modmpi->mpi

Arguments

None

Called by

proc~~readdriverfile~~CalledByGraph proc~readdriverfile readdriverfile proc~readinitfiles readinitfiles proc~readinitfiles->proc~readdriverfile program~dalesurban DALESURBAN program~dalesurban->proc~readinitfiles

Source Code

  subroutine readdriverfile
    ! this gets called in modstartup (readinitfiles) when ibrank=.true.
    use modfields, only : u0,sv0
    use modglobal, only : ib,jb,je,jmax,kb,ke,kh,jhc,khc,cexpnr,ifinput,driverstore,ltempeq,lmoist,zh,jh,driverjobnr,cdriverjobnr,nsv,timee,tdriverstart,lhdriver,lqdriver,lsdriver,ibrank,iplanerank,driverid,cdriverid,lwarmstart
    use modmpi,    only : cmyid,myid,nprocs,slabsum,excjs
    use modinletdata, only : storetdriver,storeu0driver,storev0driver,storew0driver,storethl0driver,storeqt0driver,storesv0driver,nfile
    implicit none
    integer :: filen,filee
    integer :: fileid, IOS, filesize, filesizes
    integer :: j,k,m,n,js,jf,jfdum,jsdum
    character(24) :: name

    write(cdriverjobnr, '(i3.3)') driverjobnr
    if (driverid==0) then
      write(*,*) "Consider setting 'trestart' as '(driverstore-1)*dtdriver' of driver case ", cdriverjobnr, &
                  " or a value such that (((driverstore-1)*dtdriver)/trestart) is an integer. Ignore, if set already."
      if (.not.(lwarmstart)) then
        write(*,*) "NOTE: ensure ylen,ytot,nprocy == ylen,ytot,nprocy of driver case ",cdriverjobnr,", respectively"
        write(*,*) "NOTE: ensure ztot == ztot of driver case ",cdriverjobnr
        write(*,*) "NOTE: ensure z direction grid (i.e. zsize and other parameters if stretching) == z direction grid of driver case ",cdriverjobnr
        write(*,*) "NOTE: ensure driverstore <= last driver entry step count in driver case ",cdriverjobnr, ", check corresponding simulation log."
      else ! if lwarmstart
        write(*,*) "NOTE: ensure driverstore <= last driver entry step count in driver case ",cdriverjobnr, ", check corresponding simulation log."
      end if
      write(*,*) '========================================================================'
      write(*,*) '*** Reading precursor driver simulation ***'
    end if

    name = 'tdriver_   .'
    ! write (name(13:16)  ,'(i4.4)') nfile
    name(9:11)= '000'
    ! write (name(18:20)  ,'(i3.3)') filen
    write (name(13:15)   ,'(i3.3)') driverjobnr

    inquire(file=name,size=filesize)

    ! if(driverid==0) then
    !   write(6,*) 'Reading time stamps: ', name
    !   write(6,*) 'driverstore: ', driverstore
    !   write(6,*) 'File size of time in bytes (/8) = ', filesize
    ! endif
    ! driverstore = driverstore/4.
    ! write(6,*) 'driverstore: ', driverstore
    inquire(iolength=filesize)(timee-tdriverstart)
    open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize,IOSTAT=IOS)
    ! if(myid==0) then
    !   if (IOS > 0) then
    !     write(6,*) 'IOS = ',IOS
    !   endif
    ! endif
    do n =  1, driverstore
      read(11, rec=n, IOSTAT=IOS) storetdriver(n)
      ! if(myid==0) then
      !   if(IOS > 0) then
      !     write(6,*) 'IOS = ',IOS
      !   elseif (IOS<0) then
      !     write(6,*) 'n =', n
      !   end if
      !   write(6,'(A,e20.12)') ' Reading t:', storetdriver(n)
      ! end if
    end do
    ! storetdriver = storetdriver + timee !tg3315 added in case using a warmstart...
    close (unit=11)
    ! write(*,*) 'storetdriver', storetdriver
    ! end if
    name = 'udriver_   .'
    ! write (name(13:16)  ,'(i4.4)') nfile
    name(9:11)= cdriverid
    ! write (name(18:20)  ,'(i3.3)') filen
    write (name(13:15)   ,'(i3.3)') driverjobnr
    !write(6,*) 'Reading Driver u-velocity: ', name
    ! inquire(file=name,recl=filesize)
    inquire(iolength=filesize)u0(ib,:,:)
    !write(6,*) 'record length ',filesize
    open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
    do n = 1,driverstore
      read(11,rec=n)  ((storeu0driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
      ! if(myid==0) then
        ! write(6, '(A,e20.12)') 'Reading u(irecydriver, jb, kb)', storeu0driver(jb,kb,n)
      ! endif
    end do
    ! if(myid==0) then
      ! do k=ke,kb,-1
      !   write(6, '(A,e20.12)') 'Reading u(ib,1,:)', storeu0driver(jb,k,1)
      ! end do
    ! end if
    close (unit=11)

    name = 'vdriver_   .'
    ! write (name(13:16)  ,'(i4.4)') nfile
    name(9:11)= cdriverid
    ! write (name(18:20)  ,'(i3.3)') filen
    write (name(13:15)   ,'(i3.3)') driverjobnr
    !write(6,*) 'Reading Driver v-velocity: ', name
    ! inquire(file=name,recl=filesize)
    ! inquire(iolength=filesize)u0(ib,:,:)
    open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
    do n = 1,driverstore
      read(11,rec=n)  ((storev0driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    end do
    close (unit=11)

    name = 'wdriver_   .'
    ! write (name(13:16)  ,'(i4.4)') nfile
    name(9:11)= cdriverid
    ! write (name(18:20)  ,'(i3.3)') filen
    write (name(13:15)   ,'(i3.3)') driverjobnr
    !write(6,*) 'Reading Driver w-velocity: ', name
    ! inquire(file=name,recl=filesize)
    ! inquire(iolength=filesize)u0(ib,:,:)
    open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
    do n = 1,driverstore
      read(11,rec=n)  ((storew0driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    end do
    close (unit=11)

    !name = 'edriver_   .'
    ! write (name(13:16)  ,'(i4.4)') nfile
    ! name(9:11)= cmyid
    ! write (name(18:20)  ,'(i3.3)') filen
    ! write (name(13:15)   ,'(i3.3)') driverjobnr
    ! write(6,*) 'Reading Driver turbulent kinetic energy: ', name
    ! inquire(file=name,recl=filesize)
    ! inquire(iolength=filesize)u0(ib,:,:)
    ! open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
    ! do n = 1,driverstore
    ! read(11,rec=n)  ((storee120driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    ! enddo
    ! close (unit=11)

    if (ltempeq .and. lhdriver) then
      name = 'hdriver_   .'
      ! write (name(13:16)  ,'(i4.4)') nfile
      name(9:11)= cdriverid
      ! write (name(18:20)  ,'(i3.3)') filen
      write (name(13:15)   ,'(i3.3)') driverjobnr
      !write(6,*) 'Reading Driver temperature: ', name
      ! inquire(file=name,recl=filesize)
      open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
      do n = 1,driverstore
        read(11,rec=n)  ((storethl0driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
      end do
      !if(myid==0) then
      !  do k=ke,kb,-1
      !    write(6, '(A,e20.12)') 'Reading thl0(ib,1,:)', storethl0driver(jb,k,1)
      !  end do
      !end if

      close (unit=11)
    end if

    if (lmoist .and. lqdriver) then
      name = 'qdriver_   .'
      ! write (name(13:16)  ,'(i4.4)') nfile
      name(9:11)= cdriverid
      ! write (name(18:20)  ,'(i3.3)') filen
      write (name(13:15)   ,'(i3.3)') driverjobnr
      !write(6,*) 'Reading Driver moisture: ', name
      ! inquire(file=name,recl=filesize)
      open(unit=11,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesize)
      do n = 1,driverstore
        read(11,rec=n)  ((storeqt0driver (j,k,n),j=jb-jh,je+jh),k=kb-kh,ke+kh)
      end do
      close (unit=11)
    end if

    if (nsv>0 .and. lsdriver) then
      name = 'sdriver_   .'
      ! write (name(13:16)  ,'(i4.4)') nfile
      name(9:11)= cdriverid
      ! write (name(18:20)  ,'(i3.3)') filen
      write (name(13:15)   ,'(i3.3)') driverjobnr
      !write(6,*) 'Reading Driver scalar: ', name
      ! inquire(file=name,recl=filesize)
      inquire(iolength=filesizes)sv0(ib,:,:,:)
      open(unit=12,file=name,form='unformatted',status='old',action='read',access='direct',recl=filesizes)
      do n = 1,driverstore
        read(12,rec=n)  (((storesv0driver (j,k,m,n),j=jb-jhc,je+jhc),k=kb-khc,ke+khc),m=1,nsv)
      end do
      close (unit=12)
    end if

  end subroutine readdriverfile