instant_probe_main Subroutine

private subroutine instant_probe_main()

Arguments

None

Calls

proc~~instant_probe_main~~CallsGraph proc~instant_probe_main instant_probe_main mpi_reduce mpi_reduce proc~instant_probe_main->mpi_reduce nf90_put_var nf90_put_var proc~instant_probe_main->nf90_put_var nf90_sync nf90_sync proc~instant_probe_main->nf90_sync proc~check check proc~instant_probe_main->proc~check proc~instant_gather_probe_var instant_gather_probe_var proc~instant_probe_main->proc~instant_gather_probe_var nf90_strerror nf90_strerror proc~check->nf90_strerror proc~air_temperature air_temperature proc~instant_gather_probe_var->proc~air_temperature proc~relative_humidity relative_humidity proc~instant_gather_probe_var->proc~relative_humidity zend zend proc~instant_gather_probe_var->zend zstart zstart proc~instant_gather_probe_var->zstart

Called by

proc~~instant_probe_main~~CalledByGraph proc~instant_probe_main instant_probe_main proc~instant_main instant_main proc~instant_main->proc~instant_probe_main program~udales uDALES program~udales->proc~instant_main

Source Code

    subroutine instant_probe_main
      implicit none
      real, allocatable :: send_buf(:), recv_buf(:)
      integer :: vn
      character(80) :: varname
      
      if (.not. lprobedump) return
         
      ! Only rank 0 tracks record number
      if (myid == 0) nrecprobe = nrecprobe + 1
      
      allocate(send_buf(nprobe))
      allocate(recv_buf(nprobe))
      
      ! Always write time first (Rank 0)
      if (myid == 0) then
          call check( nf90_put_var(ncidprobe, varid_time, timee, start=(/nrecprobe/)) )
      end if

      ! Loop over all requested variables
      do vn = 1, nprobevars
        varname = probevars(3*vn-2 : 3*vn-1)
        send_buf = 0.0
        recv_buf = 0.0
        
        call instant_gather_probe_var(varname, send_buf)
        
        ! Reduce to Rank 0
        call MPI_REDUCE(send_buf, recv_buf, nprobe, my_real, MPI_SUM, 0, comm3d, mpierr)
        
        if (myid == 0) then
            ! Use start/count to append to time dimension
            call check( nf90_put_var(ncidprobe, varid_vals(vn), recv_buf, &
                                    start=(/1, nrecprobe/), count=(/nprobe, 1/)) )
        end if
      end do
      
      if (myid == 0) then
        call check( nf90_sync(ncidprobe) )
      end if
      
      deallocate(send_buf, recv_buf)
    end subroutine instant_probe_main