readdriverfile_chunk Subroutine

public subroutine readdriverfile_chunk()

Uses

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

Arguments

None

Called by

proc~~readdriverfile_chunk~~CalledByGraph proc~readdriverfile_chunk readdriverfile_chunk proc~driverchunkread driverchunkread proc~driverchunkread->proc~readdriverfile_chunk proc~readinitfiles readinitfiles proc~readinitfiles->proc~readdriverfile_chunk proc~boundary boundary proc~boundary->proc~driverchunkread program~dalesurban DALESURBAN program~dalesurban->proc~readinitfiles program~dalesurban->proc~boundary

Source Code

  subroutine readdriverfile_chunk
    use modfields, only : u0,sv0
    use modglobal, only : ib,jb,je,jmax,kb,ke,kh,jhc,khc,cexpnr,ifinput,driverstore,chunkread_size,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, &
                             chunkreadctr, chunkread_s, chunkread_e
    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

    chunkread_s = (chunkreadctr-1)*chunkread_size + 1
    chunkread_e = chunkreadctr * chunkread_size
    if (chunkread_e > driverstore) chunkread_e = driverstore

    if (driverid==0) then
      write(*,*) '========================================================================'
      write(*,*) '*** Reading precursor driver simulation field data chunk *** ',chunkreadctr
    end if

    if (chunkreadctr==1) then

      if (driverid==0) then
        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 dircetion grid (i.e. zsize and other parameters if stretching) == z dircetion 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
      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
      close (unit=11)
    end if

    if (driverid==0) then
      write(*,*) 'Reading from driver step ',chunkread_s,' (time instant ',storetdriver(chunkread_s), &
                  ') to driver step ',chunkread_e,' (time instant ',storetdriver(chunkread_e),')'
    end if

    do k = kb-kh,ke+kh
      do j = jb-jh,je+jh
        storeu0driver(j,k,0) = storeu0driver (j,k,chunkread_size)
      end do
    end do
    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 = chunkread_s,chunkread_e!1,driverstore
      !if(myid==0) write(6,*) 'reading u_driver at step = ',n,'(',n-chunkread_s+1,') time = ',storetdriver(n)
      read(11,rec=n)  ((storeu0driver (j,k,n-chunkread_s+1),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)

    do k = kb-kh,ke+kh
      do j = jb-jh,je+jh
        storev0driver(j,k,0) = storev0driver (j,k,chunkread_size)
      end do
    end do
    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 = chunkread_s,chunkread_e!1,driverstore
      read(11,rec=n)  ((storev0driver (j,k,n-chunkread_s+1),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    end do
    close (unit=11)

    do k = kb-kh,ke+kh
      do j = jb-jh,je+jh
        storew0driver(j,k,0) = storew0driver (j,k,chunkread_size)
      end do
    end do
    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 = chunkread_s,chunkread_e!1,driverstore
      read(11,rec=n)  ((storew0driver (j,k,n-chunkread_s+1),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    end do
    close (unit=11)

    ! do k = kb-kh,ke+kh
    !   do j = jb-jh,je+jh
    !     storee120driver(j,k,0) = storee120driver (j,k,chunkread_size)
    !   end do
    ! end do
    ! 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 = chunkread_s,chunkread_e!1,driverstore
    ! read(11,rec=n)  ((storee120driver (j,k,n-chunkread_s+1),j=jb-jh,je+jh),k=kb-kh,ke+kh)
    ! enddo
    ! close (unit=11)

    if (ltempeq .and. lhdriver) then
      do k = kb-kh,ke+kh
        do j = jb-jh,je+jh
          storethl0driver(j,k,0) = storethl0driver (j,k,chunkread_size)
        end do
      end do
      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 = chunkread_s,chunkread_e!1,driverstore
        read(11,rec=n)  ((storethl0driver (j,k,n-chunkread_s+1),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
      do k = kb-kh,ke+kh
        do j = jb-jh,je+jh
          storeqt0driver(j,k,0) = storeqt0driver (j,k,chunkread_size)
        end do
      end do
      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 = chunkread_s,chunkread_e!1,driverstore
        read(11,rec=n)  ((storeqt0driver (j,k,n-chunkread_s+1),j=jb-jh,je+jh),k=kb-kh,ke+kh)
      end do
      close (unit=11)
    end if

    if (nsv>0 .and. lsdriver) then
      do m = 1,nsv
        do k = kb-kh,ke+kh
          do j = jb-jh,je+jh
            storesv0driver(j,k,m,0) = storesv0driver (j,k,m,chunkread_size)
          end do
        end do
      end do
      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 = chunkread_s,chunkread_e!1,driverstore
        read(12,rec=n)  (((storesv0driver (j,k,m,n-chunkread_s+1),j=jb-jhc,je+jhc),k=kb-khc,ke+khc),m=1,nsv)
      end do
      close (unit=12)
    end if

    chunkreadctr = chunkreadctr + 1
  end subroutine readdriverfile_chunk