check_res Subroutine

subroutine check_res(varname, res, error)

Check tracking results

Arguments

Type IntentOptional AttributesName
character(len=labelLen), intent(in) :: varname
real(kind=rk), intent(in) :: res(:)
integer, intent(out) :: error

Called by

proc~~check_res~~CalledByGraph proc~check_res check_res program~tem_varsys_opvar_test tem_varSys_opVar_test program~tem_varsys_opvar_test->proc~check_res

Contents

Source Code


Source Code

  subroutine check_res( varname, res, error )
    ! ---------------------------------------------------------------------- !
    character(len=labelLen), intent(in) :: varname
    real(kind=rk), intent(in) :: res(:)
    integer, intent(out) :: error
    ! ---------------------------------------------------------------------- !
    integer :: iElem  
    real(kind=rk) :: diff_spt(nElems_track)
    real(kind=rk) :: diff_vec(nElems_track,2)
    ! ---------------------------------------------------------------------- !
    error = 0 
    select case (trim(varname))
    case ('lua_fun')
      diff_spt = res(:) - luaFun_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for lua_fun does not match'
      end if  
      if (dumpRes) then
        write(*,*) 'reference: ', luaFun_ref
        write(*,*) '   output: ', res
      end if  
    case ('luafun_shape')
      diff_spt = res(:) - luaFunShape_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for luafun_shape does not match'
        write(*,*) 'diff ', diff_spt
      end if  
      if (dumpRes) then
        write(*,*) 'reference: ', luaFunShape_ref
        write(*,*) '   output: ', res
      end if  
    case ('const11')
      diff_spt = res(:) - const11_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for const11 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', const11_ref
        write(*,*) '   output: ', res
      end if  
    case ('const11_shape')
      diff_spt = res(:) - const11Shape_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for const11_shape does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', const11Shape_ref
        write(*,*) '   output: ', res
      end if  
    case ('const11_lua_fun')
      diff_spt = res(:) - const11LuaFun_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for const11_lua_fun does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', const11LuaFun_ref
        write(*,*) '   output: ', res
      end if  
    case ('add1')
      diff_spt = res(:) - add1_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for add1 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', add1_ref
        write(*,*) '   output: ', res
      end if  
    case ('add2')
      diff_spt = res(:) - add2_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for add2 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', add2_ref
        write(*,*) '   output: ', res
      end if  
    case ('diff1')
      diff_spt = res(:) - diff1_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for diff1 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', diff1_ref
        write(*,*) '   output: ', res
      end if  
    case ('combine')
      do iElem = 1, nElems_track
        diff_vec(iElem,:) = res((iElem-1)*2 + 1 : (iElem-1)*2 + 2 ) &
          &               - combine_ref(iElem,:)
      end do
      if ( any(diff_vec > eps) ) then
        error = -1
        write(*,*) 'Reference value for combine does not match'
      end if  
      if (dumpRes) then
        do iElem = 1, nElems_track
          write(*,*) 'reference: ', combine_ref(iElem, :)
          write(*,*) '   output: ', res( (iElem-1)*2 + 1 : (iElem-1)*2 + 2 )
        end do  
      end if  
    case ('extract1')
      diff_spt = res(:) - extract1_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for extract1 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', extract1_ref
        write(*,*) '   output: ', res
      end if  
    case ('extract2')
      diff_spt = res(:) - extract2_ref
      if ( any(diff_spt > eps) ) then
        error = -1
        write(*,*) 'Reference value for extract2 does not match'
      end if
      if (dumpRes) then
        write(*,*) 'reference: ', extract2_ref
        write(*,*) '   output: ', res
      end if  
    case default
      write(*,*) 'Unknown variable name', trim(varname)
      error = -1
    end select
      
   end subroutine check_res